Class: JsonCompleter::Scanners::KeywordToken

Inherits:
Struct
  • Object
show all
Defined in:
lib/json_completer/scanners.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target:, slot: nil, matched: 0) ⇒ KeywordToken

Returns a new instance of KeywordToken.



294
295
296
# File 'lib/json_completer/scanners.rb', line 294

def initialize(target:, slot: nil, matched: 0)
  super
end

Instance Attribute Details

#matchedObject

Returns the value of attribute matched

Returns:

  • (Object)

    the current value of matched



293
294
295
# File 'lib/json_completer/scanners.rb', line 293

def matched
  @matched
end

#slotObject

Returns the value of attribute slot

Returns:

  • (Object)

    the current value of slot



293
294
295
# File 'lib/json_completer/scanners.rb', line 293

def slot
  @slot
end

#targetObject

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



293
294
295
# File 'lib/json_completer/scanners.rb', line 293

def target
  @target
end

Instance Method Details

#append_byte(byte) ⇒ Object



298
299
300
301
302
303
304
# File 'lib/json_completer/scanners.rb', line 298

def append_byte(byte)
  return false if matched >= target.length
  return false unless (byte | 0x20) == target.getbyte(matched)

  self.matched += 1
  true
end

#parsed_valueObject



306
307
308
309
310
311
312
313
# File 'lib/json_completer/scanners.rb', line 306

def parsed_value
  case target
  when 'true'
    true
  when 'false'
    false
  end
end