Class: Squib::DSL::CutZone
- Inherits:
-
Object
- Object
- Squib::DSL::CutZone
- Includes:
- WarnUnexpectedParams
- Defined in:
- lib/squib/dsl/cut_zone.rb
Instance Attribute Summary collapse
- #deck ⇒ Object readonly
- #dsl_method ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(deck, dsl_method) ⇒ CutZone
constructor
A new instance of CutZone.
- #run(opts) ⇒ Object
Methods included from WarnUnexpectedParams
Constructor Details
#initialize(deck, dsl_method) ⇒ CutZone
Returns a new instance of CutZone.
15 16 17 18 |
# File 'lib/squib/dsl/cut_zone.rb', line 15 def initialize(deck, dsl_method) @deck = deck @dsl_method = dsl_method end |
Instance Attribute Details
#deck ⇒ Object (readonly)
13 14 15 |
# File 'lib/squib/dsl/cut_zone.rb', line 13 def deck @deck end |
#dsl_method ⇒ Object (readonly)
13 14 15 |
# File 'lib/squib/dsl/cut_zone.rb', line 13 def dsl_method @dsl_method end |
Class Method Details
.accepted_params ⇒ Object
20 21 22 23 24 25 |
# File 'lib/squib/dsl/cut_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 |
Instance Method Details
#run(opts) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/squib/dsl/cut_zone.rb', line 27 def run(opts) warn_if_unexpected opts cut_defaults = { margin: '0.125in', radius: '0.125in', stroke_color: :red, fill_color: '#0000', stroke_width: 2.0, } new_opts = cut_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 |