Sha256: 3bee70d9d5db1393e2096b0cf51bfc40fa58269cea1623000a5f64f276e2b74a

Contents?: true

Size: 991 Bytes

Versions: 10

Compression:

Stored size: 991 Bytes

Contents

module WhirledPeas
  module Settings
    class Spacing
      attr_writer :left, :top, :right, :bottom

      def left=(value)
        @left = validate!(value)
      end

      def left
        @left || 0
      end

      def top=(value)
        @top = validate!(value)
      end

      def top
        @top || 0
      end

      def right=(value)
        @right = validate!(value)
      end

      def right
        @right || 0
      end

      def bottom=(value)
        @bottom = validate!(value)
      end

      def bottom
        @bottom || 0
      end

      def horiz=(value)
        self.left = self.right = value
      end

      def vert=(value)
        self.top = self.bottom = value
      end

      private

      def validate!(value)
        if value && value < 0
          raise ArgumentError, "Negative values for #{self.class.name.split('::').last.downcase} are not allowed"
        else
          value
        end
      end
    end
    private_constant :Spacing
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
whirled_peas-0.13.0 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.12.0 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.11.1 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.11.0 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.10.0 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.9.1 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.9.0 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.8.0 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.7.1 lib/whirled_peas/settings/spacing.rb
whirled_peas-0.7.0 lib/whirled_peas/settings/spacing.rb