Class: Odin::Types::OdinInteger
Instance Attribute Summary collapse
Attributes inherited from OdinValue
#directives, #modifiers
Instance Method Summary
collapse
Methods inherited from OdinValue
#array?, #binary?, #boolean?, #confidential?, #currency?, #date?, #deprecated?, #duration?, #integer?, #null?, #number?, #numeric?, #object?, #percent?, #reference?, #required?, #string?, #temporal?, #time?, #timestamp?, #verb?
Constructor Details
#initialize(value, raw: nil, **kwargs) ⇒ OdinInteger
Returns a new instance of OdinInteger.
187
188
189
190
191
192
|
# File 'lib/odin/types/values.rb', line 187
def initialize(value, raw: nil, **kwargs)
super(**kwargs)
@value = value.to_i
@raw = raw&.freeze
freeze
end
|
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
185
186
187
|
# File 'lib/odin/types/values.rb', line 185
def raw
@raw
end
|
#value ⇒ Object
Returns the value of attribute value.
185
186
187
|
# File 'lib/odin/types/values.rb', line 185
def value
@value
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
196
197
198
|
# File 'lib/odin/types/values.rb', line 196
def ==(other)
other.is_a?(OdinInteger) && value == other.value
end
|
#hash ⇒ Object
201
202
203
|
# File 'lib/odin/types/values.rb', line 201
def hash
[ValueType::INTEGER, value].hash
end
|
#to_s ⇒ Object
205
206
207
|
# File 'lib/odin/types/values.rb', line 205
def to_s
raw || value.to_s
end
|
#type ⇒ Object
194
|
# File 'lib/odin/types/values.rb', line 194
def type; ValueType::INTEGER; end
|
#with_directives(dirs) ⇒ Object
213
214
215
|
# File 'lib/odin/types/values.rb', line 213
def with_directives(dirs)
OdinInteger.new(value, raw: raw, modifiers: modifiers, directives: dirs)
end
|
#with_modifiers(mods) ⇒ Object
209
210
211
|
# File 'lib/odin/types/values.rb', line 209
def with_modifiers(mods)
OdinInteger.new(value, raw: raw, modifiers: mods, directives: directives)
end
|