Class: ReVIEW::Book::IconIndex

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

Instance Attribute Summary

Attributes inherited from ImageIndex

#image_finder

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ImageIndex

#find_path, item_type

Methods inherited from Index

#[], #each, item_class, #item_type, #key?, #number

Constructor Details

#initialize(items, chapid, basedir, types, builder) ⇒ IconIndex

Returns a new instance of IconIndex.



223
224
225
226
227
228
229
230
231
232
233
# File 'lib/review/book/index.rb', line 223

def initialize(items, chapid, basedir, types, builder)
  @items = items
  @index = {}
  items.each { |i| @index[i.id] = i }
  items.each { |i| i.index = self }
  @chapid = chapid
  @basedir = basedir
  @types = types

  @image_finder = ImageFinder.new(basedir, chapid, builder, types)
end

Class Method Details

.parse(src, *args) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
# File 'lib/review/book/index.rb', line 235

def self.parse(src, *args)
  items = []
  seq = 1
  src.grep(/@<icon>/) do |line|
    line.gsub(/@<icon>\{(.+?)\}/) do
      items.push item_class.new($1, seq)
      seq += 1
    end
  end
  new(items, *args)
end