Class: Code::Object::Integer
- Inherits:
-
Code::Object
- Object
- Code::Object
- Code::Object::Integer
- Defined in:
- lib/code/object/integer.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(whole, exponent: nil) ⇒ Integer
constructor
A new instance of Integer.
- #inspect ⇒ Object
- #to_s ⇒ Object
Methods inherited from Code::Object
Constructor Details
#initialize(whole, exponent: nil) ⇒ Integer
Returns a new instance of Integer.
6 7 8 9 |
# File 'lib/code/object/integer.rb', line 6 def initialize(whole, exponent: nil) @raw = whole.to_i @raw = @raw * 10**exponent.raw if exponent end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/code/object/integer.rb', line 4 def raw @raw end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
19 20 21 |
# File 'lib/code/object/integer.rb', line 19 def ==(other) raw == other.raw end |
#hash ⇒ Object
24 25 26 |
# File 'lib/code/object/integer.rb', line 24 def hash [self.class, raw].hash end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/code/object/integer.rb', line 15 def inspect to_s end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/code/object/integer.rb', line 11 def to_s raw.to_s end |