Class: Numeric
Instance Method Summary collapse
-
#centi ⇒ Object
Return self * 10^2.
-
#deci ⇒ Object
Return self * 10.
-
#deka ⇒ Object
Return self / 10.
-
#giga ⇒ Object
Return self / 10^9.
-
#hecto ⇒ Object
Return self / 10^2.
-
#if(flag) ⇒ Object
Return 0 if the given flag is any of: nil, false, 0, [], {}.
-
#kilo ⇒ Object
Return self / 10^3.
-
#mega ⇒ Object
Return self / 10^6.
-
#micro ⇒ Object
Return self * 10^6.
-
#milli ⇒ Object
Return self * 10^3.
-
#nano ⇒ Object
Return self * 10^9.
-
#peta ⇒ Object
Return self / 10^15.
-
#tera ⇒ Object
Return self / 10^12.
-
#unless(flag) ⇒ Object
Return self if flag is nil, false, 0, [], {}; otherwise return 0.
Instance Method Details
#centi ⇒ Object
Return self * 10^2
74 75 76 |
# File 'lib/webget_ramp/numeric.rb', line 74 def centi self*100 end |
#deci ⇒ Object
Return self * 10
69 70 71 |
# File 'lib/webget_ramp/numeric.rb', line 69 def deci self*10 end |
#deka ⇒ Object
Return self / 10
64 65 66 |
# File 'lib/webget_ramp/numeric.rb', line 64 def deka self/10 end |
#giga ⇒ Object
Return self / 10^9
44 45 46 |
# File 'lib/webget_ramp/numeric.rb', line 44 def giga self/1000000000 end |
#hecto ⇒ Object
Return self / 10^2
59 60 61 |
# File 'lib/webget_ramp/numeric.rb', line 59 def hecto self/100 end |
#if(flag) ⇒ Object
Return 0 if the given flag is any of: nil, false, 0, [], {}
This is useful for multiplying a number if and only if a flag is set.
Example
sum = x.if(foo) + y.if()
11 12 13 |
# File 'lib/webget_ramp/numeric.rb', line 11 def if(flag) (flag==nil or flag==false or flag==0 or flag==[] or flag=={}) ? 0 : self end |
#kilo ⇒ Object
Return self / 10^3
54 55 56 |
# File 'lib/webget_ramp/numeric.rb', line 54 def kilo self/1000 end |
#mega ⇒ Object
Return self / 10^6
49 50 51 |
# File 'lib/webget_ramp/numeric.rb', line 49 def mega self/100000 end |
#micro ⇒ Object
Return self * 10^6
84 85 86 |
# File 'lib/webget_ramp/numeric.rb', line 84 def micro self*1000000 end |
#milli ⇒ Object
Return self * 10^3
79 80 81 |
# File 'lib/webget_ramp/numeric.rb', line 79 def milli self*1000 end |
#nano ⇒ Object
Return self * 10^9
89 90 91 |
# File 'lib/webget_ramp/numeric.rb', line 89 def nano self*1000000000 end |
#peta ⇒ Object
Return self / 10^15
34 35 36 |
# File 'lib/webget_ramp/numeric.rb', line 34 def peta self/1000000000000000 end |
#tera ⇒ Object
Return self / 10^12
39 40 41 |
# File 'lib/webget_ramp/numeric.rb', line 39 def tera self/1000000000000 end |
#unless(flag) ⇒ Object
Return self if flag is nil, false, 0, [], {}; otherwise return 0.
This is useful for multiplying a number if and only if a flag is unset.
Example
sum = w.unless(foo) +y.unless()
23 24 25 |
# File 'lib/webget_ramp/numeric.rb', line 23 def unless(flag) (flag==nil or flag==false or flag==0 or flag==[] or flag=={}) ? self : 0 end |