Sha256: 0b0ceba02c4ae3bb4b29e87e136e5340ba21a9610f26accde8a65cf0ca29d952

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

require_relative '../errors_warnings/warn_unexpected_params'

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

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

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

      def self.accepted_params
        %i{
          range
          color
        }
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

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