Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/radix/operator.rb,
lib/radix/rational.rb
Overview
Adds the b(base) method to this ruby class for quickly creating Radix instances.
Instance Method Summary collapse
-
#b(base) ⇒ Radix::Integer, Radix::Float
Takes array and makes it into a Radix::Integer or Radix::Float as given base.
-
#br(base = nil) ⇒ Radix::Rational
Adds convenience method for creating a Radix::Rational.
Instance Method Details
#b(base) ⇒ Radix::Integer, Radix::Float
Takes array and makes it into a Radix::Integer or Radix::Float as given base. Float is determined by a “.” character in array instance.
86 87 88 89 90 91 92 |
# File 'lib/radix/operator.rb', line 86 def b(base) if index('.') Radix::Float.new(self, base) else Radix::Integer.new(self, base) end end |
#br(base = nil) ⇒ Radix::Rational
TODO:
Keep #br? Or find another way?
Adds convenience method for creating a Radix::Rational.
289 290 291 292 293 |
# File 'lib/radix/rational.rb', line 289 def br(base=nil) args = dup args << base if base Radix::Rational.new(*args) end |