Skip to content

Instantly share code, notes, and snippets.

@tit
Created November 5, 2019 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tit/58a48f304c190793a86d82f9438cca63 to your computer and use it in GitHub Desktop.
Save tit/58a48f304c190793a86d82f9438cca63 to your computer and use it in GitHub Desktop.
Case URI Regexp
# frozen_string_literal: true
url_string = 'https://example.com/foo'
url_object = URI url_string
# false
puts case url_object
when %r{^https://example\.com}
true
else
false
end
# true
puts case String url_object
when %r{^https://example\.com}
true
else
false
end
# true
puts case url_string
when %r{^https://example\.com}
true
else
false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment