Class: MightyJSON::Type::Literal

Inherits:
Object
  • Object
show all
Defined in:
lib/mighty_json/type.rb

Instance Method Summary collapse

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_sObject



88
89
90
# File 'lib/mighty_json/type.rb', line 88

def to_s
  "literal(#{@value})"
end