Class: MercadoBitcoin::Trade
- Inherits:
-
BaseApiCall
- Object
- BaseApiCall
- MercadoBitcoin::Trade
- Defined in:
- lib/mercado_bitcoin/trade.rb
Defined Under Namespace
Classes: Array
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#tid ⇒ Object
Returns the value of attribute tid.
-
#to ⇒ Object
Returns the value of attribute to.
Attributes inherited from BaseApiCall
#coin, #parsed, #parser, #parser_error_class, #response, #rest_client
Instance Method Summary collapse
- #action ⇒ Object
- #from_to ⇒ Object
-
#initialize(coin, opts = {}) ⇒ Trade
constructor
A new instance of Trade.
- #model ⇒ Object
- #params ⇒ Object
Methods inherited from BaseApiCall
#base_url, #bitcoin?, #fetch, #get, #litecoin?, #parse, #url, #valid_coin?
Constructor Details
#initialize(coin, opts = {}) ⇒ Trade
Returns a new instance of Trade.
4 5 6 7 8 9 |
# File 'lib/mercado_bitcoin/trade.rb', line 4 def initialize(coin, opts = {}) @tid = opts[:tid] || opts[:since] @from = opts[:from].to_i.to_s if opts[:from].is_a?(Time) @to = opts[:to].to_i.to_s if opts[:to].is_a?(Time) super(coin, opts) end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
3 4 5 |
# File 'lib/mercado_bitcoin/trade.rb', line 3 def from @from end |
#tid ⇒ Object
Returns the value of attribute tid.
3 4 5 |
# File 'lib/mercado_bitcoin/trade.rb', line 3 def tid @tid end |
#to ⇒ Object
Returns the value of attribute to.
3 4 5 |
# File 'lib/mercado_bitcoin/trade.rb', line 3 def to @to end |
Instance Method Details
#action ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/mercado_bitcoin/trade.rb', line 20 def action return @action if @action @action = bitcoin? ? 'trades' : 'trades_litecoin' if(from_to) @action = File.join(@action, from_to).freeze end @action end |
#from_to ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/mercado_bitcoin/trade.rb', line 11 def from_to return @from_to if @from_to if @from && @to @from_to = "#{from}/#{to}" else @from_to = @from || @to end end |
#model ⇒ Object
34 35 36 |
# File 'lib/mercado_bitcoin/trade.rb', line 34 def model Array end |
#params ⇒ Object
29 30 31 32 |
# File 'lib/mercado_bitcoin/trade.rb', line 29 def params return {} unless tid { tid: tid } end |