Class: Odin::Types::OdinPercent
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) ⇒ OdinPercent
Returns a new instance of OdinPercent.
261
262
263
264
265
266
|
# File 'lib/odin/types/values.rb', line 261
def initialize(value, raw: nil, **kwargs)
super(**kwargs)
@value = value.to_f
@raw = raw&.freeze
freeze
end
|
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
259
260
261
|
# File 'lib/odin/types/values.rb', line 259
def raw
@raw
end
|
#value ⇒ Object
Returns the value of attribute value.
259
260
261
|
# File 'lib/odin/types/values.rb', line 259
def value
@value
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
270
271
272
|
# File 'lib/odin/types/values.rb', line 270
def ==(other)
other.is_a?(OdinPercent) && value == other.value
end
|
#hash ⇒ Object
275
276
277
|
# File 'lib/odin/types/values.rb', line 275
def hash
[ValueType::PERCENT, value].hash
end
|
#to_s ⇒ Object
279
280
281
|
# File 'lib/odin/types/values.rb', line 279
def to_s
raw || value.to_s
end
|
#type ⇒ Object
268
|
# File 'lib/odin/types/values.rb', line 268
def type; ValueType::PERCENT; end
|
#with_directives(dirs) ⇒ Object
287
288
289
|
# File 'lib/odin/types/values.rb', line 287
def with_directives(dirs)
OdinPercent.new(value, raw: raw, modifiers: modifiers, directives: dirs)
end
|
#with_modifiers(mods) ⇒ Object
283
284
285
|
# File 'lib/odin/types/values.rb', line 283
def with_modifiers(mods)
OdinPercent.new(value, raw: raw, modifiers: mods, directives: directives)
end
|