Class: Code::Object::Integer

Inherits:
Code::Object show all
Defined in:
lib/code/object/integer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Code::Object

#fetch

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

#rawObject (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

#hashObject



24
25
26
# File 'lib/code/object/integer.rb', line 24

def hash
  [self.class, raw].hash
end

#inspectObject



15
16
17
# File 'lib/code/object/integer.rb', line 15

def inspect
  to_s
end

#to_sObject



11
12
13
# File 'lib/code/object/integer.rb', line 11

def to_s
  raw.to_s
end