Class: Odin::Types::OdinString

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) ⇒ OdinString

Returns a new instance of OdinString.



120
121
122
123
124
# File 'lib/odin/types/values.rb', line 120

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



118
119
120
# File 'lib/odin/types/values.rb', line 118

def value
  @value
end

Instance Method Details

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



128
129
130
# File 'lib/odin/types/values.rb', line 128

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

#hashObject



133
134
135
# File 'lib/odin/types/values.rb', line 133

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

#to_sObject



137
138
139
# File 'lib/odin/types/values.rb', line 137

def to_s
  "\"#{value}\""
end

#typeObject



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

def type; ValueType::STRING; end

#with_directives(dirs) ⇒ Object



145
146
147
# File 'lib/odin/types/values.rb', line 145

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

#with_modifiers(mods) ⇒ Object



141
142
143
# File 'lib/odin/types/values.rb', line 141

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