Class: Tenon::Asset
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Tenon::Asset
- Defined in:
- app/models/tenon/asset.rb
Instance Attribute Summary collapse
-
#crop_h ⇒ Object
Returns the value of attribute crop_h.
-
#crop_w ⇒ Object
Returns the value of attribute crop_w.
-
#crop_x ⇒ Object
Returns the value of attribute crop_x.
-
#crop_y ⇒ Object
Returns the value of attribute crop_y.
-
#duplicate ⇒ Object
Returns the value of attribute duplicate.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#crop_h ⇒ Object
Returns the value of attribute crop_h.
3 4 5 |
# File 'app/models/tenon/asset.rb', line 3 def crop_h @crop_h end |
#crop_w ⇒ Object
Returns the value of attribute crop_w.
3 4 5 |
# File 'app/models/tenon/asset.rb', line 3 def crop_w @crop_w end |
#crop_x ⇒ Object
Returns the value of attribute crop_x.
3 4 5 |
# File 'app/models/tenon/asset.rb', line 3 def crop_x @crop_x end |
#crop_y ⇒ Object
Returns the value of attribute crop_y.
3 4 5 |
# File 'app/models/tenon/asset.rb', line 3 def crop_y @crop_y end |
#duplicate ⇒ Object
Returns the value of attribute duplicate.
3 4 5 |
# File 'app/models/tenon/asset.rb', line 3 def duplicate @duplicate end |
Class Method Details
.documents ⇒ Object
33 34 35 36 |
# File 'app/models/tenon/asset.rb', line 33 def self.documents where('attachment_content_type NOT LIKE ?', '%image%') .where('attachment_content_type NOT LIKE ?', '%video%') end |
.with_type(type) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/models/tenon/asset.rb', line 25 def self.with_type(type) if %w(images videos).include?(type) where('attachment_content_type LIKE ?', "%#{type.singularize}%") else documents end end |
Instance Method Details
#cropping? ⇒ Boolean
48 49 50 |
# File 'app/models/tenon/asset.rb', line 48 def cropping? crop_x.present? end |
#dimensions(style = :original) ⇒ Object
42 43 44 45 46 |
# File 'app/models/tenon/asset.rb', line 42 def dimensions(style = :original) attach = style.to_sym == :original ? : .styles[style] file = Paperclip.io_adapters.for(attach) Paperclip::Geometry.from_file(file).to_s.split('x') end |
#is_image? ⇒ Boolean
38 39 40 |
# File 'app/models/tenon/asset.rb', line 38 def is_image? =~ /image/ end |