Class: ReplicateClient::Hardware
- Inherits:
-
Object
- Object
- ReplicateClient::Hardware
- Defined in:
- lib/replicate-client/hardware.rb
Constant Summary collapse
- INDEX_PATH =
"/hardware"
Instance Attribute Summary collapse
-
#name ⇒ String
The name of the hardware.
-
#sku ⇒ String
The SKU of the hardware.
Class Method Summary collapse
-
.all ⇒ Array<ReplicateClient::Hardware>
List all available hardware.
-
.find_by(sku:) ⇒ ReplicateClient::Hardware?
Find hardware by SKU.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ ReplicateClient::Hardware
constructor
Initialize a new hardware instance.
-
#to_s ⇒ String
Convert the hardware object to a string representation.
Constructor Details
#initialize(attributes) ⇒ ReplicateClient::Hardware
Initialize a new hardware instance.
41 42 43 44 |
# File 'lib/replicate-client/hardware.rb', line 41 def initialize(attributes) @sku = attributes["sku"] @name = attributes["name"] end |
Instance Attribute Details
#name ⇒ String
The name of the hardware.
34 35 36 |
# File 'lib/replicate-client/hardware.rb', line 34 def name @name end |
#sku ⇒ String
The SKU of the hardware.
29 30 31 |
# File 'lib/replicate-client/hardware.rb', line 29 def sku @sku end |
Class Method Details
.all ⇒ Array<ReplicateClient::Hardware>
List all available hardware.
11 12 13 14 |
# File 'lib/replicate-client/hardware.rb', line 11 def all response = ReplicateClient.client.get(INDEX_PATH) response.map { |attributes| new(attributes) } end |
.find_by(sku:) ⇒ ReplicateClient::Hardware?
Find hardware by SKU.
21 22 23 |
# File 'lib/replicate-client/hardware.rb', line 21 def find_by(sku:) all.find { |hardware| hardware.sku == sku } end |
Instance Method Details
#to_s ⇒ String
Convert the hardware object to a string representation.
49 50 51 |
# File 'lib/replicate-client/hardware.rb', line 49 def to_s "#{name} (#{sku})" end |