Class: ReVIEW::Book::BookUnit
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from TextUtils
#add_space?, #detab, #join_lines_to_paragraph, #split_paragraph
Constructor Details
#initialize(file_content: nil, book: nil) ⇒ BookUnit
Returns a new instance of BookUnit.
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/review/book/book_unit.rb', line 26
def initialize(file_content: nil, book: nil)
if book
@book = book
end
if file_content
@content = file_content
end
if @content
@lines = @content.lines
end
end
|
Instance Attribute Details
Returns the value of attribute book.
16
17
18
|
# File 'lib/review/book/book_unit.rb', line 16
def book
@book
end
|
#column_index ⇒ Object
Returns the value of attribute column_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def column_index
@column_index
end
|
Returns the value of attribute content.
19
20
21
|
# File 'lib/review/book/book_unit.rb', line 19
def content
@content
end
|
#endnote_index ⇒ Object
Returns the value of attribute endnote_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def endnote_index
@endnote_index
end
|
#equation_index ⇒ Object
Returns the value of attribute equation_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def equation_index
@equation_index
end
|
Returns the value of attribute footnote_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def
@footnote_index
end
|
#headline_index ⇒ Object
Returns the value of attribute headline_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def headline_index
@headline_index
end
|
#icon_index ⇒ Object
Returns the value of attribute icon_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def icon_index
@icon_index
end
|
#image_index ⇒ Object
Returns the value of attribute image_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def image_index
@image_index
end
|
#indepimage_index ⇒ Object
Returns the value of attribute indepimage_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def indepimage_index
@indepimage_index
end
|
Returns the value of attribute lines.
18
19
20
|
# File 'lib/review/book/book_unit.rb', line 18
def lines
@lines
end
|
#list_index ⇒ Object
Returns the value of attribute list_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def list_index
@list_index
end
|
#numberless_image_index ⇒ Object
Returns the value of attribute numberless_image_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def numberless_image_index
@numberless_image_index
end
|
Returns the value of attribute path.
17
18
19
|
# File 'lib/review/book/book_unit.rb', line 17
def path
@path
end
|
#table_index ⇒ Object
Returns the value of attribute table_index.
21
22
23
|
# File 'lib/review/book/book_unit.rb', line 21
def table_index
@table_index
end
|
Instance Method Details
72
73
74
|
# File 'lib/review/book/book_unit.rb', line 72
def basename
@path && File.basename(@path)
end
|
#bibpaper(id) ⇒ Object
137
138
139
|
# File 'lib/review/book/book_unit.rb', line 137
def bibpaper(id)
bibpaper_index[id]
end
|
#bibpaper_index ⇒ Object
141
142
143
144
145
|
# File 'lib/review/book/book_unit.rb', line 141
def bibpaper_index
raise FileNotFound, "no such bib file: #{@book.bib_file}" unless @book.bib_exist?
@book.bibpaper_index
end
|
#column(id) ⇒ Object
151
152
153
|
# File 'lib/review/book/book_unit.rb', line 151
def column(id)
column_index[id]
end
|
68
69
70
|
# File 'lib/review/book/book_unit.rb', line 68
def dirname
@path && File.dirname(@path)
end
|
#endnote(id) ⇒ Object
121
122
123
|
# File 'lib/review/book/book_unit.rb', line 121
def endnote(id)
endnote_index[id]
end
|
125
126
127
|
# File 'lib/review/book/book_unit.rb', line 125
def endnotes
endnote_index
end
|
#equation(id) ⇒ Object
113
114
115
|
# File 'lib/review/book/book_unit.rb', line 113
def equation(id)
equation_index[id]
end
|
#execute_indexer(force: false) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/review/book/book_unit.rb', line 38
def execute_indexer(force: false)
if @index_builder && !force
return @index_builder
end
@index_builder = ReVIEW::IndexBuilder.new
compiler = ReVIEW::Compiler.new(@index_builder)
compiler.compile(self)
@index_builder
end
|
117
118
119
|
# File 'lib/review/book/book_unit.rb', line 117
def (id)
[id]
end
|
#generate_indexes(use_bib: false) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/review/book/book_unit.rb', line 49
def generate_indexes(use_bib: false)
return unless content
@lines = content.lines
@indexes = execute_indexer
@list_index = @indexes.list_index
@table_index = @indexes.table_index
@equation_index = @indexes.equation_index
@footnote_index = @indexes.
@endnote_index = @indexes.endnote_index
@headline_index = @indexes.headline_index
@column_index = @indexes.column_index
if use_bib
@book.bibpaper_index = @indexes.bibpaper_index
end
end
|
#headline(caption) ⇒ Object
147
148
149
|
# File 'lib/review/book/book_unit.rb', line 147
def headline(caption)
headline_index[caption]
end
|
#image(id) ⇒ Object
129
130
131
132
133
134
135
|
# File 'lib/review/book/book_unit.rb', line 129
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_bound?(item_id) ⇒ Boolean
163
164
165
|
# File 'lib/review/book/book_unit.rb', line 163
def image_bound?(item_id)
image(item_id).path
end
|
105
106
107
|
# File 'lib/review/book/book_unit.rb', line 105
def list(id)
list_index[id]
end
|
#name ⇒ Object
Also known as:
id
76
77
78
|
# File 'lib/review/book/book_unit.rb', line 76
def name
@name && File.basename(@name, '.*')
end
|
#next_chapter ⇒ Object
155
156
157
|
# File 'lib/review/book/book_unit.rb', line 155
def next_chapter
book.next_chapter(self)
end
|
#prev_chapter ⇒ Object
159
160
161
|
# File 'lib/review/book/book_unit.rb', line 159
def prev_chapter
book.prev_chapter(self)
end
|
97
98
99
|
# File 'lib/review/book/book_unit.rb', line 97
def size
content.size
end
|
#table(id) ⇒ Object
109
110
111
|
# File 'lib/review/book/book_unit.rb', line 109
def table(id)
table_index[id]
end
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/review/book/book_unit.rb', line 82
def title
return @title if @title
@title = ''
return @title unless content
content.each_line do |line|
if /\A=+/.match?(line)
@title = line.sub(/\A=+(\[.+?\])?(\{.+?\})?/, '').strip
break
end
end
@title
end
|
101
102
103
|
# File 'lib/review/book/book_unit.rb', line 101
def volume
@volume ||= Volume.count_file(path)
end
|