Class: Odin::Types::OdinTimestamp

Inherits:
OdinValue
  • Object
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, raw: nil, **kwargs) ⇒ OdinTimestamp

Returns a new instance of OdinTimestamp.



329
330
331
332
333
334
# File 'lib/odin/types/values.rb', line 329

def initialize(value, raw: nil, **kwargs)
  super(**kwargs)
  @value = value
  @raw = (raw || value.iso8601).freeze
  freeze
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



327
328
329
# File 'lib/odin/types/values.rb', line 327

def raw
  @raw
end

#valueObject (readonly)

Returns the value of attribute value.



327
328
329
# File 'lib/odin/types/values.rb', line 327

def value
  @value
end

Instance Method Details

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



338
339
340
# File 'lib/odin/types/values.rb', line 338

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

#hashObject



343
344
345
# File 'lib/odin/types/values.rb', line 343

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

#to_sObject



347
348
349
# File 'lib/odin/types/values.rb', line 347

def to_s
  raw
end

#typeObject



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

def type; ValueType::TIMESTAMP; end

#with_directives(dirs) ⇒ Object



355
356
357
# File 'lib/odin/types/values.rb', line 355

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

#with_modifiers(mods) ⇒ Object



351
352
353
# File 'lib/odin/types/values.rb', line 351

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