class Trader::CurrencyPair

Attributes

base[R]
quote[R]

Public Class Methods

for_code(_pair, _quote=nil) click to toggle source
# File lib/trade-o-matic/structs/currency_pair.rb, line 9
def self.for_code(_pair, _quote=nil)
  return _pair if _pair.is_a? self
  self.new _pair, _quote
end
new(_base, _quote) click to toggle source
# File lib/trade-o-matic/structs/currency_pair.rb, line 14
def initialize(_base, _quote)
  @base = Currency.for_code _base
  @quote = Currency.for_code _quote
end
parse(_string) click to toggle source
# File lib/trade-o-matic/structs/currency_pair.rb, line 5
def self.parse(_string)
  new *(_string.split '/')
end

Public Instance Methods

==(_other) click to toggle source
# File lib/trade-o-matic/structs/currency_pair.rb, line 19
def ==(_other)
  return false unless _other.is_a? CurrencyPair
  base == _other.base and quote == _other.quote
end
compatible_with?(_pair, _quote=nil) click to toggle source
# File lib/trade-o-matic/structs/currency_pair.rb, line 29
def compatible_with?(_pair, _quote=nil)
  _pair = for_code _pair, _quote
  base.compatible_with?(_pair.base) and quote.compatible_with?(_pair.quote)
end
convertible_to?(_pair, _quote=nil) click to toggle source
# File lib/trade-o-matic/structs/currency_pair.rb, line 24
def convertible_to?(_pair, _quote=nil)
  _pair = for_code _pair, _quote
  base.convertible_to?(_pair.base) and quote.convertible_to?(_pair.quote)
end
to_s() click to toggle source
# File lib/trade-o-matic/structs/currency_pair.rb, line 34
def to_s
  "#{base}/#{quote}"
end

Private Instance Methods

for_code(_pair, _quote=nil) click to toggle source
# File lib/trade-o-matic/structs/currency_pair.rb, line 40
def for_code(_pair, _quote=nil)
  self.class.for_code _pair, _quote
end