Class: RedMatter::Loader
- Inherits:
-
Object
- Object
- RedMatter::Loader
- Defined in:
- lib/red_matter/loader.rb
Overview
Loader - processes Redfile / config block
Instance Attribute Summary collapse
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#asset(name, &block) ⇒ RedMatter::Loader
Adds asset node.
-
#initialize ⇒ Loader
constructor
A new instance of Loader.
-
#load(dat, &block) ⇒ RedMatter::Loader
Loads given code from string (‘dat` parameter) or yielded block.
Constructor Details
#initialize ⇒ Loader
Returns a new instance of Loader.
8 9 10 11 12 |
# File 'lib/red_matter/loader.rb', line 8 def initialize @assets = {} @verbose = false @total = 0.0 end |
Instance Attribute Details
#verbose ⇒ Object
Returns the value of attribute verbose.
6 7 8 |
# File 'lib/red_matter/loader.rb', line 6 def verbose @verbose end |
Instance Method Details
#asset(name, &block) ⇒ RedMatter::Loader
Adds asset node
40 41 42 43 44 |
# File 'lib/red_matter/loader.rb', line 40 def asset(name, &block) @assets[name] = RedMatter::Asset.new(&block) @assets[name].name = name self end |
#load(dat, &block) ⇒ RedMatter::Loader
Loads given code from string (‘dat` parameter) or yielded block
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/red_matter/loader.rb', line 18 def load(dat, &block) if block instance_exec(&block) else instance_eval(dat, nil, 'Redfile') end @assets.each_pair do |name, asset| t1 = Time.now.to_f asset.process t2 = Time.now.to_f took = t2 - t1 @total += took puts "`#{name}`: #{took.truncate(6)} seconds" if @verbose end puts "Total: #{@total.truncate(6)} seconds" if @verbose self end |