Module: UserAgentList::ParserUa

Included in:
UserAgentList
Defined in:
lib/user_agent_list/parser_ua.rb

Instance Method Summary collapse

Instance Method Details

#allObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/user_agent_list/parser_ua.rb', line 3

def all
  result = {}
  parser.css('h3').each do |item|
    parser.css("a:contains('#{item.text}')").each do |link|
      result[item.text] ||= []
      result[item.text] << link.children.text unless link.children.text =~ /-->>/
    end
    result.delete(item.text) if result[item.text] && result[item.text].empty?
  end
  result
end

#by_browser(string) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/user_agent_list/parser_ua.rb', line 15

def by_browser(string)
  raise BrowserNotSupported, "#{string} is not supported" unless SUPPORTED_BROWSERS.include?(string)

  result = []
  parser.css("a:contains('#{string}')").each do |link|
    result << link.children.text unless link.children.text =~ /-->>/
  end
  result
end