Class: Broadway::Asset

Inherits:
Object
  • Object
show all
Includes:
Configurable, Readable, Resourceful, Sortable, Taggable, Comparable
Defined in:
lib/broadway/resources/asset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

included

Methods included from Taggable

included

Methods included from Sortable

included

Methods included from Readable

included

Methods included from Resourceful

included

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, options = {})
  self.resource = resource
  self.name     = name
  self.data     = options
  self.path     = options.delete(:path) || options.delete(:src) || options.delete(:url) || options.delete(:href)
  options.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_typeObject

Returns the value of attribute content_type.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def content_type
  @content_type
end

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def height
  @height
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def name
  @name
end

#pathObject 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

#resourceObject

Returns the value of attribute resource.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def resource
  @resource
end

#siteObject

Returns the value of attribute site.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def site
  @site
end

#thumbObject

Returns the value of attribute thumb.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def thumb
  @thumb
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def title
  @title
end

#tooltipObject

Returns the value of attribute tooltip.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def tooltip
  @tooltip
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/broadway/resources/asset.rb', line 3

def width
  @width
end

Instance Method Details

#extensionObject



32
33
34
# File 'lib/broadway/resources/asset.rb', line 32

def extension
  ::File.extname(self.path).split(".").last
end