Class: Rack::Tipi::Asset
- Inherits:
-
Object
- Object
- Rack::Tipi::Asset
- Defined in:
- lib/rack/tipi/asset.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #content ⇒ Object
-
#initialize(namespace, path, route) ⇒ Asset
constructor
A new instance of Asset.
- #mime_type ⇒ Object
- #route ⇒ Object
Constructor Details
#initialize(namespace, path, route) ⇒ Asset
Returns a new instance of Asset.
8 9 10 11 12 |
# File 'lib/rack/tipi/asset.rb', line 8 def initialize(namespace, path, route) @namespace = namespace @path = Pathname.new(path). @route = route.sub(/\//, '') end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/rack/tipi/asset.rb', line 6 def namespace @namespace end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/rack/tipi/asset.rb', line 6 def path @path end |
Instance Method Details
#==(other) ⇒ Object
14 15 16 |
# File 'lib/rack/tipi/asset.rb', line 14 def ==(other) route == other.route if other.respond_to? :route end |
#content ⇒ Object
18 19 20 |
# File 'lib/rack/tipi/asset.rb', line 18 def content path.read end |
#mime_type ⇒ Object
22 23 24 |
# File 'lib/rack/tipi/asset.rb', line 22 def mime_type Rack::Mime.mime_type(path.extname) end |
#route ⇒ Object
26 27 28 |
# File 'lib/rack/tipi/asset.rb', line 26 def route "/#{namespace}/#{@route}" end |