Module: Paperclip::Meta::Attachment::InstanceMethods

Defined in:
lib/paperclip-meta/attachment.rb

Instance Method Summary collapse

Instance Method Details

#aspect_ratio(style = default_style) ⇒ Object



43
44
45
# File 'lib/paperclip-meta/attachment.rb', line 43

def aspect_ratio(style = default_style)
  width(style).to_f / height(style).to_f
end

#assign_attributes_with_meta_dataObject



13
14
15
16
# File 'lib/paperclip-meta/attachment.rb', line 13

def 
  
  assign_meta
end

#height(style = default_style) ⇒ Object



35
36
37
# File 'lib/paperclip-meta/attachment.rb', line 35

def height(style = default_style)
  read_meta 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.



49
50
51
# File 'lib/paperclip-meta/attachment.rb', line 49

def image_size(style = default_style)
  "#{width(style)}x#{height(style)}"
end

#post_process_styles_with_meta_data(*styles) ⇒ Object



25
26
27
28
# File 'lib/paperclip-meta/attachment.rb', line 25

def (*styles)
  (*styles)
  assign_meta
end

#save_with_meta_dataObject



18
19
20
21
22
23
# File 'lib/paperclip-meta/attachment.rb', line 18

def 
  if @queued_for_delete.any? && @queued_for_write.empty?
    instance_write(:meta, meta_encode({}))
  end
  
end

#size_with_meta_data(style = nil) ⇒ Object

Use meta info for style if required



31
32
33
# File 'lib/paperclip-meta/attachment.rb', line 31

def (style = nil)
  style ? read_meta(style, :size) : 
end

#width(style = default_style) ⇒ Object



39
40
41
# File 'lib/paperclip-meta/attachment.rb', line 39

def width(style = default_style)
  read_meta style, :width
end