Class: OrangeAsset
- Inherits:
-
Orange::Carton
- Object
- Orange::Carton
- OrangeAsset
- Defined in:
- lib/orange-more/assets/cartons/asset_carton.rb
Instance Method Summary collapse
- #file? ⇒ Boolean
- #file_path ⇒ Object
- #image? ⇒ Boolean
- #pdf? ⇒ Boolean
- #to_asset_tag(alt = "") ⇒ Object
- #to_s ⇒ Object
Methods inherited from Orange::Carton
Instance Method Details
#file? ⇒ Boolean
35 36 37 |
# File 'lib/orange-more/assets/cartons/asset_carton.rb', line 35 def file? !(pdf? || image?) end |
#file_path ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/orange-more/assets/cartons/asset_carton.rb', line 15 def file_path if(s3_bucket) "http://s3.amazonaws.com/#{s3_bucket}/#{path}" else File.join('', 'assets', 'uploaded', path) end end |
#image? ⇒ Boolean
32 33 34 |
# File 'lib/orange-more/assets/cartons/asset_carton.rb', line 32 def image? mime_type =~ /^image/ end |
#pdf? ⇒ Boolean
29 30 31 |
# File 'lib/orange-more/assets/cartons/asset_carton.rb', line 29 def pdf? mime_type =~ /^application\/pdf/ end |
#to_asset_tag(alt = "") ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/orange-more/assets/cartons/asset_carton.rb', line 39 def to_asset_tag(alt = "") alt = alt.blank? ? : alt alt = alt.blank? ? name : alt case mime_type when /^image/ "<img src='#{file_path}' border='0' alt='#{alt}' />" when /^application\/pdf/ "<span class='pdf_link'><a href='#{file_path}'>#{alt}</a></span>" else "<span class='file_link'><a href='#{file_path}'>#{alt}</a></span>" end end |
#to_s ⇒ Object
23 24 25 26 27 |
# File 'lib/orange-more/assets/cartons/asset_carton.rb', line 23 def to_s <<-DOC {"id": #{self.id}, "name": "#{self.name}", "caption": "#{self.}", "html": "#{self.to_asset_tag}"} DOC end |