class PodcastAgentParser::Parser
Public Class Methods
new()
click to toggle source
# File lib/podcast_agent_parser/parser.rb, line 6 def initialize @patterns_path = File.read(PodcastAgentParser::DefaultPatternsPath) end
Public Instance Methods
parse(user_agent_string)
click to toggle source
# File lib/podcast_agent_parser/parser.rb, line 10 def parse(user_agent_string) JSON.parse(@patterns_path).each do |pattern| pattern['user_agents'].each do |str| if Regexp.new(str).match(user_agent_string) return Agent.new( pattern['app'], pattern['device'], pattern['os'], pattern['bot'] ) end end end return nil end