Class: GEPUB::Builder
Defined Under Namespace
Classes: MetaItem
Instance Method Summary
collapse
#method_missing
Constructor Details
#initialize(_attributes = {}, &block) ⇒ Builder
Returns a new instance of Builder.
184
185
186
187
188
189
190
|
# File 'lib/gepub/builder.rb', line 184
def initialize(_attributes = {}, &block)
@last_defined_item = nil
@book = Book.new
instance_eval(&block)
true
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class GEPUB::BuilderMixin
Instance Method Details
#alts(alt_vals = {}) ⇒ Object
257
258
259
260
261
262
263
|
# File 'lib/gepub/builder.rb', line 257
def alts(alt_vals = {})
raise "can't specify alts on single item" if ! Array === @last_defined_item
@last_defined_item.each_with_index {
|item, index|
item.alt Hash[*(alt_vals.map{|k,v| [k,v[index]]}.flatten)]
}
end
|
#book ⇒ Object
305
306
307
|
# File 'lib/gepub/builder.rb', line 305
def book
@book
end
|
#collection(val, count = 1) ⇒ Object
217
218
219
220
|
# File 'lib/gepub/builder.rb', line 217
def collection(val, count = 1)
@last_defined_item =
MetaItem.new(@book.add_title(val, title_type: GEPUB::TITLE_TYPE::COLLECTION).group_position(count.to_s))
end
|
#contributor(val, role = nil) ⇒ Object
265
266
267
|
# File 'lib/gepub/builder.rb', line 265
def contributor(val, role = nil)
MetaItem.new(@book.add_contributor(val, role: role))
end
|
#contributors(*vals) ⇒ Object
236
237
238
239
240
241
242
243
244
|
# File 'lib/gepub/builder.rb', line 236
def contributors(*vals)
@last_defined_item = vals.map {
|v|
name = v
role = nil
name,role = v[0], v[1] if Array === name
MetaItem.new(@book.add_contributor(name, role: role))
}
end
|
#creator(val, role = 'aut') ⇒ Object
222
223
224
|
# File 'lib/gepub/builder.rb', line 222
def creator(val, role = 'aut')
MetaItem.new(@book.add_creator(val, role: role))
end
|
#creators(*vals) ⇒ Object
226
227
228
229
230
231
232
233
234
|
# File 'lib/gepub/builder.rb', line 226
def creators(*vals)
@last_defined_item = vals.map {
|v|
name = v
role = 'aut'
name,role = v[0], v[1] if Array === name
MetaItem.new(@book.add_creator(name, role: role))
}
end
|
#generate_epub(path_to_epub) ⇒ Object
298
299
300
|
# File 'lib/gepub/builder.rb', line 298
def generate_epub(path_to_epub)
@book.generate_epub(path_to_epub)
end
|
#generate_epub_stream ⇒ Object
308
309
310
|
# File 'lib/gepub/builder.rb', line 308
def generate_epub_stream
@book.generate_epub_stream
end
|
specify scroll axis for ibooks
279
280
281
|
# File 'lib/gepub/builder.rb', line 279
def ibooks_scroll_axis(val)
@book.ibooks_scroll_axis = val
end
|
#ibooks_version(val) ⇒ Object
specify version for ibooks
275
276
277
|
# File 'lib/gepub/builder.rb', line 275
def ibooks_version(val)
@book.ibooks_version=val
end
|
#optional_file(val) ⇒ Object
set optional file. val should be String or Hash. if val is String, file is read from the File specified by string and stored in EPUB to the path specified by string. if val is Hash, file is read from the value and stored in EPUB to the path specified by the key.
287
288
289
290
291
292
293
294
295
296
|
# File 'lib/gepub/builder.rb', line 287
def optional_file(val)
path = val
io = val if String === val
if Hash === val
raise 'argument to optional_file should be length 1' if val.size != 1
path = val.first[0]
io = val.first[1]
end
@book.add_optional_file(path, io)
end
|
#page_progression_direction(val) ⇒ Object
set page progression direction.
270
271
272
273
|
# File 'lib/gepub/builder.rb', line 270
def page_progression_direction(val)
raise assert unless ['rtl', 'ltr', 'default'].member? val
@book.page_progression_direction = val
end
|
#publishers(*vals) ⇒ Object
246
247
248
249
250
251
|
# File 'lib/gepub/builder.rb', line 246
def publishers(*vals)
@last_defined_item = vals.map {
|v|
MetaItem.new(@book.add_publisher(v))
}
end
|
#resources(attributes = {}, &block) ⇒ Object
302
303
304
|
# File 'lib/gepub/builder.rb', line 302
def resources(attributes = {}, &block)
ResourceBuilder.new(@book, attributes, &block)
end
|
#unique_identifier(val, id = 'BookID', scheme = 'nil') ⇒ Object
253
254
255
|
# File 'lib/gepub/builder.rb', line 253
def unique_identifier(val, id = 'BookID', scheme = 'nil')
@last_defined_item = MetaItem.new(@book.primary_identifier(val, id, scheme))
end
|