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 |
# 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 stake_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.
62 63 64 |
# File 'lib/coinbase/validator.rb', line 62 def inspect to_s end |
#status ⇒ Symbol
Returns the status of the Validator.
50 51 52 |
# File 'lib/coinbase/validator.rb', line 50 def status @model.status end |
#to_s ⇒ String
Returns a string representation of the Validator.
56 57 58 |
# File 'lib/coinbase/validator.rb', line 56 def to_s Coinbase.pretty_print_object(self, validator_id: validator_id, status: status) end |
#validator_id ⇒ String
Returns the public identifiable id of the Validator.
44 45 46 |
# File 'lib/coinbase/validator.rb', line 44 def validator_id @model.validator_id end |