Class: Tenon::Asset
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- 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
31 32 33 |
# File 'app/models/tenon/asset.rb', line 31 def self.documents where('attachment_content_type NOT LIKE ?', '%image%') end |
.with_type(type) ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/models/tenon/asset.rb', line 23 def self.with_type(type) if %w(images).include?(type) where('attachment_content_type LIKE ?', "%#{type.singularize}%") else documents end end |
Instance Method Details
#cropping? ⇒ Boolean
45 46 47 |
# File 'app/models/tenon/asset.rb', line 45 def cropping? crop_x.present? end |
#dimensions(style = :original) ⇒ Object
39 40 41 42 43 |
# File 'app/models/tenon/asset.rb', line 39 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
35 36 37 |
# File 'app/models/tenon/asset.rb', line 35 def is_image? =~ /image/ end |