Class: Ckeditor::Asset

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb,
lib/generators/ckeditor/migration/templates/models/attachment_fu/asset.rb

Direct Known Subclasses

AttachmentFile, Picture

Instance Method Summary collapse

Instance Method Details

#content_typeObject



23
24
25
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 23

def content_type
  data_content_type
end

#filenameObject



19
20
21
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 19

def filename
  data_file_name
end

#format_created_atObject



39
40
41
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 39

def format_created_at
  I18n.l(created_at, :format=>"%d.%m.%Y %H:%M")
end

#geometryObject



70
71
72
73
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 70

def geometry
  @geometry ||= Paperclip::Geometry.from_file(data.to_file)
  @geometry
end

#has_dimensions?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 62

def has_dimensions?
  respond_to?(:width) && respond_to?(:height)
end

#image?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 66

def image?
  Ckeditor::IMAGE_TYPES.include?(data_content_type)
end

#pathObject



31
32
33
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 31

def path
  data.path
end

#public_filenameObject



17
18
19
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 17

def url(*args)
  data.url(*args)
end

#sizeObject



27
28
29
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 27

def size
  data_file_size
end

#stylesObject



35
36
37
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 35

def styles
  data.styles
end

#to_xml(options = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 43

def to_xml(options = {})
  builder = options[:builder] ||= Nokogiri::XML::Builder.new(options)

  builder.send(self.type.to_s.downcase) do |xml|
    xml.id_ self.id
    xml.filename self.filename
    xml.size self.size
    xml.path self.url
    
    xml.styles do
      self.styles.each do |style|
        xml.send(style.first, self.url(style.first))
      end
    end unless self.styles.empty?
  end
  
  builder.to_xml
end

#url(*args) ⇒ Object



14
15
16
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb', line 14

def url(*args)
  data.url(*args)
end