Class: Odin::Types::OdinString
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
#value ⇒ Object
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
|
#hash ⇒ Object
133
134
135
|
# File 'lib/odin/types/values.rb', line 133
def hash
[ValueType::STRING, value].hash
end
|
#to_s ⇒ Object
137
138
139
|
# File 'lib/odin/types/values.rb', line 137
def to_s
"\"#{value}\""
end
|
#type ⇒ Object
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
|