Class: Cryptopay::Rate
- Inherits:
-
Object
- Object
- Cryptopay::Rate
- Defined in:
- lib/cryptopay/models/rate.rb
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Rate
Builds the object from hash.
Instance Method Summary collapse
-
#buy_rate ⇒ Object
Buy rate.
-
#initialize(attributes = {}) ⇒ Rate
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#sell_rate ⇒ Object
Buy rate.
-
#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 = {}) ⇒ Rate
Initializes the object
32 33 34 |
# File 'lib/cryptopay/models/rate.rb', line 32 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Rate
Builds the object from hash
25 26 27 28 |
# File 'lib/cryptopay/models/rate.rb', line 25 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#buy_rate ⇒ Object
Buy rate
37 38 39 |
# File 'lib/cryptopay/models/rate.rb', line 37 def buy_rate @attributes[:buy_rate] end |
#inspect ⇒ Object
70 71 72 |
# File 'lib/cryptopay/models/rate.rb', line 70 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?
48 49 50 51 52 53 54 55 56 |
# File 'lib/cryptopay/models/rate.rb', line 48 def invalid_properties properties = [] properties.push('invalid value for "buy_rate", buy_rate cannot be nil.') if buy_rate.nil? properties.push('invalid value for "sell_rate", sell_rate cannot be nil.') if sell_rate.nil? properties end |
#sell_rate ⇒ Object
Buy rate
42 43 44 |
# File 'lib/cryptopay/models/rate.rb', line 42 def sell_rate @attributes[:sell_rate] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
66 67 68 |
# File 'lib/cryptopay/models/rate.rb', line 66 def to_hash ENCODER.to_hash(@attributes) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
60 61 62 |
# File 'lib/cryptopay/models/rate.rb', line 60 def valid? invalid_properties.empty? end |