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 +4 -4
- data/lib/etheruby/ether_multipliable.rb +38 -0
- data/lib/etheruby.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3820276ab8945379dd964e4bb2eb648acdac6f74
|
4
|
+
data.tar.gz: 9fb6b699587224619e6e73d8d53a4c708b4b731a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
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
|