Class: ReVIEW::Book::BibpaperIndex

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

Defined Under Namespace

Classes: Item

Class Method Summary collapse

Methods inherited from Index

#[], #each, #has_key?, #initialize, item_class, #item_type, #number

Constructor Details

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

Class Method Details

.parse(src) ⇒ Object



245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/review/book/index.rb', line 245

def BibpaperIndex.parse(src)
  items = []
  seq = 1
  src.grep(%r<^//bibpaper>) do |line|
    if m = /\[(.*?)\]\[(.*)\]/.match(line)
      m1 = m[1].gsub(/\\(.)/){$1}
      m2 = m[2].gsub(/\\(.)/){$1}
      items.push Item.new(m1, seq, m2)
    end
    seq += 1
  end
  new(items)
end