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

#_id, #ability?, #after_initialize, #errors, #formatted_time, getters_or_setters_to_hash, getters_to_hash, #html_view?, #include_errors?, setters_to_hash, #site, #true

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

#raw_sizeObject



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

def raw_size
  self.__source.size
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



42
43
44
# File 'app/presenters/locomotive/content_asset_presenter.rb', line 42

def url
  self.__source.source.url
end