Sha256: 0f86f2b979676768c8219236f4789f9df3d224dddb6ddee1b51eb816a45520ac

Contents?: true

Size: 1.33 KB

Versions: 14

Compression:

Stored size: 1.33 KB

Contents

require_relative 'arg_loader'

module Squib
  # @api private
  module Args

    class Transform
      include ArgLoader

      def initialize(deck = nil)
        @deck = deck
      end

      def self.parameters
        { angle: 0,
          crop_x: 0,
          crop_y: 0,
          crop_width: :native,
          crop_height: :native,
          crop_corner_radius: nil,
          crop_corner_x_radius: 0,
          crop_corner_y_radius: 0,
          flip_vertical: false,
          flip_horizontal: false,
        }
      end

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

      def self.params_with_units
        parameters.keys - [:flip_vertical, :flip_horizontal]
      end

      def validate_crop_width(arg, _i)
        return arg if @deck.nil?
        return @deck.width if arg == :deck
        arg
      end

      def validate_crop_height(arg, _i)
        return arg if @deck.nil?
        return @deck.height if arg == :deck
        arg
      end

      def validate_crop_corner_x_radius(arg, i)
        return crop_corner_radius[i] unless crop_corner_radius[i].nil?
        arg
      end

      def validate_crop_corner_y_radius(arg, i)
        return crop_corner_radius[i] unless crop_corner_radius[i].nil?
        arg
      end

    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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