Module: Utility::URL

Included in:
Utility
Defined in:
lib/utility/url.rb

Instance Method Summary collapse

Instance Method Details

#html_escape(html) ⇒ Object



26
27
28
# File 'lib/utility/url.rb', line 26

def html_escape(html)
  CGI::escapeHTML(html).gsub(" ", " ")
end

#html_text(html) ⇒ Object



34
35
36
# File 'lib/utility/url.rb', line 34

def html_text(html)
  Nokogiri::HTML(html).text
end

#html_unescape(html) ⇒ Object



30
31
32
# File 'lib/utility/url.rb', line 30

def html_unescape(html)
  Nokogiri::HTML.parse(html).text
end

#parse_query(url) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/utility/url.rb', line 6

def parse_query(url)
  if url =~ URI::regexp
    CGI.parse URI.parse(url).query
  else
    CGI.parse url
  end
end

#url_escape(url, all = :no) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/utility/url.rb', line 14

def url_escape(url, all = :no)
  if url =~ URI::regexp && all != :all
    URI.escape url
  else
    CGI::escape url
  end
end

#url_unescape(url) ⇒ Object



22
23
24
# File 'lib/utility/url.rb', line 22

def url_unescape(url)
  URI.unescape url
end