etheruby 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af7e8f1646fb49e6c917b515320bc07b9f9413a8
4
- data.tar.gz: 799fc6b8aefea6413ae6d664db3620788ea625ac
3
+ metadata.gz: 3820276ab8945379dd964e4bb2eb648acdac6f74
4
+ data.tar.gz: 9fb6b699587224619e6e73d8d53a4c708b4b731a
5
5
  SHA512:
6
- metadata.gz: 2c997b1010710a80a3e28f28511cb4de3518cbca6d9ee1a186f484b89021dca5078029d11903deacff7280768ddcd0c3eca10307e04b66507726b8fff54b1a88
7
- data.tar.gz: 158181e1ed668c808d58ab4cbc82bd8e86c4e6ca001e0a39754f571153e6a928e487194855339f1bbacd87241e124bc3f8d7dfb40fae6a7154388904d1a423bc
6
+ metadata.gz: a3a66b0a3f071199be7f96e40eea49be3e526616b489db56227c685fa039297905876b75b11e4db695ce2c116bed293c2c49a834ede7bda30e83d4bd930d3a46
7
+ data.tar.gz: 92c55c8446de0ff92746e0b6a575bb7e2afb452dea3c0f67654d4767efc82be8afe5cdd3933796b6540a4b086c30b1e437a09092e0cf7c1f8a4db32d6f8c988c
@@ -0,0 +1,38 @@
1
+ ETHER_MULTIPLES = {
2
+ kwei: (10**3),
3
+ mwei: (10**6),
4
+ gwei: (10**9),
5
+ szabo: (10**12),
6
+ finney: (10**15),
7
+ ether: (10**18),
8
+ kether: (10**21),
9
+ mether: (10**24),
10
+ gether: (10**27),
11
+ tether: (10**30)
12
+ }
13
+
14
+ module EtherMultipliable
15
+ def method_missing(sym)
16
+ if ETHER_MULTIPLES.has_key? sym
17
+ return self * ETHER_MULTIPLES[sym]
18
+ else
19
+ raise NoMethodError.new
20
+ end
21
+ end
22
+
23
+ def from_wei(sym)
24
+ return self / ETHER_MULTIPLES[sym].to_f
25
+ end
26
+ end
27
+
28
+ class Fixnum
29
+ include EtherMultipliable
30
+ end
31
+
32
+ class Bignum
33
+ include EtherMultipliable
34
+ end
35
+
36
+ class Float
37
+ include EtherMultipliable
38
+ end
data/lib/etheruby.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'logger'
2
2
  require_relative 'etheruby/client'
3
3
  require_relative 'etheruby/contract'
4
+ require_relative 'etheruby/ether_multipliable'
4
5
  require_relative 'etheruby/railtie' if defined?(Rails)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etheruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy SEBAN
@@ -101,6 +101,7 @@ files:
101
101
  - lib/etheruby/encoders/function.rb
102
102
  - lib/etheruby/encoders/int.rb
103
103
  - lib/etheruby/encoders/string.rb
104
+ - lib/etheruby/ether_multipliable.rb
104
105
  - lib/etheruby/railtie.rb
105
106
  - lib/etheruby/response_parser.rb
106
107
  - lib/etheruby/treat_variable.rb