Class: Rack::Bundle::Base
- Inherits:
-
Object
- Object
- Rack::Bundle::Base
- Defined in:
- lib/rack/bundle/bundles/base.rb
Class Attribute Summary collapse
-
.extension ⇒ Object
Returns the value of attribute extension.
-
.joiner ⇒ Object
Returns the value of attribute joiner.
-
.mime_type ⇒ Object
Returns the value of attribute mime_type.
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#files ⇒ Object
Returns the value of attribute files.
Class Method Summary collapse
Instance Method Summary collapse
- #==(bundle) ⇒ Object
- #extension ⇒ Object
- #hash ⇒ Object
-
#initialize(*files) ⇒ Base
constructor
A new instance of Base.
- #joiner ⇒ Object
- #mime_type ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(*files) ⇒ Base
Returns a new instance of Base.
13 14 15 |
# File 'lib/rack/bundle/bundles/base.rb', line 13 def initialize *files @files = files end |
Class Attribute Details
.extension ⇒ Object
Returns the value of attribute extension.
4 5 6 |
# File 'lib/rack/bundle/bundles/base.rb', line 4 def extension @extension end |
.joiner ⇒ Object
Returns the value of attribute joiner.
4 5 6 |
# File 'lib/rack/bundle/bundles/base.rb', line 4 def joiner @joiner end |
.mime_type ⇒ Object
Returns the value of attribute mime_type.
4 5 6 |
# File 'lib/rack/bundle/bundles/base.rb', line 4 def mime_type @mime_type end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
5 6 7 |
# File 'lib/rack/bundle/bundles/base.rb', line 5 def contents @contents end |
#files ⇒ Object
Returns the value of attribute files.
5 6 7 |
# File 'lib/rack/bundle/bundles/base.rb', line 5 def files @files end |
Class Method Details
.new_from_contents(contents) ⇒ Object
7 8 9 10 11 |
# File 'lib/rack/bundle/bundles/base.rb', line 7 def self.new_from_contents contents instance = new instance.contents = contents instance end |
Instance Method Details
#==(bundle) ⇒ Object
41 42 43 |
# File 'lib/rack/bundle/bundles/base.rb', line 41 def == bundle self.class == bundle.class && hash == bundle.hash end |
#extension ⇒ Object
29 30 31 |
# File 'lib/rack/bundle/bundles/base.rb', line 29 def extension self.class.extension end |
#hash ⇒ Object
21 22 23 |
# File 'lib/rack/bundle/bundles/base.rb', line 21 def hash @hash ||= MD5.new(@files.map { |file| File.basename(file.path) + File.mtime(file.path).to_s }.join).to_s end |
#joiner ⇒ Object
33 34 35 |
# File 'lib/rack/bundle/bundles/base.rb', line 33 def joiner self.class.joiner end |
#mime_type ⇒ Object
37 38 39 |
# File 'lib/rack/bundle/bundles/base.rb', line 37 def mime_type self.class.mime_type end |
#path ⇒ Object
25 26 27 |
# File 'lib/rack/bundle/bundles/base.rb', line 25 def path "/rack-bundle-#{hash}.#{extension}" end |