Class: DeviceAware::Device
- Inherits:
-
Object
- Object
- DeviceAware::Device
- Includes:
- Enumerable
- Defined in:
- lib/device_aware/device.rb
Instance Method Summary collapse
-
#[](key) ⇒ Object
allow direct access to data for anything we don’t alias.
-
#each ⇒ Object
be Enumerable.
-
#initialize(options = {}) ⇒ Device
constructor
A new instance of Device.
- #is?(phone) ⇒ Boolean
- #unknown? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Device
Returns a new instance of Device.
9 10 11 12 |
# File 'lib/device_aware/device.rb', line 9 def initialize(={}) @user_agent = [:user_agent] || ['user_agent'] @server = URI.parse([:server] || ['server']) end |
Instance Method Details
#[](key) ⇒ Object
allow direct access to data for anything we don’t alias
20 21 22 |
# File 'lib/device_aware/device.rb', line 20 def [](key) data[key] end |
#each ⇒ Object
be Enumerable
15 16 17 |
# File 'lib/device_aware/device.rb', line 15 def each data.each {|k,v| yield(k, coerce(v)) } end |
#is?(phone) ⇒ Boolean
45 46 47 |
# File 'lib/device_aware/device.rb', line 45 def is?(phone) self.model.downcase == phone.to_s.downcase end |
#unknown? ⇒ Boolean
43 |
# File 'lib/device_aware/device.rb', line 43 def unknown? ; data.empty? || data == {} ; end |