Module: Ethlite::Utility
- Included in:
- ContractMethod
- Defined in:
- lib/ethlite/utility.rb
Instance Method Summary collapse
Instance Method Details
#from_hex(h) ⇒ Object
9 10 11 |
# File 'lib/ethlite/utility.rb', line 9 def from_hex( h ) h.nil? ? 0 : (h.kind_of?(String) ? h.to_i(16) : h) end |
#hex(num) ⇒ Object
5 6 7 |
# File 'lib/ethlite/utility.rb', line 5 def hex( num ) '0x' + num.to_s(16) end |
#remove_0x_head(s) ⇒ Object
13 14 15 16 |
# File 'lib/ethlite/utility.rb', line 13 def remove_0x_head( s ) return s if !s || s.length<2 s[0,2] == '0x' ? s[2..-1] : s end |
#wei_to_ether(wei) ⇒ Object
19 20 21 |
# File 'lib/ethlite/utility.rb', line 19 def wei_to_ether( wei ) 1.0 * wei / 10**18 end |