Class: Odin::Types::OdinTime

Inherits:
OdinValue show all
Defined in:
lib/odin/types/values.rb

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, **kwargs) ⇒ OdinTime

Returns a new instance of OdinTime.



363
364
365
366
367
# File 'lib/odin/types/values.rb', line 363

def initialize(value, **kwargs)
  super(**kwargs)
  @value = -value.to_s
  freeze
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



361
362
363
# File 'lib/odin/types/values.rb', line 361

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



371
372
373
# File 'lib/odin/types/values.rb', line 371

def ==(other)
  other.is_a?(OdinTime) && value == other.value
end

#hashObject



376
377
378
# File 'lib/odin/types/values.rb', line 376

def hash
  [ValueType::TIME, value].hash
end

#to_sObject



380
381
382
# File 'lib/odin/types/values.rb', line 380

def to_s
  value
end

#typeObject



369
# File 'lib/odin/types/values.rb', line 369

def type; ValueType::TIME; end

#with_directives(dirs) ⇒ Object



388
389
390
# File 'lib/odin/types/values.rb', line 388

def with_directives(dirs)
  OdinTime.new(value, modifiers: modifiers, directives: dirs)
end

#with_modifiers(mods) ⇒ Object



384
385
386
# File 'lib/odin/types/values.rb', line 384

def with_modifiers(mods)
  OdinTime.new(value, modifiers: mods, directives: directives)
end