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

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

Instance Method Summary collapse

Instance Method Details

#height(style = default_style) ⇒ Object



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

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.



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

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

#post_process_styles_with_meta_data(*styles) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/paperclip-meta/attachment.rb', line 19

def (*styles)
  (*styles)
  return unless instance.respond_to?(:"#{name}_meta=")

  meta = populate_meta(@queued_for_write)
  return if meta == {}

  write_meta(meta)
end

#save_with_meta_dataObject



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_write(:meta, meta_encode({}))
  end
  
end

#size_with_meta_data(style = nil) ⇒ Object

Use meta info for style if required



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

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

#width(style = default_style) ⇒ Object



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

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