Class: Agent212::UserAgent
- Inherits:
-
Object
- Object
- Agent212::UserAgent
- Defined in:
- lib/agent212/user_agent.rb
Instance Attribute Summary collapse
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
Class Method Summary collapse
Instance Method Summary collapse
- #comments ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ UserAgent
constructor
A new instance of UserAgent.
- #products ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ UserAgent
Returns a new instance of UserAgent.
9 10 11 |
# File 'lib/agent212/user_agent.rb', line 9 def initialize @parts = [] # either products or strings (comments) end |
Instance Attribute Details
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
7 8 9 |
# File 'lib/agent212/user_agent.rb', line 7 def parts @parts end |
Class Method Details
.empty ⇒ Object
21 22 23 |
# File 'lib/agent212/user_agent.rb', line 21 def self.empty new end |
Instance Method Details
#comments ⇒ Object
29 30 31 |
# File 'lib/agent212/user_agent.rb', line 29 def comments @parts.select { |part| part.is_a? String } end |
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/agent212/user_agent.rb', line 33 def empty? @parts.empty? end |
#products ⇒ Object
25 26 27 |
# File 'lib/agent212/user_agent.rb', line 25 def products @parts.select { |part| part.is_a? Product } end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/agent212/user_agent.rb', line 37 def to_s "UserAgent: " + @parts.join(" ") end |