Sha256: 516892e908048ae67c4e0e0d336b2714588c44a0df8cf77dfe84e71034d51bdf

Contents?: true

Size: 626 Bytes

Versions: 1

Compression:

Stored size: 626 Bytes

Contents

class Litecoin
  def initialize(value, unit = nil)
    @value = value
    @unit = unit
    @litoshi = convert_to_litoshi if @unit
  end

  def convert_to_litoshi
    case @unit
      when :ltc
        @value * 100000000
      when :lit
        @value
      else
        @value
    end
  end

  def to_ltc
    @litoshi / 100000000.0
  end
  alias :to_coin :to_ltc

  def to_litoshi
    @litoshi
  end

  def to_smallest
    to_litoshi
  end

  def smallest_to_coin
    @unit ||= :lit
    @litoshi = @value
    to_coin
  end

  def coin_to_smallest
    @unit ||= :ltc
    @litoshi = convert_to_litoshi
    to_smallest
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
currency_units-0.1.6 lib/currency_units/currencies/litecoin.rb