Class: Broadway::Asset
- Inherits:
-
Object
- Object
- Broadway::Asset
- Includes:
- Configurable, Readable, Resourceful, Sortable, Taggable, Comparable
- Defined in:
- lib/broadway/resources/asset.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#height ⇒ Object
Returns the value of attribute height.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
(also: #url, #href, #src)
Returns the value of attribute path.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#site ⇒ Object
Returns the value of attribute site.
-
#thumb ⇒ Object
Returns the value of attribute thumb.
-
#title ⇒ Object
Returns the value of attribute title.
-
#tooltip ⇒ Object
Returns the value of attribute tooltip.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #extension ⇒ Object
-
#initialize(resource, name, options = {}) ⇒ Asset
constructor
A new instance of Asset.
Methods included from Configurable
Methods included from Taggable
Methods included from Sortable
Methods included from Readable
Methods included from Resourceful
Constructor Details
#initialize(resource, name, options = {}) ⇒ Asset
Returns a new instance of Asset.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/broadway/resources/asset.rb', line 12 def initialize(resource, name, = {}) self.resource = resource self.name = name self.data = self.path = .delete(:path) || .delete(:src) || .delete(:url) || .delete(:href) .each do |k,v| self.send("#{k}=", v) if self.respond_to?(k) end self.title ||= Broadway::File.file_name(self.path).titleize end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def content_type @content_type end |
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def height @height end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def name @name end |
#path ⇒ Object Also known as: url, href, src
Returns the value of attribute path.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def path @path end |
#resource ⇒ Object
Returns the value of attribute resource.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def resource @resource end |
#site ⇒ Object
Returns the value of attribute site.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def site @site end |
#thumb ⇒ Object
Returns the value of attribute thumb.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def thumb @thumb end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def title @title end |
#tooltip ⇒ Object
Returns the value of attribute tooltip.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def tooltip @tooltip end |
#width ⇒ Object
Returns the value of attribute width.
3 4 5 |
# File 'lib/broadway/resources/asset.rb', line 3 def width @width end |
Instance Method Details
#extension ⇒ Object
32 33 34 |
# File 'lib/broadway/resources/asset.rb', line 32 def extension ::File.extname(self.path).split(".").last end |