Class: PodcastAgent
- Inherits:
-
Object
- Object
- PodcastAgent
- Defined in:
- lib/podcast_agent.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, type:, user_agent:) ⇒ PodcastAgent
constructor
A new instance of PodcastAgent.
Constructor Details
#initialize(name:, type:, user_agent:) ⇒ PodcastAgent
Returns a new instance of PodcastAgent.
7 8 9 10 11 12 13 |
# 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 |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
5 6 7 |
# File 'lib/podcast_agent.rb', line 5 def browser @browser end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/podcast_agent.rb', line 5 def name @name end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
5 6 7 |
# File 'lib/podcast_agent.rb', line 5 def platform @platform end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/podcast_agent.rb', line 5 def type @type end |
Class Method Details
.database ⇒ Object
22 23 24 |
# 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:) ⇒ Object
15 16 17 18 19 20 |
# 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 |