Class: Odin::Types::OdinDate

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, raw: nil, **kwargs) ⇒ OdinDate

Returns a new instance of OdinDate.



295
296
297
298
299
300
# File 'lib/odin/types/values.rb', line 295

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

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



293
294
295
# File 'lib/odin/types/values.rb', line 293

def raw
  @raw
end

#valueObject (readonly)

Returns the value of attribute value.



293
294
295
# File 'lib/odin/types/values.rb', line 293

def value
  @value
end

Instance Method Details

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



304
305
306
# File 'lib/odin/types/values.rb', line 304

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

#hashObject



309
310
311
# File 'lib/odin/types/values.rb', line 309

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

#to_sObject



313
314
315
# File 'lib/odin/types/values.rb', line 313

def to_s
  raw
end

#typeObject



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

def type; ValueType::DATE; end

#with_directives(dirs) ⇒ Object



321
322
323
# File 'lib/odin/types/values.rb', line 321

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

#with_modifiers(mods) ⇒ Object



317
318
319
# File 'lib/odin/types/values.rb', line 317

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