Sha256: 700fa55102587d4fe61b371386d945d4e388774b92996478bbe0b7f87f902278
Contents?: true
Size: 789 Bytes
Versions: 1
Compression:
Stored size: 789 Bytes
Contents
class Ethereum def initialize(value, unit = nil) @value = value @unit = unit @wei = convert_to_wei if @unit end def convert_to_wei case @unit when :eth @value * 1000000000000000000 when :kwei @value * 1000000000000000 when :mwei @value * 1000000000000 when :szabo @value * 1000000 when :finney @value * 1000 when :wei @value else @value end end def to_wei @wei end def to_eth @wei / 1000000000000000000.0 end alias :to_coin :to_eth def to_smallest to_wei end def smallest_to_coin @unit ||= :wei @wei = @value to_coin end def coin_to_smallest @unit ||= :eth @wei = convert_to_wei 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/ethereum.rb |