|
|
|
@ -7,10 +7,10 @@ module Squib |
|
|
|
# @param dir: the directory for the output to be sent to. Will be created if it doesn't exist |
|
|
|
# @param dir: the directory for the output to be sent to. Will be created if it doesn't exist |
|
|
|
# @param format: the format that this will be rendered too. Options `:pdf, :png`. Array of both is allowed: `[:pdf, :png]` |
|
|
|
# @param format: the format that this will be rendered too. Options `:pdf, :png`. Array of both is allowed: `[:pdf, :png]` |
|
|
|
# @param prefix: the prefix of the file name to be printed |
|
|
|
# @param prefix: the prefix of the file name to be printed |
|
|
|
def save(range: :all, dir: "_output", format: :png, prefix: "card_") |
|
|
|
def save(opts = {}) |
|
|
|
format = [format].flatten |
|
|
|
opts = needs(opts, [:range, :creatable_dir, :formats, :prefix]) |
|
|
|
save_png(range: range, dir: dir, prefix: prefix) if format.include? :png |
|
|
|
save_png(opts) if opts[:format].include? :png |
|
|
|
save_pdf if format.include? :pdf |
|
|
|
save_pdf(opts) if opts[:format].include? :pdf |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# Saves the range of cards to PNG |
|
|
|
# Saves the range of cards to PNG |
|
|
|
@ -18,9 +18,11 @@ module Squib |
|
|
|
# @param range: the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} |
|
|
|
# @param range: the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} |
|
|
|
# @param dir: the directory for the output to be sent to. Will be created if it doesn't exist |
|
|
|
# @param dir: the directory for the output to be sent to. Will be created if it doesn't exist |
|
|
|
# @param prefix: the prefix of the file name to be printed |
|
|
|
# @param prefix: the prefix of the file name to be printed |
|
|
|
def save_png(range: :all, dir: "_output", prefix: 'card_') |
|
|
|
def save_png(opts = {}) |
|
|
|
range = rangeify(range); dir = dirify(dir, allow_create: true) |
|
|
|
opts = needs(opts,[:range, :creatable_dir, :prefix]) |
|
|
|
range.each { |i| @cards[i].save_png(i, dir, prefix) } |
|
|
|
opts[:range].each do |i| |
|
|
|
|
|
|
|
@cards[i].save_png(i, opts[:dir], opts[:prefix]) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|