Class: Nanoc3::RuleMemoryCalculator Private
- Inherits:
-
Object
- Object
- Nanoc3::RuleMemoryCalculator
- Extended by:
- Memoization
- Defined in:
- lib/nanoc3/base/compilation/rule_memory_calculator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Calculates rule memories for objects that can be run through a rule (item representations and layouts).
Instance Method Summary collapse
-
#[](obj) ⇒ Array
private
The caluclated rule memory for the given object.
-
#initialize(params = {}) ⇒ RuleMemoryCalculator
constructor
private
A new instance of RuleMemoryCalculator.
Methods included from Memoization
Constructor Details
#initialize(params = {}) ⇒ RuleMemoryCalculator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RuleMemoryCalculator.
15 16 17 18 |
# File 'lib/nanoc3/base/compilation/rule_memory_calculator.rb', line 15 def initialize(params={}) @rules_collection = params[:rules_collection] or raise ArgumentError, "Required :rules_collection option is missing" end |
Instance Method Details
#[](obj) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The caluclated rule memory for the given object.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nanoc3/base/compilation/rule_memory_calculator.rb', line 23 def [](obj) result = case obj.type when :item_rep @rules_collection.new_rule_memory_for_rep(obj) when :layout @rules_collection.new_rule_memory_for_layout(obj) else raise RuntimeError, "Do not know how to calculate the rule memory for #{obj.inspect}" end result end |