push
travis-ci
20 of 20 new or added lines in 3 files covered. (100.0%)
908 of 910 relevant lines covered (99.78%)
45.83 hits per line
|
module MoreCoreExtensions |
4 all except jruby-head ✔ |
|
module IEC60027_2 |
4 all except jruby-head ✔ |
3 |
# Support converting strings with an IEC60027-2 suffix to an integer
|
|
4 |
# http://physics.nist.gov/cuu/Units/binary.html
|
|
5 |
# Example: "1 Ki".iec_60027_2_to_i => 1024
|
|
6 |
|
|
|
IEC_60027_2_SIZE_SUFFIXES = %w(Ki Mi Gi Ti Pi Ei Zi Yi).freeze |
4 all except jruby-head ✔ |
|
def iec_60027_2_to_i |
4 all except jruby-head ✔ |
|
suffix_index = IEC_60027_2_SIZE_SUFFIXES.index(self[-2..-1]) |
32 all except jruby-head ✔ |
|
if suffix_index.nil?
|
32 all except jruby-head ✔ |
|
Integer(self)
|
× |
12 |
else
|
|
|
Integer(self[0..-3]) * (2**10)**(suffix_index + 1) |
32 all except jruby-head ✔ |
14 |
end
|
|
15 |
end
|
|
16 |
end
|
|
17 |
end
|
|
18 |
|
|
|
String.send(:prepend, MoreCoreExtensions::IEC60027_2) |
4 all except jruby-head ✔ |