Class: UserAgent
- Inherits:
-
Object
- Object
- UserAgent
- Defined in:
- lib/user_agent.rb
Instance Attribute Summary collapse
-
#string ⇒ Object
Returns the value of attribute string.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type) ⇒ UserAgent
constructor
A new instance of UserAgent.
Constructor Details
#initialize(type) ⇒ UserAgent
Returns a new instance of UserAgent.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/user_agent.rb', line 7 def initialize(type) @type = type ua_types = ["crawler", "desktop_browser", "mobile_browser", "console", "offline_browser", "email_client", "link_checker", "email_collector", "validator", "feed_reader", "library", "cloud_platform", "other"] ua_h = YAML.load_file(File.("../data/user_agents.yml", __FILE__)) if ua_types.include?(type) @string = ua_h[type].sample.to_s else @string = ua_h.values.flatten.sample end end |
Instance Attribute Details
#string ⇒ Object
Returns the value of attribute string.
5 6 7 |
# File 'lib/user_agent.rb', line 5 def string @string end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/user_agent.rb', line 5 def type @type end |