Class: Bitstamper::Models::TradingPair

Inherits:
Base
  • Object
show all
Defined in:
lib/bitstamper/models/trading_pair.rb

Constant Summary collapse

MAPPING =
{
  "name"              =>   :string,
  "url_symbol"        =>   :string,
  "description"       =>   :string,
  "base_decimals"     =>   :integer,
  "counter_decimals"  =>   :integer,
  "minimum_order"     =>   :string,
  "trading"           =>   :string,
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes

Constructor Details

#initialize(hash) ⇒ TradingPair

Returns a new instance of TradingPair.



17
18
19
20
21
22
23
# File 'lib/bitstamper/models/trading_pair.rb', line 17

def initialize(hash)
  hash.each do |key, value|
    type            =     ::Bitstamper::Models::TradingPair::MAPPING.fetch(key, nil)
    value           =     value && type ? ::Bitstamper::Utilities::convert_value(value, type) : value
    self.send("#{key}=", value) if self.respond_to?(key)
  end
end

Instance Attribute Details

#base_decimalsObject

Returns the value of attribute base_decimals.



5
6
7
# File 'lib/bitstamper/models/trading_pair.rb', line 5

def base_decimals
  @base_decimals
end

#counter_decimalsObject

Returns the value of attribute counter_decimals.



5
6
7
# File 'lib/bitstamper/models/trading_pair.rb', line 5

def counter_decimals
  @counter_decimals
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/bitstamper/models/trading_pair.rb', line 4

def description
  @description
end

#minimum_orderObject

Returns the value of attribute minimum_order.



5
6
7
# File 'lib/bitstamper/models/trading_pair.rb', line 5

def minimum_order
  @minimum_order
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/bitstamper/models/trading_pair.rb', line 4

def name
  @name
end

#tradingObject

Returns the value of attribute trading.



5
6
7
# File 'lib/bitstamper/models/trading_pair.rb', line 5

def trading
  @trading
end

#url_symbolObject

Returns the value of attribute url_symbol.



4
5
6
# File 'lib/bitstamper/models/trading_pair.rb', line 4

def url_symbol
  @url_symbol
end

Class Method Details

.parse(data) ⇒ Object



29
30
31
# File 'lib/bitstamper/models/trading_pair.rb', line 29

def self.parse(data)
  data&.collect { |item| ::Bitstamper::Models::TradingPair.new(item) }
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/bitstamper/models/trading_pair.rb', line 25

def enabled?
  self.trading.downcase.strip.eql?("enabled")
end