Class: Model
- Inherits:
-
Object
- Object
- Model
- Defined in:
- lib/active_device/model.rb
Instance Attribute Summary collapse
-
#user_agent ⇒ Object
readonly
User agent user_agent.
Class Method Summary collapse
- .brand_model(user_agent) ⇒ Object
- .htc_models(user_agent) ⇒ Object
- .model_clear(model) ⇒ Object
-
.model_reselution(user_agent) ⇒ Object
Return the model reselution for user agent user_agent.
-
.nokia_models(user_agent) ⇒ Object
Return the Nokia model for user agent user_agent.
- .samsung_models(user_agent) ⇒ Object
- .sonyericsson_models(user_agent) ⇒ Object
Instance Method Summary collapse
-
#initialize(user_agent) ⇒ Model
constructor
Initialize with user agent user_agent.
Constructor Details
#initialize(user_agent) ⇒ Model
Initialize with user agent user_agent.
10 11 12 |
# File 'lib/active_device/model.rb', line 10 def initialize user_agent @user_agent = user_agent.strip end |
Instance Attribute Details
#user_agent ⇒ Object (readonly)
User agent user_agent.
5 6 7 |
# File 'lib/active_device/model.rb', line 5 def user_agent @user_agent end |
Class Method Details
.brand_model(user_agent) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active_device/model.rb', line 14 def self.brand_model user_agent case user_agent when /iPhone/i ; :iPhone when /SAMSUNG[\w\-\.\_\ ]*/i ; samsung_models user_agent when /Nokia[\w\.\_\ ]*/i ; nokia_models user_agent when /HTC[\w\-\.\_\ ]*/i ; htc_models user_agent when /SonyEricsson[\w\-\.\_\ ]*/i ; sonyericsson_models user_agent when /^Mozilla[0-9\-\.\_\ ]*/i ; :'Unknown Yet' else ; :"#{user_agent[/[\w\-\.\_]*/i]}" end end |
.htc_models(user_agent) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/active_device/model.rb', line 39 def self.htc_models user_agent if user_agent =~ /^HTC[\w\-\.\_\ ]*/i model = user_agent[/[\w\-\.\_\ ]*/i] elsif user_agent =~ /Vodafone[\w\-\.\_\ ]*/i model = user_agent[/Vodafone[\w\-\.\_\ ]*/i] else model = user_agent[/HTC[\w\-\.\_\ ]*/i] end model_clear model end |
.model_clear(model) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/active_device/model.rb', line 68 def self.model_clear model model = model.to_s if model.include?("Profile") model = model.gsub(/Profile[\w\.\_\ ]*/i, "") elsif model.include?("Mozilla") model = model.gsub(/Mozilla[\w\.\_\ ]*/i, "") end :"#{model.chomp("-").strip}" end |
.model_reselution(user_agent) ⇒ Object
Return the model reselution for user agent user_agent.
80 81 82 83 84 85 |
# File 'lib/active_device/model.rb', line 80 def self.model_reselution user_agent case user_agent when /([0-9]+x+[0-9]*)/i ; :"#{user_agent[/([0-9]+x+[0-9]*)/i]}" else ; :'Not Recognized' end end |
.nokia_models(user_agent) ⇒ Object
Return the Nokia model for user agent user_agent. Note: Nokia Models Include “Nokia” Returend Value.
30 31 32 33 34 35 36 37 |
# File 'lib/active_device/model.rb', line 30 def self.nokia_models user_agent if user_agent =~ /^Nokia[\w\.\_\ ]*/i model = user_agent[/Nokia[\w\.\_\ ]*/i] else model = user_agent[/Nokia[\w\.\_\ ]*/i] end model_clear model end |
.samsung_models(user_agent) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/active_device/model.rb', line 59 def self.samsung_models user_agent if user_agent =~ /^Samsung[\w\.\_\-]*/i model = user_agent[/Samsung[\w\.\_\-]*/i] else model = user_agent[/Samsung[\w\.\_\-]*/i] end model_clear model end |
.sonyericsson_models(user_agent) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/active_device/model.rb', line 50 def self.sonyericsson_models user_agent if user_agent =~ /^SonyEricsson[\w\.\_]*/i model = user_agent[/SonyEricsson[\w\.\_]*/i] else model = user_agent[/SonyEricsson[\w\.\_]*/i] end model_clear model end |