Class: DeviceAware::Device

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/device_aware/device.rb

Instance Method Summary collapse

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(options={})
  @user_agent = options[:user_agent] || options['user_agent']
  @server = URI.parse(options[:server] || options['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

#eachObject

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

Returns:

  • (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

Returns:

  • (Boolean)


43
# File 'lib/device_aware/device.rb', line 43

def unknown? ; data.empty? || data == {} ; end