Sha256: 85b964697aa40c5af34cf631cab0b5dacacb8532d677567dd41ff32a89ed12e0

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

require_relative 'arg_loader'
require_relative 'dir_validator'

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

      def initialize
      end

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

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

      def self.params_with_units
        [:trim, :trim_radius]
      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

14 entries across 14 versions & 1 rubygems

Version Path
squib-0.15.3 lib/squib/args/save_batch.rb
squib-0.15.0 lib/squib/args/save_batch.rb
squib-0.14.3.pre1 lib/squib/args/save_batch.rb
squib-0.14.1 lib/squib/args/save_batch.rb
squib-0.14.0 lib/squib/args/save_batch.rb
squib-0.14.beta1 lib/squib/args/save_batch.rb
squib-0.13.4 lib/squib/args/save_batch.rb
squib-0.13.3 lib/squib/args/save_batch.rb
squib-0.13.2 lib/squib/args/save_batch.rb
squib-0.13.1 lib/squib/args/save_batch.rb
squib-0.13.0 lib/squib/args/save_batch.rb
squib-0.12.0 lib/squib/args/save_batch.rb
squib-0.11.0 lib/squib/args/save_batch.rb
squib-0.10.0 lib/squib/args/save_batch.rb