Class: Ahoy::Deckhands::TechnologyDeckhand
- Inherits:
-
Object
- Object
- Ahoy::Deckhands::TechnologyDeckhand
- Defined in:
- lib/ahoy/deckhands/technology_deckhand.rb
Instance Method Summary collapse
- #browser ⇒ Object
- #device_type ⇒ Object
-
#initialize(user_agent) ⇒ TechnologyDeckhand
constructor
A new instance of TechnologyDeckhand.
- #os ⇒ Object
Constructor Details
#initialize(user_agent) ⇒ TechnologyDeckhand
Returns a new instance of TechnologyDeckhand.
4 5 6 |
# File 'lib/ahoy/deckhands/technology_deckhand.rb', line 4 def initialize(user_agent) @user_agent = user_agent end |
Instance Method Details
#browser ⇒ Object
8 9 10 |
# File 'lib/ahoy/deckhands/technology_deckhand.rb', line 8 def browser agent.name end |
#device_type ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ahoy/deckhands/technology_deckhand.rb', line 16 def device_type @device_type ||= begin browser = Browser.new(@user_agent) if browser.bot? "Bot" elsif browser.device.tv? "TV" elsif browser.device.console? "Console" elsif browser.device.tablet? "Tablet" elsif browser.device.mobile? "Mobile" else "Desktop" end end end |
#os ⇒ Object
12 13 14 |
# File 'lib/ahoy/deckhands/technology_deckhand.rb', line 12 def os agent.os.name end |