Class: Literal::IntegerValue

Inherits:
Value
  • Object
show all
Defined in:
lib/literal/integer_value.rb

Instance Attribute Summary

Attributes inherited from Value

#value

Instance Method Summary collapse

Methods inherited from Value

#===, #inspect

Constructor Details

#initialize(value) ⇒ IntegerValue

Returns a new instance of IntegerValue.



4
5
6
7
8
9
10
11
12
# File 'lib/literal/integer_value.rb', line 4

def initialize(value)
	unless Integer === value
		raise Literal::TypeError.expected(value, to_be_a: Integer)
	end

	@value = value

	freeze
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/literal/integer_value.rb', line 16

def ==(other)
	case other
	when Integer
		@value == other
	when Literal::IntegerValue
		@value == other.value
	else
		false
	end
end