Class: ReVIEW::Book::ImageIndex
Direct Known Subclasses
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#image_finder ⇒ Object
readonly
Returns the value of attribute image_finder.
Class Method Summary collapse
Instance Method Summary collapse
- #find_path(id) ⇒ Object
-
#initialize(items, chapid, basedir, types, builder) ⇒ ImageIndex
constructor
A new instance of ImageIndex.
Methods inherited from Index
#[], #each, item_class, #item_type, #key?, #number
Constructor Details
#initialize(items, chapid, basedir, types, builder) ⇒ ImageIndex
Returns a new instance of ImageIndex.
205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/review/book/index.rb', line 205 def initialize(items, chapid, basedir, types, builder) super items items.each do |i| i.index = self end @chapid = chapid @basedir = basedir @types = types @image_finder = ReVIEW::Book::ImageFinder.new(basedir, chapid, builder, types) end |
Instance Attribute Details
#image_finder ⇒ Object (readonly)
Returns the value of attribute image_finder.
203 204 205 |
# File 'lib/review/book/index.rb', line 203 def image_finder @image_finder end |
Class Method Details
.item_type ⇒ Object
177 178 179 |
# File 'lib/review/book/index.rb', line 177 def self.item_type '(image|graph|imgtable)' end |
.parse(src, *args) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/review/book/index.rb', line 156 def self.parse(src, *args) items = [] seq = 1 src.grep(%r{\A//#{item_type}}) do |line| # ex. ["//image", "id", "", "caption"] elements = line.split(/\[(.*?)\]/) if elements[1].present? if line =~ %r{\A//imgtable} items.push item_class.new(elements[1], 0, elements[3]) else ## %r<\A//(image|graph)> items.push item_class.new(elements[1], seq, elements[3]) seq += 1 end if elements[1] == '' ReVIEW.logger.warn "warning: no ID of #{item_type} in #{line}" end end end new(items, *args) end |
Instance Method Details
#find_path(id) ⇒ Object
217 218 219 |
# File 'lib/review/book/index.rb', line 217 def find_path(id) @image_finder.find_path(id) end |