Sha256: abe84f96d9f5264a2256ed31f0cf035f99bd6f74c334fad0e139b47e46dbaa89

Contents?: true

Size: 857 Bytes

Versions: 3

Compression:

Stored size: 857 Bytes

Contents

require_relative '../errors_warnings/warn_unexpected_params'

module Squib
  class Deck
    def triangle(opts = {})
      DSL::Triangle.new(self, __callee__).run(opts)
    end
  end

  module DSL
    class Triangle
      include WarnUnexpectedParams
      attr_reader :dsl_method, :deck

      def initialize(deck, dsl_method)
        @deck = deck
        @dsl_method = dsl_method
      end

      def self.accepted_params
        %i(x1 y1 x2 y2 x3 y3
           fill_color stroke_color stroke_width stroke_strategy join dash cap
           range layout)
      end

      def run(opts)
        warn_if_unexpected opts
        range = Args.extract_range opts, deck
        draw  = Args.extract_draw opts, deck
        coords   = Args.extract_coords opts, deck
        range.each { |i| deck.cards[i].triangle(coords[i], draw[i]) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
squib-0.19.0 lib/squib/dsl/triangle.rb
squib-0.19.0b lib/squib/dsl/triangle.rb
squib-0.19.0a lib/squib/dsl/triangle.rb