Sha256: 4119423ed07495a82c69046c95f2b859cd4f8c1327abf8e196fff7e18c526c5f

Contents?: true

Size: 1006 Bytes

Versions: 30

Compression:

Stored size: 1006 Bytes

Contents

module Locomotive
  class ContentAssetPresenter < BasePresenter

    ## properties ##

    properties :content_type, :width, :height

    with_options only_getter: true do |presenter|
      presenter.properties :filename, :full_filename, :short_name, :extname, :raw_size
      presenter.properties :vignette_url, :url, :content_type_text
    end

    property :source, only_setter: true

    ## custom getters / setters ##

    def full_filename
      self.__source.source_filename
    end

    def filename
      truncate(self.__source.source_filename, length: 22)
    end

    def short_name
      truncate(self.__source.name, length: 15)
    end

    def extname
      truncate(self.__source.extname, length: 3)
    end

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

    def raw_size
      self.__source.size
    end

    def url
      self.__source.source.url
    end

  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.6 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.6.rc2 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.6.rc1 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.5 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.4 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.3 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.2 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.1 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.0 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.0.rc3 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.0.rc2 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.5.0.rc1 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.4.1 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.4.0 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.3.1 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.3.0 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.2.3 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.2.2 app/presenters/locomotive/content_asset_presenter.rb
locomotive_cms-2.2.1 app/presenters/locomotive/content_asset_presenter.rb