Class: Universa::ContractState
- Inherits:
-
Object
- Object
- Universa::ContractState
- Defined in:
- lib/universa/client.rb
Overview
The state of some contract reported by thee network. It is a convenience wrapper around Universa ItemState structure.
Instance Method Summary collapse
-
#approved? ⇒ Boolean
same as #is_approved.
-
#errors ⇒ Array(Hash)
get errors reported by the network.
-
#errors? ⇒ Boolean
True if the state contain errors.
-
#initialize(universa_contract_state) ⇒ ContractState
constructor
A new instance of ContractState.
- #inspect ⇒ Object
-
#is_approved ⇒ Object
True if the contract state was approved.
-
#is_pending ⇒ Object
Check that state us
PENDING
. -
#pending? ⇒ Boolean
same as #is_pending.
-
#state ⇒ Object
ItemState structure reported by the UMI.
- #to_s ⇒ Object
Constructor Details
#initialize(universa_contract_state) ⇒ ContractState
Returns a new instance of ContractState.
222 223 224 |
# File 'lib/universa/client.rb', line 222 def initialize(universa_contract_state) @source = universa_contract_state end |
Instance Method Details
#approved? ⇒ Boolean
same as #is_approved
261 262 263 |
# File 'lib/universa/client.rb', line 261 def approved? is_approved end |
#errors ⇒ Array(Hash)
get errors reported by the network
228 229 230 231 232 |
# File 'lib/universa/client.rb', line 228 def errors @_errors ||= @source.errors || [] rescue "failed to extract errors: #$!" end |
#errors? ⇒ Boolean
Returns true if the state contain errors.
235 236 237 |
# File 'lib/universa/client.rb', line 235 def errors? !errors.empty? end |
#inspect ⇒ Object
274 275 276 |
# File 'lib/universa/client.rb', line 274 def inspect to_s end |
#is_approved ⇒ Object
Returns true if the contract state was approved.
251 252 253 254 255 256 257 258 |
# File 'lib/universa/client.rb', line 251 def is_approved case state when 'APPROVED', 'LOCKED' true else false end end |
#is_pending ⇒ Object
Check that state us PENDING
. Pending state is neither approved nor rejected.
246 247 248 |
# File 'lib/universa/client.rb', line 246 def is_pending state.start_with?('PENDING') end |
#pending? ⇒ Boolean
same as #is_pending
266 267 268 |
# File 'lib/universa/client.rb', line 266 def pending? is_pending end |
#state ⇒ Object
Returns ItemState structure reported by the UMI.
240 241 242 |
# File 'lib/universa/client.rb', line 240 def state @source.state end |
#to_s ⇒ Object
270 271 272 |
# File 'lib/universa/client.rb', line 270 def to_s "<ContractState:#{state}>" end |