Class: Arcp::Lease::LeaseRequest
- Inherits:
-
Data
- Object
- Data
- Arcp::Lease::LeaseRequest
- Defined in:
- lib/arcp/lease.rb
Instance Attribute Summary collapse
-
#budget ⇒ Object
readonly
Returns the value of attribute budget.
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#model_use ⇒ Object
readonly
Returns the value of attribute model_use.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(capabilities:, budget: nil, model_use: nil, expires_at: nil) ⇒ LeaseRequest
constructor
A new instance of LeaseRequest.
- #to_h ⇒ Object
Constructor Details
#initialize(capabilities:, budget: nil, model_use: nil, expires_at: nil) ⇒ LeaseRequest
Returns a new instance of LeaseRequest.
81 82 83 84 85 86 87 88 |
# File 'lib/arcp/lease.rb', line 81 def initialize(capabilities:, budget: nil, model_use: nil, expires_at: nil) super( capabilities: Array(capabilities).freeze, budget: budget, model_use: model_use ? Array(model_use).freeze : nil, expires_at: expires_at ) end |
Instance Attribute Details
#budget ⇒ Object (readonly)
Returns the value of attribute budget
80 81 82 |
# File 'lib/arcp/lease.rb', line 80 def budget @budget end |
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities
80 81 82 |
# File 'lib/arcp/lease.rb', line 80 def capabilities @capabilities end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at
80 81 82 |
# File 'lib/arcp/lease.rb', line 80 def expires_at @expires_at end |
#model_use ⇒ Object (readonly)
Returns the value of attribute model_use
80 81 82 |
# File 'lib/arcp/lease.rb', line 80 def model_use @model_use end |
Class Method Details
.from_h(h) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/arcp/lease.rb', line 90 def self.from_h(h) return nil if h.nil? h = h.transform_keys(&:to_s) new( capabilities: Array(h['capabilities']).freeze, budget: h['cost.budget'] ? CostBudget.parse(h['cost.budget']) : nil, model_use: h['model.use'] ? Array(h['model.use']).freeze : nil, expires_at: h['expires_at'] ) end |
Instance Method Details
#to_h ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/arcp/lease.rb', line 102 def to_h out = { 'capabilities' => capabilities } out['cost.budget'] = budget.to_a if budget out['model.use'] = model_use if model_use out['expires_at'] = expires_at if expires_at out end |