Class: MercadoBitcoin::Trade

Inherits:
BaseApiCall show all
Defined in:
lib/mercado_bitcoin/trade.rb

Defined Under Namespace

Classes: Array

Instance Attribute Summary collapse

Attributes inherited from BaseApiCall

#coin, #parsed, #parser, #parser_error_class, #response, #rest_client

Instance Method Summary collapse

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

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/mercado_bitcoin/trade.rb', line 3

def from
  @from
end

#tidObject

Returns the value of attribute tid.



3
4
5
# File 'lib/mercado_bitcoin/trade.rb', line 3

def tid
  @tid
end

#toObject

Returns the value of attribute to.



3
4
5
# File 'lib/mercado_bitcoin/trade.rb', line 3

def to
  @to
end

Instance Method Details

#actionObject



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_toObject



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

#modelObject



34
35
36
# File 'lib/mercado_bitcoin/trade.rb', line 34

def model
  Array
end

#paramsObject



29
30
31
32
# File 'lib/mercado_bitcoin/trade.rb', line 29

def params
  return {} unless tid 
  { tid: tid }
end