Class: Ahoy::Deckhands::TechnologyDeckhand

Inherits:
Object
  • Object
show all
Defined in:
lib/ahoy/deckhands/technology_deckhand.rb

Instance Method Summary collapse

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

#browserObject



8
9
10
# File 'lib/ahoy/deckhands/technology_deckhand.rb', line 8

def browser
  agent.name
end

#device_typeObject



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

#osObject



12
13
14
# File 'lib/ahoy/deckhands/technology_deckhand.rb', line 12

def os
  agent.os.name
end