class Koin

Constants

VERSION

Attributes

currency[RW]

Public Class Methods

new(value, currency = nil) click to toggle source
Calls superclass method
# File lib/koin.rb, line 7
def initialize(value, currency = nil)
  @currency = currency&.upcase

  if value.is_a?(Float)
    super(value, 16)
  elsif value.is_a?(Koin)
    @currency ||= value.currency
    super(value)
  elsif value.is_a?(String) || value.is_a?(Integer) || value.is_a?(BigDecimal) || value.is_a?(Numeric)
    super(value)
  else
    raise NotImplementedError("Invalid `value` type: #{value.class}.")
  end
end

Public Instance Methods

inspect(*args)
Alias for: to_s
to_s(*args) click to toggle source
super

end Koin.new(1, 'eth') == Koin.new(1) Koin.new(1, 'eth') == Koin.new(1, 'eth') Koin.new(1, 'btc') == Koin.new(1, 'eth') Koin.new(1) == Koin.new(1) Koin.new(1) == Koin.new(2)

# File lib/koin.rb, line 35
def to_s(*args)
  "#{super} #{currency}".strip
end
Also aliased as: inspect