class Squib::DSL::SafeZone

Attributes

deck[R]
dsl_method[R]

Public Class Methods

accepted_params() click to toggle source
# File lib/squib/dsl/safe_zone.rb, line 20
def self.accepted_params
  %i(x y width height margin angle
     x_radius y_radius radius
     fill_color stroke_color stroke_width stroke_strategy join dash cap
     range layout)
end
new(deck, dsl_method) click to toggle source
# File lib/squib/dsl/safe_zone.rb, line 15
def initialize(deck, dsl_method)
  @deck = deck
  @dsl_method = dsl_method
end

Public Instance Methods

run(opts) click to toggle source
# File lib/squib/dsl/safe_zone.rb, line 27
def run(opts)
  warn_if_unexpected opts
  safe_defaults = {
    margin: '0.25in',
    radius: '0.125in',
    stroke_color: :blue,
    fill_color: '#0000',
    stroke_width: 1.0,
    dash: '3 3',
  }
  new_opts = safe_defaults.merge(opts)
  margin = Args::UnitConversion.parse new_opts[:margin], @deck.dpi, @deck.cell_px
  new_opts[:x] = margin
  new_opts[:y] = margin
  new_opts[:width] = deck.width - (2 * margin)
  new_opts[:height] = deck.height - (2 * margin)
  new_opts.delete :margin
  deck.rect(new_opts)
end