Sha256: f5d86cbc587beceefc780554e1badb7b8def7851990b7c768016a2f41b2ab0ad

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'squib/args/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

1 entries across 1 versions & 1 rubygems

Version Path
squib-0.9.0 lib/squib/args/box.rb