Class: BudaApi::Models::BaseModel
- Inherits:
-
Object
- Object
- BudaApi::Models::BaseModel
- Defined in:
- lib/buda_api/models.rb
Overview
Base model class with common functionality
Direct Known Subclasses
Amount, AveragePrice, Balance, Candlestick, Deposit, Market, Order, OrderBook, OrderBookEntry, OrderPages, PaginationMeta, Quotation, Ticker, Trade, Trades, Withdrawal
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ BaseModel
constructor
A new instance of BaseModel.
-
#raw ⇒ Object
Access to raw API response data.
-
#to_h ⇒ Object
Convert to hash.
-
#to_json(*args) ⇒ Object
Convert to JSON.
Constructor Details
#initialize(data = {}) ⇒ BaseModel
11 12 13 14 |
# File 'lib/buda_api/models.rb', line 11 def initialize(data = {}) @data = data.is_a?(Hash) ? data : {} @raw_data = @data.dup end |
Instance Method Details
#raw ⇒ Object
Access to raw API response data
17 18 19 |
# File 'lib/buda_api/models.rb', line 17 def raw @raw_data end |
#to_h ⇒ Object
Convert to hash
22 23 24 |
# File 'lib/buda_api/models.rb', line 22 def to_h @data end |
#to_json(*args) ⇒ Object
Convert to JSON
27 28 29 |
# File 'lib/buda_api/models.rb', line 27 def to_json(*args) @data.to_json(*args) end |