Class: ReVIEW::Book::ColumnIndex

Inherits:
Index show all
Defined in:
lib/review/book/index.rb

Constant Summary collapse

COLUMN_PATTERN =
/\A(=+)\[column\](?:\{(.+?)\})?(.*)/

Class Method Summary collapse

Methods inherited from Index

#[], #add_item, #each, #initialize, #item_type, #key?, #number

Constructor Details

This class inherits a constructor from ReVIEW::Book::Index

Class Method Details

.parse(src, *_args) ⇒ Object



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/review/book/index.rb', line 348

def self.parse(src, *_args)
  index = self.new
  seq = 1
  src.each do |line|
    m = COLUMN_PATTERN.match(line)
    next unless m
    _level = m[1] ## not use it yet
    id = m[2]
    caption = m[3].strip
    id = caption if id.nil? || id.empty?

    index.add_item(ReVIEW::Book::Index::Item.new(id, seq, caption))
    seq += 1
  end
  index
end