Class: Opencdd::StructuredValues::SynonymTupleScanner

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

Overview

Internal scanner for the {(name,lang),(name,lang)} synonym wire form. Lives here so StructuredValues is the single home for all collection parsing. Parsed via StringScanner because the format can include quoted commas inside names.

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ SynonymTupleScanner

Returns a new instance of SynonymTupleScanner.



144
145
146
147
# File 'lib/opencdd/structured_values.rb', line 144

def initialize(source)
  require "strscan"
  @ss = StringScanner.new(source)
end

Instance Method Details

#scanObject



149
150
151
152
# File 'lib/opencdd/structured_values.rb', line 149

def scan
  @ss.skip(/\s*\{?\s*/)
  collect_tuples
end