Class: StrongJSON::Type::Literal
- Inherits:
-
Object
- Object
- StrongJSON::Type::Literal
- Includes:
- Match
- Defined in:
- lib/strong_json/type.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #coerce(value, path: []) ⇒ Object
-
#initialize(value) ⇒ Literal
constructor
A new instance of Literal.
- #to_s ⇒ Object
Methods included from Match
Constructor Details
#initialize(value) ⇒ Literal
Returns a new instance of Literal.
94 95 96 |
# File 'lib/strong_json/type.rb', line 94 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
92 93 94 |
# File 'lib/strong_json/type.rb', line 92 def value @value end |
Instance Method Details
#coerce(value, path: []) ⇒ Object
102 103 104 105 |
# File 'lib/strong_json/type.rb', line 102 def coerce(value, path: []) raise Error.new(path: path, type: self, value: value) unless (_ = self.value) == value value end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/strong_json/type.rb', line 98 def to_s "literal(#{@value})" end |