Module: Tweetwine::Uri

Defined in:
lib/tweetwine/uri.rb

Constant Summary collapse

UNSAFE_CHARS_REGEXP =
/[^#{URI::PATTERN::UNRESERVED}]/

Class Method Summary collapse

Class Method Details

.extract(*args) ⇒ Object



18
19
20
# File 'lib/tweetwine/uri.rb', line 18

def extract(*args)
  parser.extract(*args)
end

.parse(*args) ⇒ Object



22
23
24
# File 'lib/tweetwine/uri.rb', line 22

def parse(*args)
  parser.parse(*args)
end

.parserObject



10
11
12
13
14
15
16
# File 'lib/tweetwine/uri.rb', line 10

def parser
  if ::URI.const_defined? :Parser
    @parser ||= ::URI::Parser.new
  else
    ::URI
  end
end

.percent_encode(str) ⇒ Object



26
27
28
# File 'lib/tweetwine/uri.rb', line 26

def percent_encode(str)
  parser.escape(str.to_s, UNSAFE_CHARS_REGEXP)
end