Class: Btce::Trade

Inherits:
Object
  • Object
show all
Defined in:
lib/btce/trade.rb

Constant Summary collapse

JSON_METHODS =
%w(date price amount tid price_currency item trade_type)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#jsonObject

Returns the value of attribute json


39
40
41
# File 'lib/btce/trade.rb', line 39

def json
  @json
end

Class Method Details

.new_from_json(json) ⇒ Object


46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/btce/trade.rb', line 46

def new_from_json(json)
  result = Trade.new
  result.json = json
  if json.is_a? Hash
    JSON_METHODS.each do |method|
      instance_eval %{
        result.#{method} = json["#{method}"]
      }
    end
  end
  result
end