Class: Hulk::Bundle
- Inherits:
-
Object
- Object
- Hulk::Bundle
- Defined in:
- lib/hulk/bundle.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #<<(val) ⇒ Object
- #compile! ⇒ Object
- #compiled? ⇒ Boolean
- #digest ⇒ Object
- #filename ⇒ Object
-
#initialize(name) ⇒ Bundle
constructor
A new instance of Bundle.
Constructor Details
#initialize(name) ⇒ Bundle
Returns a new instance of Bundle.
8 9 10 11 12 |
# File 'lib/hulk/bundle.rb', line 8 def initialize(name) @name = name.to_s @raw = [] @compiled = nil end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/hulk/bundle.rb', line 6 def name @name end |
Instance Method Details
#<<(val) ⇒ Object
14 15 16 17 |
# File 'lib/hulk/bundle.rb', line 14 def <<(val) (@raw << val) and return unless compiled? raise Hulk::FrozenBundleError.new("This bundle has already been compiled.") end |
#compile! ⇒ Object
28 29 30 |
# File 'lib/hulk/bundle.rb', line 28 def compile! @compiled ||= generate_compiled(@raw.join) end |
#compiled? ⇒ Boolean
19 20 21 |
# File 'lib/hulk/bundle.rb', line 19 def compiled? !@compiled.nil? end |
#digest ⇒ Object
23 24 25 26 |
# File 'lib/hulk/bundle.rb', line 23 def digest return nil unless compiled? @digest ||= Digest::MD5.hexdigest(compile!) end |
#filename ⇒ Object
32 33 34 |
# File 'lib/hulk/bundle.rb', line 32 def filename "#{digest}-#{name}.#{ext}" end |