Class: Coinbase::Validator
- Inherits:
-
Object
- Object
- Coinbase::Validator
- Defined in:
- lib/coinbase/validator.rb
Overview
A representation of a staking validator.
Class Method Summary collapse
-
.fetch(network, asset_id, validator_id) ⇒ Coinbase::Validator
Returns a Validator for the provided network, asset, and validator.
-
.list(network, asset_id, status: nil) ⇒ Enumerable<Coinbase::Validator>
Returns a list of Validators for the provided network and asset.
Instance Method Summary collapse
-
#initialize(model) ⇒ Validator
constructor
Returns a new Validator object.
-
#inspect ⇒ String
Same as to_s.
-
#status ⇒ Symbol
Returns the status of the Validator.
-
#to_s ⇒ String
Returns a string representation of the Validator.
-
#validator_id ⇒ String
Returns the public identifiable id of the Validator.
Constructor Details
#initialize(model) ⇒ Validator
Returns a new Validator object.
8 9 10 |
# File 'lib/coinbase/validator.rb', line 8 def initialize(model) @model = model end |
Class Method Details
.fetch(network, asset_id, validator_id) ⇒ Coinbase::Validator
Returns a Validator for the provided network, asset, and validator.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/coinbase/validator.rb', line 32 def self.fetch(network, asset_id, validator_id) network = Coinbase::Network.from_id(network) validator = Coinbase.call_api do validators_api.get_validator( network.normalized_id, asset_id, validator_id ) end new(validator) end |
.list(network, asset_id, status: nil) ⇒ Enumerable<Coinbase::Validator>
Returns a list of Validators for the provided network and asset.
17 18 19 20 21 22 23 24 25 |
# File 'lib/coinbase/validator.rb', line 17 def self.list(network, asset_id, status: nil) network = Coinbase::Network.from_id(network) Coinbase::Pagination.enumerate(lambda { |page| list_page(network, asset_id, status, page) }) do |validator| new(validator) end end |
Instance Method Details
#inspect ⇒ String
Same as to_s.
65 66 67 |
# File 'lib/coinbase/validator.rb', line 65 def inspect to_s end |
#status ⇒ Symbol
Returns the status of the Validator.
53 54 55 |
# File 'lib/coinbase/validator.rb', line 53 def status @model.status end |
#to_s ⇒ String
Returns a string representation of the Validator.
59 60 61 |
# File 'lib/coinbase/validator.rb', line 59 def to_s "Coinbase::Validator{id: '#{validator_id}' status: '#{status}'}" end |
#validator_id ⇒ String
Returns the public identifiable id of the Validator.
47 48 49 |
# File 'lib/coinbase/validator.rb', line 47 def validator_id @model.validator_id end |