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.
182
183
184
185
186
187
188
|
# File 'lib/gepub/builder.rb', line 182
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
255
256
257
258
259
260
261
|
# File 'lib/gepub/builder.rb', line 255
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
303
304
305
|
# File 'lib/gepub/builder.rb', line 303
def book
@book
end
|
#collection(val, count = 1) ⇒ Object
215
216
217
218
|
# File 'lib/gepub/builder.rb', line 215
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
263
264
265
|
# File 'lib/gepub/builder.rb', line 263
def contributor(val, role = nil)
MetaItem.new(@book.add_contributor(val, role: role))
end
|
#contributors(*vals) ⇒ Object
234
235
236
237
238
239
240
241
242
|
# File 'lib/gepub/builder.rb', line 234
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
220
221
222
|
# File 'lib/gepub/builder.rb', line 220
def creator(val, role = 'aut')
MetaItem.new(@book.add_creator(val, role: role))
end
|
#creators(*vals) ⇒ Object
224
225
226
227
228
229
230
231
232
|
# File 'lib/gepub/builder.rb', line 224
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
296
297
298
|
# File 'lib/gepub/builder.rb', line 296
def generate_epub(path_to_epub)
@book.generate_epub(path_to_epub)
end
|
#generate_epub_stream ⇒ Object
306
307
308
|
# File 'lib/gepub/builder.rb', line 306
def generate_epub_stream
@book.generate_epub_stream
end
|
specify scroll axis for ibooks
277
278
279
|
# File 'lib/gepub/builder.rb', line 277
def ibooks_scroll_axis(val)
@book.ibooks_scroll_axis = val
end
|
#ibooks_version(val) ⇒ Object
specify version for ibooks
273
274
275
|
# File 'lib/gepub/builder.rb', line 273
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.
285
286
287
288
289
290
291
292
293
294
|
# File 'lib/gepub/builder.rb', line 285
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.
268
269
270
271
|
# File 'lib/gepub/builder.rb', line 268
def page_progression_direction(val)
raise assert unless ['rtl', 'ltr', 'default'].member? val
@book.page_progression_direction = val
end
|
#publishers(*vals) ⇒ Object
244
245
246
247
248
249
|
# File 'lib/gepub/builder.rb', line 244
def publishers(*vals)
@last_defined_item = vals.map {
|v|
MetaItem.new(@book.add_publisher(v))
}
end
|
#resources(attributes = {}, &block) ⇒ Object
300
301
302
|
# File 'lib/gepub/builder.rb', line 300
def resources(attributes = {}, &block)
ResourceBuilder.new(@book, attributes, &block)
end
|
#unique_identifier(val, id = 'BookID', scheme = 'nil') ⇒ Object
251
252
253
|
# File 'lib/gepub/builder.rb', line 251
def unique_identifier(val, id = 'BookID', scheme = 'nil')
@last_defined_item = MetaItem.new(@book.primary_identifier(val, id, scheme))
end
|