Module: Paperclip::Meta::Attachment::InstanceMethods
- Defined in:
- lib/paperclip-meta/attachment.rb
Instance Method Summary collapse
- #height(*args) ⇒ Object
-
#image_size(style = default_style) ⇒ Object
Return image dimesions (“WxH”) for given style name.
- #post_process_styles_with_meta_data(*style_args) ⇒ Object
- #save_with_meta_data ⇒ Object
-
#size_with_meta_data(passed_style = nil) ⇒ Object
Use meta info for style if required.
- #width(*args) ⇒ Object
Instance Method Details
#height(*args) ⇒ Object
46 47 48 |
# File 'lib/paperclip-meta/attachment.rb', line 46 def height(*args) ((args.first || default_style), :height) end |
#image_size(style = default_style) ⇒ Object
Return image dimesions (“WxH”) for given style name. If style name not given, return dimesions for default_style.
56 57 58 |
# File 'lib/paperclip-meta/attachment.rb', line 56 def image_size(style = default_style) "#{width(style)}x#{height(style)}" end |
#post_process_styles_with_meta_data(*style_args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/paperclip-meta/attachment.rb', line 19 def (*style_args) (*style_args) return unless instance.respond_to?(:"#{name}_meta=") = {} @queued_for_write.each do |style, file| begin geo = Geometry.from_file file [style] = {:width => geo.width.to_i, :height => geo.height.to_i, :size => file.size } rescue Paperclip::Errors::NotIdentifiedByImageMagickError [style] = {} end end return if == {} instance.send("#{name}_meta=", ()) instance.class .where(instance.class.primary_key => instance.id) .update_all("#{name}_meta" => ()) end |
#save_with_meta_data ⇒ Object
12 13 14 15 16 17 |
# File 'lib/paperclip-meta/attachment.rb', line 12 def if @queued_for_delete.any? && @queued_for_write.empty? && instance.respond_to?(:"#{name}_meta=") instance_write(:meta, ({})) end end |
#size_with_meta_data(passed_style = nil) ⇒ Object
Use meta info for style if required
42 43 44 |
# File 'lib/paperclip-meta/attachment.rb', line 42 def (passed_style = nil) passed_style ? (passed_style, :size) : end |
#width(*args) ⇒ Object
50 51 52 |
# File 'lib/paperclip-meta/attachment.rb', line 50 def width(*args) ((args.first || default_style), :width) end |