Class: TSJSON::Literal
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value) ⇒ Literal
constructor
A new instance of Literal.
- #validate(other) ⇒ Object
Methods inherited from Base
#compile, #index, #property, #valid?
Constructor Details
#initialize(value) ⇒ Literal
Returns a new instance of Literal.
5 6 7 |
# File 'lib/types/literal.rb', line 5 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/types/literal.rb', line 3 def value @value end |
Instance Method Details
#==(other) ⇒ Object
9 10 11 12 13 |
# File 'lib/types/literal.rb', line 9 def ==(other) return value == other unless other.is_a?(self.class) value == other.value end |
#validate(other) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/types/literal.rb', line 15 def validate(other) unless @value == other raise LiteralValidationError.new( expected_value: @value, received_value: other ) end true end |