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.
92 93 94 |
# File 'lib/strong_json/type.rb', line 92 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
90 91 92 |
# File 'lib/strong_json/type.rb', line 90 def value @value end |
Instance Method Details
#coerce(value, path: []) ⇒ Object
100 101 102 103 |
# File 'lib/strong_json/type.rb', line 100 def coerce(value, path: []) raise Error.new(path: path, type: self, value: value) unless self.value == value value end |
#to_s ⇒ Object
96 97 98 |
# File 'lib/strong_json/type.rb', line 96 def to_s "literal(#{@value})" end |