Class: Newsletter::Field::InlineAsset::Value
- Inherits:
-
Object
- Object
- Newsletter::Field::InlineAsset::Value
- Defined in:
- app/models/newsletter/field/inline_asset.rb
Overview
create nicer accessors for use in design since this is more than one value, unlike other fields
Instance Attribute Summary collapse
-
#asset ⇒ Object
Returns the value of attribute asset.
-
#asset_id ⇒ Object
Returns the value of attribute asset_id.
-
#text ⇒ Object
Returns the value of attribute text.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(params) ⇒ Value
constructor
A new instance of Value.
- #is_image? ⇒ Boolean
- #is_image_by_extension? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Value
Returns a new instance of Value.
71 72 73 74 75 76 |
# File 'app/models/newsletter/field/inline_asset.rb', line 71 def initialize(params) @url = params[:url] @text = params[:text] @asset = params[:asset] @asset_id = @asset.nil? ? nil : @asset.id end |
Instance Attribute Details
#asset ⇒ Object
Returns the value of attribute asset.
55 56 57 |
# File 'app/models/newsletter/field/inline_asset.rb', line 55 def asset @asset end |
#asset_id ⇒ Object
Returns the value of attribute asset_id.
55 56 57 |
# File 'app/models/newsletter/field/inline_asset.rb', line 55 def asset_id @asset_id end |
#text ⇒ Object
Returns the value of attribute text.
55 56 57 |
# File 'app/models/newsletter/field/inline_asset.rb', line 55 def text @text end |
#url ⇒ Object
Returns the value of attribute url.
55 56 57 |
# File 'app/models/newsletter/field/inline_asset.rb', line 55 def url @url end |
Instance Method Details
#is_image? ⇒ Boolean
56 57 58 59 60 61 62 |
# File 'app/models/newsletter/field/inline_asset.rb', line 56 def is_image? if asset.present? asset.is_image? else is_image_by_extension? end end |
#is_image_by_extension? ⇒ Boolean
64 65 66 67 68 69 |
# File 'app/models/newsletter/field/inline_asset.rb', line 64 def is_image_by_extension? extension = File.extname(url).gsub(/^\./,'') [ 'bmp', 'cod', 'gif', 'ief', 'jpe', 'jpeg', 'jpg', 'png', 'jfif', 'svg', 'tif', 'tiff' ].include?(extension.downcase) end |