Class: AssetLibrary::Asset
- Inherits:
-
Object
- Object
- AssetLibrary::Asset
- Defined in:
- lib/asset_library/asset.rb
Instance Attribute Summary collapse
-
#absolute_path ⇒ Object
readonly
Returns the value of attribute absolute_path.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(absolute_path) ⇒ Asset
constructor
A new instance of Asset.
- #relative_path ⇒ Object
- #relative_url ⇒ Object
- #timestamp ⇒ Object
Constructor Details
#initialize(absolute_path) ⇒ Asset
Returns a new instance of Asset.
5 6 7 |
# File 'lib/asset_library/asset.rb', line 5 def initialize(absolute_path) @absolute_path = absolute_path end |
Instance Attribute Details
#absolute_path ⇒ Object (readonly)
Returns the value of attribute absolute_path.
3 4 5 |
# File 'lib/asset_library/asset.rb', line 3 def absolute_path @absolute_path end |
Instance Method Details
#eql?(other) ⇒ Boolean
9 10 11 |
# File 'lib/asset_library/asset.rb', line 9 def eql?(other) self.class === other && absolute_path == other.absolute_path end |
#hash ⇒ Object
13 14 15 |
# File 'lib/asset_library/asset.rb', line 13 def hash self.absolute_path.hash end |
#relative_path ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/asset_library/asset.rb', line 17 def relative_path if AssetLibrary.root == '/' absolute_path else absolute_path[AssetLibrary.root.length..-1] end end |
#relative_url ⇒ Object
31 32 33 |
# File 'lib/asset_library/asset.rb', line 31 def relative_url "#{relative_path}?#{.to_i.to_s}" end |
#timestamp ⇒ Object
25 26 27 28 29 |
# File 'lib/asset_library/asset.rb', line 25 def File.mtime(absolute_path) rescue Errno::ENOENT nil end |