Sha256: a14dd38a09b0c4f8e3842fa77102067fea45731bd542b82f15f5e1ac0319b4bd

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'squib/args/arg_loader'
require 'squib/args/dir_validator'

module Squib
  # @api private
  module Args
    class SaveBatch
      include ArgLoader
      include DirValidator

      def initialize
      end

      def self.parameters
        { dir: '_output',
          prefix: 'card_',
          count_format: '%02d',
          rotate: false,
          angle: 0,
        }
      end

      def self.expanding_parameters
        self.parameters.keys # all of them
      end

      def self.params_with_units
        [] # none of them
      end

      def validate_dir(arg, _i)
        ensure_dir_created(arg)
      end

      def validate_rotate(arg, i)
        case arg
        when true, :clockwise
          angle[i] = 0.5 * Math::PI
          return true
        when :counterclockwise
          angle[i] = 1.5 * Math::PI
          return true
        when false
          false
        else
          raise 'invalid option to rotate: only [true, false, :clockwise, :counterclockwise]'
        end
      end

      def full_filename(i)
        "#{dir[i]}/#{prefix[i]}#{count_format[i] % i}.png"
      end

      def summary
        "#{dir[0]}/#{prefix[0]}_*"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
squib-0.8.0 lib/squib/args/save_batch.rb
squib-0.7.0 lib/squib/args/save_batch.rb