Sha256: e1fac96eeeda6d37a84468ab8d262ab42cbbe4dc61cf51feee42d8b57a5fde43

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

require_relative 'arg_loader'

module Squib
  # @api private
  module Args

    class Box
      include ArgLoader

      def initialize(deck = nil, dsl_method_defaults = {})
        @deck = deck
        @dsl_method_defaults = dsl_method_defaults
      end

      def self.parameters
        { x: 0, y: 0,
          width: :deck, height: :deck,
          radius: nil, x_radius: 0, y_radius: 0
        }
      end

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

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

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

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

      def validate_x_radius(arg, i)
        return radius[i] unless radius[i].nil?
        arg
      end

      def validate_y_radius(arg, i)
        return radius[i] unless 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/box.rb
squib-0.15.0 lib/squib/args/box.rb
squib-0.14.3.pre1 lib/squib/args/box.rb
squib-0.14.1 lib/squib/args/box.rb
squib-0.14.0 lib/squib/args/box.rb
squib-0.14.beta1 lib/squib/args/box.rb
squib-0.13.4 lib/squib/args/box.rb
squib-0.13.3 lib/squib/args/box.rb
squib-0.13.2 lib/squib/args/box.rb
squib-0.13.1 lib/squib/args/box.rb
squib-0.13.0 lib/squib/args/box.rb
squib-0.12.0 lib/squib/args/box.rb
squib-0.11.0 lib/squib/args/box.rb
squib-0.10.0 lib/squib/args/box.rb