Class: WurflCloud::DeviceCapabilities
- Inherits:
-
Object
- Object
- WurflCloud::DeviceCapabilities
- Defined in:
- lib/wurfl_cloud/device_capabilities.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #empty? ⇒ Boolean
- #has_key?(key) ⇒ Boolean
-
#initialize(ua = nil) ⇒ DeviceCapabilities
constructor
A new instance of DeviceCapabilities.
- #merge(newvalues) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(ua = nil) ⇒ DeviceCapabilities
Returns a new instance of DeviceCapabilities.
19 20 21 22 23 24 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 19 def initialize(ua = nil) @capabilities = {} @mtime = Time.at(0) @id = nil @user_agent = ua end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
17 18 19 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 17 def id @id end |
#mtime ⇒ Object
Returns the value of attribute mtime.
17 18 19 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 17 def mtime @mtime end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
17 18 19 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 17 def user_agent @user_agent end |
Class Method Details
.parse(json) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 50 def parse(json) object = JSON.parse(json) new.tap do |device_capabilities| object["capabilities"].each do |key,value| device_capabilities[key] = cast_value(value) end device_capabilities.id = object["id"] device_capabilities["id"] = object["id"] device_capabilities.mtime = Time.at(object["mtime"].to_i) end rescue raise WurflCloud::Errors::MalformedResponseError.new end |
Instance Method Details
#[](key) ⇒ Object
26 27 28 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 26 def [](key) @capabilities[key] end |
#[]=(key, value) ⇒ Object
30 31 32 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 30 def []=(key, value) @capabilities[key] = value end |
#empty? ⇒ Boolean
38 39 40 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 38 def empty? @capabilities.empty? end |
#has_key?(key) ⇒ Boolean
42 43 44 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 42 def has_key?(key) @capabilities.has_key?(key) end |
#merge(newvalues) ⇒ Object
34 35 36 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 34 def merge(newvalues) @capabilities.merge!(newvalues) end |
#to_hash ⇒ Object
46 47 48 |
# File 'lib/wurfl_cloud/device_capabilities.rb', line 46 def to_hash @capabilities.clone end |