Class: Squib::Args::Draw Private
- Inherits:
-
Object
- Object
- Squib::Args::Draw
- Includes:
- ArgLoader, ColorValidator
- Defined in:
- lib/squib/args/draw.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .expanding_parameters ⇒ Object private
- .parameters ⇒ Object private
- .params_with_units ⇒ Object private
Instance Method Summary collapse
-
#initialize(custom_colors, dsl_method_defaults = {}) ⇒ Draw
constructor
private
A new instance of Draw.
- #validate_cap(arg, _i) ⇒ Object private
- #validate_color(arg, _i) ⇒ Object private
- #validate_dash(arg, _i) ⇒ Object private
- #validate_fill_color(arg, _i) ⇒ Object private
- #validate_join(arg, _i) ⇒ Object private
- #validate_stroke_color(arg, _i) ⇒ Object private
- #validate_stroke_strategy(arg, _i) ⇒ Object private
Methods included from ColorValidator
Methods included from ArgLoader
#[], #convert_units, #defaultify, #expand_and_set_and_defaultify, #expandable_singleton?, #load!, #prep_layout_args, #validate
Constructor Details
#initialize(custom_colors, dsl_method_defaults = {}) ⇒ Draw
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Draw.
13 14 15 16 |
# File 'lib/squib/args/draw.rb', line 13 def initialize(custom_colors, dsl_method_defaults = {}) @custom_colors = custom_colors @dsl_method_defaults = dsl_method_defaults end |
Class Method Details
.expanding_parameters ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/squib/args/draw.rb', line 30 def self. parameters.keys # all of them are expandable end |
.parameters ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/squib/args/draw.rb', line 18 def self.parameters { color: :black, fill_color: '#0000', stroke_color: :black, stroke_width: 2.0, stroke_strategy: :fill_first, join: :miter, cap: 'butt', dash: '' } end |
.params_with_units ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/squib/args/draw.rb', line 34 def self.params_with_units [:stroke_width] end |
Instance Method Details
#validate_cap(arg, _i) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/squib/args/draw.rb', line 49 def validate_cap(arg, _i) case arg.to_s.strip.downcase when 'butt' Cairo::LINE_CAP_BUTT when 'round' Cairo::LINE_CAP_ROUND when 'square' Cairo::LINE_CAP_SQUARE end end |
#validate_color(arg, _i) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'lib/squib/args/draw.rb', line 74 def validate_color(arg, _i) colorify(arg, @custom_colors) end |
#validate_dash(arg, _i) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 |
# File 'lib/squib/args/draw.rb', line 60 def validate_dash(arg, _i) arg.to_s.split.collect do |x| UnitConversion.parse(x, @dpi).to_f end end |
#validate_fill_color(arg, _i) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 |
# File 'lib/squib/args/draw.rb', line 66 def validate_fill_color(arg, _i) colorify(arg, @custom_colors) end |
#validate_join(arg, _i) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/squib/args/draw.rb', line 38 def validate_join(arg, _i) case arg.to_s.strip.downcase when 'miter' Cairo::LINE_JOIN_MITER when 'round' Cairo::LINE_JOIN_ROUND when 'bevel' Cairo::LINE_JOIN_BEVEL end end |
#validate_stroke_color(arg, _i) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 |
# File 'lib/squib/args/draw.rb', line 70 def validate_stroke_color(arg, _i) colorify(arg, @custom_colors) end |
#validate_stroke_strategy(arg, _i) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/squib/args/draw.rb', line 78 def validate_stroke_strategy(arg, _i) case arg.to_s.downcase.strip when 'fill_first' :fill_first when 'stroke_first' :stroke_first else raise "Only 'stroke_first' or 'fill_first' allowed" end end |