Class: ReVIEW::Book::ImageIndex
Direct Known Subclasses
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(chapid, basedir, types, builder) ⇒ ImageIndex
constructor
A new instance of ImageIndex.
Methods inherited from Index
#[], #add_item, #each, #item_type, #key?, #number
Constructor Details
#initialize(chapid, basedir, types, builder) ⇒ ImageIndex
Returns a new instance of ImageIndex.
180 181 182 183 184 185 186 187 188 |
# File 'lib/review/book/index.rb', line 180 def initialize(chapid, basedir, types, builder) super() @chapid = chapid @basedir = basedir @types = types @logger = ReVIEW.logger @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.
178 179 180 |
# File 'lib/review/book/index.rb', line 178 def image_finder @image_finder end |
Class Method Details
.item_type ⇒ Object
174 175 176 |
# File 'lib/review/book/index.rb', line 174 def self.item_type '(image|graph|imgtable)' end |
.parse(src, *args) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/review/book/index.rb', line 153 def self.parse(src, *args) index = self.new(*args) seq = 1 src.grep(%r{\A//#{item_type}}) do |line| # ex. ["//image", "id", "", "caption"] elements = line.split(/\[(.*?)\]/) if elements[1].present? if line.start_with?('//imgtable') index.add_item(ReVIEW::Book::Index::Item.new(elements[1], 0, elements[3])) else ## %r<\A//(image|graph)> index.add_item(ReVIEW::Book::Index::Item.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 index end |
Instance Method Details
#find_path(id) ⇒ Object
190 191 192 |
# File 'lib/review/book/index.rb', line 190 def find_path(id) @image_finder.find_path(id) end |