Class: Numeric
Overview
Numeric extensions
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
77 78 79 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 77 def centi self*100 end |
#deci ⇒ Object
Return self * 10
72 73 74 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 72 def deci self*10 end |
#deka ⇒ Object
Return self / 10
67 68 69 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 67 def deka self/10 end |
#giga ⇒ Object
Return self / 10^9
47 48 49 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 47 def giga self/1000000000 end |
#hecto ⇒ Object
Return self / 10^2
62 63 64 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 62 def hecto self/100 end |
#if(flag) ⇒ Object
Return 0 if the given flag is any of: nil, false, 0, [], {}
Example
3.if(true) => 3
3.if(false) => 0
14 15 16 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 14 def if(flag) if [nil,false,0,[],{}].include?(flag) then 0 else self end end |
#kilo ⇒ Object
Return self / 10^3
57 58 59 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 57 def kilo self/1000 end |
#mega ⇒ Object
Return self / 10^6
52 53 54 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 52 def mega self/1000000 end |
#micro ⇒ Object
Return self * 10^6
87 88 89 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 87 def micro self*1000000 end |
#milli ⇒ Object
Return self * 10^3
82 83 84 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 82 def milli self*1000 end |
#nano ⇒ Object
Return self * 10^9
92 93 94 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 92 def nano self*1000000000 end |
#peta ⇒ Object
Return self / 10^15
37 38 39 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 37 def peta self/1000000000000000 end |
#tera ⇒ Object
Return self / 10^12
42 43 44 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 42 def tera self/1000000000000 end |
#unless(flag) ⇒ Object
Return self if flag is nil, false, 0, [], {}; otherwise return 0.
Example
3.unless(true) => 0
3.unless(false) => 3
25 26 27 |
# File 'lib/webget_ruby_ramp/numeric.rb', line 25 def unless(flag) if [nil,false,0,[],{}].include?(flag) then self else 0 end end |