class PodcastAgent

Attributes

browser[R]
name[R]
platform[R]
type[R]

Public Class Methods

database() click to toggle source
# File lib/podcast_agent.rb, line 22
def self.database
  @database ||= YAML.load_file('lib/data/podcast_agents.yml')
end
find_by(user_agent_string:) click to toggle source
# File lib/podcast_agent.rb, line 15
def self.find_by(user_agent_string:)
  entry = database.find do |attrs|
    user_agent_string =~ Regexp.new(attrs['regex'])
  end
  new(name: entry['name'], type: entry['type'], user_agent: UserAgent.parse(user_agent_string)) if entry
end
new(name:, type:, user_agent:) click to toggle source
# File lib/podcast_agent.rb, line 7
def initialize(name:, type:, user_agent:)
  @name  = name
  @type = type
  @user_agent = user_agent
  @browser    = user_agent.browser
  @platform   = user_agent.platform
end