Class: AttachmentMagick::DSL
- Inherits:
-
Object
- Object
- AttachmentMagick::DSL
- Defined in:
- lib/attachment_magick/dsl.rb
Instance Attribute Summary collapse
-
#default_options ⇒ Object
readonly
Returns the value of attribute default_options.
-
#styles ⇒ Object
readonly
Returns the value of attribute styles.
Instance Method Summary collapse
-
#initialize(set, default_grids) ⇒ DSL
constructor
A new instance of DSL.
- #method_missing(name, *params, &blk) ⇒ Object
Constructor Details
#initialize(set, default_grids) ⇒ DSL
Returns a new instance of DSL.
6 7 8 9 10 |
# File 'lib/attachment_magick/dsl.rb', line 6 def initialize(set, default_grids) @set = set @styles = {} @default_grids = default_grids end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *params, &blk) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/attachment_magick/dsl.rb', line 12 def method_missing(name, *params, &blk) = params.first if .nil? = @default_grids[name.to_sym] elsif .is_a?(String) values = .split('x') = {} .merge!(:width => values.first.to_i) if values.first .merge!(:height => values.last.to_i) if values.second .merge!(:ajust => values.second.match(/\W/).to_s) unless values.second.match(/\W/).to_s.blank? if values.second = @default_grids[name.to_sym].merge() elsif .is_a?(Hash) = @default_grids[name.to_sym].merge() end @styles.merge!(name.to_sym => ) end |
Instance Attribute Details
#default_options ⇒ Object (readonly)
Returns the value of attribute default_options.
4 5 6 |
# File 'lib/attachment_magick/dsl.rb', line 4 def @default_options end |
#styles ⇒ Object (readonly)
Returns the value of attribute styles.
3 4 5 |
# File 'lib/attachment_magick/dsl.rb', line 3 def styles @styles end |