Class: Configuration::Thumbnail::ThumbnailSpec
- Inherits:
-
Object
- Object
- Configuration::Thumbnail::ThumbnailSpec
- Includes:
- ConditionalInclusion
- Defined in:
- lib/httpimagestore/configuration/thumbnailer.rb
Defined Under Namespace
Classes: Spec
Instance Attribute Summary collapse
-
#image_name ⇒ Object
readonly
Returns the value of attribute image_name.
Instance Method Summary collapse
-
#initialize(image_name, method, width, height, format, options = {}, matcher = nil) ⇒ ThumbnailSpec
constructor
A new instance of ThumbnailSpec.
- #render(locals = {}) ⇒ Object
Methods included from ConditionalInclusion
#excluded?, #included?, #inclusion_matcher
Constructor Details
#initialize(image_name, method, width, height, format, options = {}, matcher = nil) ⇒ ThumbnailSpec
Returns a new instance of ThumbnailSpec.
69 70 71 72 73 74 75 76 77 |
# File 'lib/httpimagestore/configuration/thumbnailer.rb', line 69 def initialize(image_name, method, width, height, format, = {}, matcher = nil) @image_name = image_name @method = Spec.new(image_name, 'method', method) @width = Spec.new(image_name, 'width', width) @height = Spec.new(image_name, 'height', height) @format = Spec.new(image_name, 'format', format) @options = .inject({}){|h, v| h[v.first] = Spec.new(image_name, v.first, v.last); h} inclusion_matcher matcher if matcher end |
Instance Attribute Details
#image_name ⇒ Object (readonly)
Returns the value of attribute image_name.
79 80 81 |
# File 'lib/httpimagestore/configuration/thumbnailer.rb', line 79 def image_name @image_name end |
Instance Method Details
#render(locals = {}) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/httpimagestore/configuration/thumbnailer.rb', line 81 def render(locals = {}) = @options.inject({}){|h, v| h[v.first] = v.last.render(locals); h} = ['options'] ? Hash[.delete('options').to_s.split(',').map{|pair| pair.split(':', 2)}] : {} { @image_name => [ @method.render(locals), @width.render(locals), @height.render(locals), @format.render(locals), .merge() ] } end |