Class: StructuredReader::JSONReader::LiteralReader

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

Direct Known Subclasses

NullReader

Instance Method Summary collapse

Constructor Details

#initialize(value:, **_) ⇒ LiteralReader

Returns a new instance of LiteralReader.



212
213
214
# File 'lib/structured_reader.rb', line 212

def initialize(value:, **_)
  @value = value
end

Instance Method Details

#read(fragment, context) ⇒ Object



216
217
218
219
220
221
222
# File 'lib/structured_reader.rb', line 216

def read(fragment, context)
  if fragment == @value
    context.accept fragment
  else
    context.flunk(fragment, "expected #{@value.inspect}")
  end
end