Module: ReVIEW::Book::Compilable
Instance Attribute Summary collapse
-
#book ⇒ Object
readonly
Returns the value of attribute book.
-
#content ⇒ Object
Returns the value of attribute content.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #basename ⇒ Object
- #bibpaper(id) ⇒ Object
- #bibpaper_index ⇒ Object
- #column(id) ⇒ Object
- #column_index ⇒ Object
- #dirname ⇒ Object
- #equation(id) ⇒ Object
- #equation_index ⇒ Object
- #footnote(id) ⇒ Object
- #footnote_index ⇒ Object
- #headline(caption) ⇒ Object
- #headline_index ⇒ Object
- #icon_index ⇒ Object
- #image(id) ⇒ Object
- #image_index ⇒ Object
- #indepimage_index ⇒ Object
- #lines ⇒ Object
- #list(id) ⇒ Object
- #list_index ⇒ Object
- #name ⇒ Object (also: #id)
- #next_chapter ⇒ Object
- #numberless_image_index ⇒ Object
- #prev_chapter ⇒ Object
- #size ⇒ Object
- #table(id) ⇒ Object
- #table_index ⇒ Object
- #title ⇒ Object
- #volume ⇒ Object
Methods included from TextUtils
Instance Attribute Details
#book ⇒ Object (readonly)
Returns the value of attribute book.
15 16 17 |
# File 'lib/review/book/compilable.rb', line 15 def book @book end |
#content ⇒ Object
Returns the value of attribute content.
17 18 19 |
# File 'lib/review/book/compilable.rb', line 17 def content @content end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
16 17 18 |
# File 'lib/review/book/compilable.rb', line 16 def path @path end |
Instance Method Details
#basename ⇒ Object
24 25 26 27 |
# File 'lib/review/book/compilable.rb', line 24 def basename return nil unless @path File.basename(@path) end |
#bibpaper(id) ⇒ Object
138 139 140 |
# File 'lib/review/book/compilable.rb', line 138 def bibpaper(id) bibpaper_index[id] end |
#bibpaper_index ⇒ Object
142 143 144 145 146 |
# File 'lib/review/book/compilable.rb', line 142 def bibpaper_index raise FileNotFound, "no such bib file: #{@book.bib_file}" unless @book.bib_exist? @bibpaper_index ||= BibpaperIndex.parse(@book.read_bib.lines.to_a) @bibpaper_index end |
#column(id) ⇒ Object
156 157 158 |
# File 'lib/review/book/compilable.rb', line 156 def column(id) column_index[id] end |
#column_index ⇒ Object
160 161 162 |
# File 'lib/review/book/compilable.rb', line 160 def column_index @column_index ||= ColumnIndex.parse(lines) end |
#dirname ⇒ Object
19 20 21 22 |
# File 'lib/review/book/compilable.rb', line 19 def dirname return nil unless @path File.dirname(@path) end |
#equation(id) ⇒ Object
85 86 87 |
# File 'lib/review/book/compilable.rb', line 85 def equation(id) equation_index[id] end |
#equation_index ⇒ Object
89 90 91 92 |
# File 'lib/review/book/compilable.rb', line 89 def equation_index @equation_index ||= EquationIndex.parse(lines) @equation_index end |
#footnote(id) ⇒ Object
94 95 96 |
# File 'lib/review/book/compilable.rb', line 94 def footnote(id) footnote_index[id] end |
#footnote_index ⇒ Object
98 99 100 101 |
# File 'lib/review/book/compilable.rb', line 98 def footnote_index @footnote_index ||= FootnoteIndex.parse(lines) @footnote_index end |
#headline(caption) ⇒ Object
148 149 150 |
# File 'lib/review/book/compilable.rb', line 148 def headline(caption) headline_index[caption] end |
#headline_index ⇒ Object
152 153 154 |
# File 'lib/review/book/compilable.rb', line 152 def headline_index @headline_index ||= HeadlineIndex.parse(lines, self) end |
#icon_index ⇒ Object
124 125 126 127 128 129 |
# File 'lib/review/book/compilable.rb', line 124 def icon_index @icon_index ||= IconIndex.parse(lines, id, @book.imagedir, @book.image_types, @book.config['builder']) @icon_index end |
#image(id) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/review/book/compilable.rb', line 103 def image(id) return image_index[id] if image_index.key?(id) return icon_index[id] if icon_index.key?(id) return numberless_image_index[id] if numberless_image_index.key?(id) indepimage_index[id] end |
#image_index ⇒ Object
117 118 119 120 121 122 |
# File 'lib/review/book/compilable.rb', line 117 def image_index @image_index ||= ImageIndex.parse(lines, id, @book.imagedir, @book.image_types, @book.config['builder']) @image_index end |
#indepimage_index ⇒ Object
131 132 133 134 135 136 |
# File 'lib/review/book/compilable.rb', line 131 def indepimage_index @indepimage_index ||= IndepImageIndex.parse(lines, id, @book.imagedir, @book.image_types, @book.config['builder']) end |
#lines ⇒ Object
62 63 64 65 |
# File 'lib/review/book/compilable.rb', line 62 def lines # FIXME: we cannot duplicate Enumerator on ruby 1.9 HEAD (@lines ||= content.lines.to_a).dup end |
#list(id) ⇒ Object
67 68 69 |
# File 'lib/review/book/compilable.rb', line 67 def list(id) list_index[id] end |
#list_index ⇒ Object
71 72 73 74 |
# File 'lib/review/book/compilable.rb', line 71 def list_index @list_index ||= ListIndex.parse(lines) @list_index end |
#name ⇒ Object Also known as: id
29 30 31 32 |
# File 'lib/review/book/compilable.rb', line 29 def name return nil unless @name File.basename(@name, '.*') end |
#next_chapter ⇒ Object
164 165 166 |
# File 'lib/review/book/compilable.rb', line 164 def next_chapter book.next_chapter(self) end |
#numberless_image_index ⇒ Object
110 111 112 113 114 115 |
# File 'lib/review/book/compilable.rb', line 110 def numberless_image_index @numberless_image_index ||= NumberlessImageIndex.parse(lines, id, @book.imagedir, @book.image_types, @book.config['builder']) end |
#prev_chapter ⇒ Object
168 169 170 |
# File 'lib/review/book/compilable.rb', line 168 def prev_chapter book.prev_chapter(self) end |
#size ⇒ Object
50 51 52 |
# File 'lib/review/book/compilable.rb', line 50 def size content.size end |
#table(id) ⇒ Object
76 77 78 |
# File 'lib/review/book/compilable.rb', line 76 def table(id) table_index[id] end |
#table_index ⇒ Object
80 81 82 83 |
# File 'lib/review/book/compilable.rb', line 80 def table_index @table_index ||= TableIndex.parse(lines) @table_index end |
#title ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/review/book/compilable.rb', line 36 def title return @title if @title @title = '' return @title unless content content.each_line do |line| if line =~ /\A=+/ @title = line.sub(/\A=+(\[.+?\])?(\{.+?\})?/, '').strip break end end @title end |
#volume ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/review/book/compilable.rb', line 54 def volume unless @volume @volume = Volume.count_file(path) @volume.page_per_kbyte = @book.page_metric.page_per_kbyte end @volume end |