Class: Particle::ProductFirmware
- Inherits:
-
Model
- Object
- Model
- Particle::ProductFirmware
show all
- Defined in:
- lib/particle/product_firmware.rb
Overview
Domain model for one Particle device
Constant Summary
collapse
- ID_REGEX =
/^\d{1,6}$/
Instance Method Summary
collapse
Methods inherited from Model
attribute_reader, #attributes, #id, #inspect
Constructor Details
#initialize(client, product_or_id, attributes) ⇒ ProductFirmware
Returns a new instance of ProductFirmware.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/particle/product_firmware.rb', line 9
def initialize(client, product_or_id, attributes)
super(client, attributes)
product = client.product(product_or_id)
@attributes = { version: attributes } if attributes.is_a?(Integer) || attributes.is_a?(String)
@attributes = @attributes.merge(product: product, product_id: product.id)
@fully_loaded = true if @attributes.key?(:title)
end
|
Instance Method Details
#description ⇒ Object
35
36
37
38
|
# File 'lib/particle/product_firmware.rb', line 35
def description
get_attributes unless @attributes[:description]
@attributes[:description]
end
|
#get_attributes ⇒ Object
20
21
22
23
|
# File 'lib/particle/product_firmware.rb', line 20
def get_attributes
@loaded = @fully_loaded = true
@attributes = @client.product_firmware_attributes(self)
end
|
#path ⇒ Object
48
49
50
|
# File 'lib/particle/product_firmware.rb', line 48
def path
"/v1/products/#{product_id}/firmware/#{version}"
end
|
#product ⇒ Object
40
41
42
|
# File 'lib/particle/product_firmware.rb', line 40
def product
@attributes[:product]
end
|
#product_id ⇒ Object
44
45
46
|
# File 'lib/particle/product_firmware.rb', line 44
def product_id
product.id
end
|
#title ⇒ Object
30
31
32
33
|
# File 'lib/particle/product_firmware.rb', line 30
def title
get_attributes unless @attributes[:title]
@attributes[:title]
end
|
#upload_path ⇒ Object
52
53
54
|
# File 'lib/particle/product_firmware.rb', line 52
def upload_path
"/v1/products/#{product_id}/firmware"
end
|
#version ⇒ Object
25
26
27
28
|
# File 'lib/particle/product_firmware.rb', line 25
def version
get_attributes unless @attributes[:version]
@attributes[:version]
end
|