Class: Cryptopay::Coin
- Inherits:
-
Object
- Object
- Cryptopay::Coin
- Defined in:
- lib/cryptopay/models/coin.rb
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Coin
Builds the object from hash.
Instance Method Summary collapse
- #currency ⇒ Object
-
#initialize(attributes = {}) ⇒ Coin
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
- #logo_url ⇒ Object
- #name ⇒ Object
- #networks ⇒ Object
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Coin
Initializes the object
36 37 38 |
# File 'lib/cryptopay/models/coin.rb', line 36 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Coin
Builds the object from hash
29 30 31 32 |
# File 'lib/cryptopay/models/coin.rb', line 29 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#currency ⇒ Object
40 41 42 |
# File 'lib/cryptopay/models/coin.rb', line 40 def currency @attributes[:currency] end |
#inspect ⇒ Object
90 91 92 |
# File 'lib/cryptopay/models/coin.rb', line 90 def inspect "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash) end |
#invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cryptopay/models/coin.rb', line 58 def invalid_properties properties = [] properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil? properties.push('invalid value for "name", name cannot be nil.') if name.nil? properties.push('invalid value for "logo_url", logo_url cannot be nil.') if logo_url.nil? properties.push('invalid value for "networks", networks cannot be nil.') if networks.nil? networks&.each_with_index do |item, index| item.invalid_properties.each do |prop| properties.push("invalid value for \"networks.#{index}\": #{prop}") end end properties end |
#logo_url ⇒ Object
48 49 50 |
# File 'lib/cryptopay/models/coin.rb', line 48 def logo_url @attributes[:logo_url] end |
#name ⇒ Object
44 45 46 |
# File 'lib/cryptopay/models/coin.rb', line 44 def name @attributes[:name] end |
#networks ⇒ Object
52 53 54 |
# File 'lib/cryptopay/models/coin.rb', line 52 def networks @attributes[:networks] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
86 87 88 |
# File 'lib/cryptopay/models/coin.rb', line 86 def to_hash ENCODER.to_hash(@attributes) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
80 81 82 |
# File 'lib/cryptopay/models/coin.rb', line 80 def valid? invalid_properties.empty? end |