Class: ReVIEW::Book::ImageIndex

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

Direct Known Subclasses

IconIndex, IndepImageIndex, NumberlessImageIndex

Defined Under Namespace

Classes: Item

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Index

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

Constructor Details

#initialize(items, chapid, basedir, types) ⇒ ImageIndex

Returns a new instance of ImageIndex.



162
163
164
165
166
167
168
169
170
# File 'lib/review/book/index.rb', line 162

def initialize(items, chapid, basedir, types)
  super items
  items.each do |i|
    i.index = self
  end
  @chapid = chapid
  @basedir = basedir
  @types = types
end

Class Method Details

.item_typeObject



158
159
160
# File 'lib/review/book/index.rb', line 158

def ImageIndex.item_type
  '(image|graph)'
end

Instance Method Details

#find_pathes(id) ⇒ Object

internal use only



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/review/book/index.rb', line 173

def find_pathes(id)
  if ReVIEW.book.param["subdirmode"]
    re = /\A#{id}(?i:#{@types.join('|')})\z/x
    entries().select {|ent| re =~ ent }\
      .sort_by {|ent| @types.index(File.extname(ent).downcase) }\
      .map {|ent| "#{@basedir}/#{@chapid}/#{ent}" }
  elsif ReVIEW.book.param["singledirmode"]
    re = /\A#{id}(?i:#{@types.join('|')})\z/x
    entries().select {|ent| re =~ ent }\
      .sort_by {|ent| @types.index(File.extname(ent).downcase) }\
      .map {|ent| "#{@basedir}/#{ent}" }
  else
    re = /\A#{@chapid.gsub('+', '\\\+').gsub('-', '\\\-')}-#{id}(?i:#{@types.join('|')})\z/x
    entries().select {|ent| re =~ ent }\
      .sort_by {|ent| @types.index(File.extname(ent).downcase) }\
      .map {|ent| "#{@basedir}/#{ent}" }
  end
end