Class: Locomotive::ContentAssetPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/locomotive/content_asset_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#ability, #depth

Instance Method Summary collapse

Methods inherited from BasePresenter

#ability?, #after_initialize, getters_to_hash, #id, setters_to_hash, #site

Methods included from Presentable

#after_initialize, #as_json, #attributes=, #getters, #initialize, #property_options, #setters

Instance Method Details

#content_typeObject

properties ##



6
# File 'app/presenters/locomotive/content_asset_presenter.rb', line 6

properties :content_type, :width, :height

#content_type_textObject



33
34
35
36
# File 'app/presenters/locomotive/content_asset_presenter.rb', line 33

def content_type_text
  value = self.source.content_type.to_s == 'other' ? self.extname : self.source.content_type
  value.blank? ? '?' : value
end

#extnameObject



29
30
31
# File 'app/presenters/locomotive/content_asset_presenter.rb', line 29

def extname
  truncate(self.source.extname, :length => 3)
end

#filenameObject



21
22
23
# File 'app/presenters/locomotive/content_asset_presenter.rb', line 21

def filename
  truncate(self.source.source_filename, :length => 22)
end

#full_filenameObject

custom getters / setters ##



17
18
19
# File 'app/presenters/locomotive/content_asset_presenter.rb', line 17

def full_filename
  self.source.source_filename
end

#short_nameObject



25
26
27
# File 'app/presenters/locomotive/content_asset_presenter.rb', line 25

def short_name
  truncate(self.source.name, :length => 15)
end

#urlObject



38
39
40
# File 'app/presenters/locomotive/content_asset_presenter.rb', line 38

def url
  self.source.source.url
end