Class: Handset

Inherits:
Object
  • Object
show all
Defined in:
lib/active_device/handset.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_agent) ⇒ Handset

Initialize with user agent string.



14
15
16
# File 'lib/active_device/handset.rb', line 14

def initialize user_agent
  @user_agent = user_agent.strip
end

Instance Attribute Details

#user_agentObject (readonly)

User agent string.



9
10
11
# File 'lib/active_device/handset.rb', line 9

def user_agent
  @user_agent
end

Class Method Details

.is_brand?(user_agent, brand) ⇒ Boolean

Is string. Device

Returns:

  • (Boolean)


53
54
55
56
57
58
# File 'lib/active_device/handset.rb', line 53

def self.is_brand? user_agent, brand
  brand_sym = Brand.mobile_brand user_agent
  brand_sym = brand_sym.to_s.downcase
  brand = brand.to_s.downcase
  brand_sym.include? brand
end

.is_handset?(user_agent, model) ⇒ Boolean

Is string. Device

Returns:

  • (Boolean)


33
34
35
36
37
38
# File 'lib/active_device/handset.rb', line 33

def self.is_handset? user_agent, model
  model_sym = Model.brand_model user_agent
  model_sym = model_sym.to_s.downcase
  model = model.to_s.downcase
  model_sym.include? model
end

.is_mobile?(user_agent) ⇒ Boolean

Is string. Mobile Device

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
# File 'lib/active_device/handset.rb', line 21

def self.is_mobile? user_agent
  mobi = Brand.mobile_brand user_agent
  if mobi == :UnknownMobile
    false
  else
    true
  end
end

.is_model?(user_agent, model) ⇒ Boolean

Is string. Device

Returns:

  • (Boolean)


43
44
45
46
47
48
# File 'lib/active_device/handset.rb', line 43

def self.is_model? user_agent, model
  model_sym = Model.brand_model user_agent
  model_sym = model_sym.to_s.downcase
  model = model.to_s.downcase
  model_sym.include? model
end