Class: MightyJSON::Type::Literal
- Inherits:
-
Object
- Object
- MightyJSON::Type::Literal
- Defined in:
- lib/mighty_json/type.rb
Instance Method Summary collapse
- #compile(var:, path:) ⇒ Object
-
#initialize(value) ⇒ Literal
constructor
A new instance of Literal.
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ Literal
Returns a new instance of Literal.
84 85 86 |
# File 'lib/mighty_json/type.rb', line 84 def initialize(value) @value = value end |
Instance Method Details
#compile(var:, path:) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/mighty_json/type.rb', line 92 def compile(var:, path:) v = var.cur " raise Error.new(path: \#{path.inspect}, type: \#{self.to_s.inspect}, value: \#{v}) unless \#{@value.inspect} == \#{v}\n \#{v}\n END\nend\n" |
#to_s ⇒ Object
88 89 90 |
# File 'lib/mighty_json/type.rb', line 88 def to_s "literal(#{@value})" end |