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
185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/review/book/index.rb', line 185 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.
183 184 185 |
# File 'lib/review/book/index.rb', line 183 def image_finder @image_finder end |
Class Method Details
.item_type ⇒ Object
157 158 159 |
# File 'lib/review/book/index.rb', line 157 def self.item_type '(image|graph|imgtable)' end |
.parse(src, *args) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/review/book/index.rb', line 138 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 ReVIEW.logger.warn "warning: no ID of #{item_type} in #{line}" if elements[1] == '' end end new(items, *args) end |
Instance Method Details
#find_path(id) ⇒ Object
197 198 199 |
# File 'lib/review/book/index.rb', line 197 def find_path(id) @image_finder.find_path(id) end |