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, #has_key?, item_class, #item_type, #number

Constructor Details

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

Returns a new instance of IconIndex.



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/review/book/index.rb', line 182

def initialize(items, chapid, basedir, types, builder)
  @items = items
  @index = {}
  items.each do |i|
    ## warn "warning: duplicate ID: #{i.id} (#{i})" unless @index[i.id].nil?
    @index[i.id] = i
  end
  items.each do |i|
    i.index = self
  end
  @chapid = chapid
  @basedir = basedir
  @types = types

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

Class Method Details

.parse(src, *args) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
# File 'lib/review/book/index.rb', line 199

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