Class: Infinity
- Includes:
- Multiton
- Defined in:
- lib/mega/infinity.rb
Constant Summary
Constants included from Multiton
Multiton::MULTITON_ID_HOOK, Multiton::MULTITON_NEW_HOOK, Multiton::POOLS
Instance Attribute Summary collapse
-
#aleph ⇒ Object
readonly
Returns the value of attribute aleph.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
Class Method Summary collapse
Instance Method Summary collapse
- #-@ ⇒ Object
- #<=>(x) ⇒ Object
-
#initialize(aleph = 0, direction = 1) ⇒ Infinity
constructor
A new instance of Infinity.
- #times ⇒ Object
- #to_f ⇒ Object
- #to_s ⇒ Object
Methods included from Multiton
Methods included from Numeric::Multipliers
#atto, #centi, #deci, #deka, #exa, #exbi, #femto, #gibi, #giga, #hecto, #kibi, #kilo, #mebi, #mega, #micro, #milli, #nano, #pebi, #peta, #pico, #tebi, #tera
Methods included from Numeric::TimeInEnglish
#after, #before, #days, #fortnights, #hours, #minutes, #months, #seconds, #weeks, #years
Methods included from Numeric::BinaryMultipliers
#bit, #byte, #exabit, #exabyte, #exbi, #gibi, #gigabit, #gigabyte, #in_bits, #in_bytes, #in_exabits, #in_exabytes, #in_gigabits, #in_gigabytes, #in_kilobits, #in_kilobytes, #in_megabits, #in_megabytes, #in_petabits, #in_petabytes, #in_terabits, #in_terabytes, #kibi, #kilobit, #kilobyte, #mebi, #megabit, #megabyte, #pebi, #petabit, #petabyte, #strfbits, #strfbytes, #tebi, #terabit, #terabyte
Constructor Details
#initialize(aleph = 0, direction = 1) ⇒ Infinity
Returns a new instance of Infinity.
60 61 62 63 |
# File 'lib/mega/infinity.rb', line 60 def initialize(aleph=0, direction=1) @aleph = aleph @direction = direction end |
Instance Attribute Details
#aleph ⇒ Object (readonly)
Returns the value of attribute aleph.
58 59 60 |
# File 'lib/mega/infinity.rb', line 58 def aleph @aleph end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
58 59 60 |
# File 'lib/mega/infinity.rb', line 58 def direction @direction end |
Class Method Details
.[](a) ⇒ Object
54 55 56 |
# File 'lib/mega/infinity.rb', line 54 def self.[](a) self.new(a) end |
Instance Method Details
#-@ ⇒ Object
65 66 67 |
# File 'lib/mega/infinity.rb', line 65 def -@ self.class.instance(@aleph, @direction * -1) end |
#<=>(x) ⇒ Object
79 80 81 |
# File 'lib/mega/infinity.rb', line 79 def <=>(x) return (x.kind_of?(Infinity) ? (@aleph <=> x.aleph) : @direction) end |
#times ⇒ Object
73 74 75 76 77 |
# File 'lib/mega/infinity.rb', line 73 def times loop do yield end end |
#to_f ⇒ Object
69 70 71 |
# File 'lib/mega/infinity.rb', line 69 def to_f (1.0/0) * @direction end |
#to_s ⇒ Object
83 84 85 |
# File 'lib/mega/infinity.rb', line 83 def to_s %Q{#{ '-' if @direction == -1 }Infinity[#{@aleph}]} end |