Class: Nanoc::RuleMemoryCalculator Private
- Inherits:
-
Object
- Object
- Nanoc::RuleMemoryCalculator
- Extended by:
- Memoization
- Defined in:
- lib/nanoc/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)
-
- (Array) [](obj)
private
The caluclated rule memory for the given object.
-
- (RuleMemoryCalculator) initialize(params = {})
constructor
private
A new instance of RuleMemoryCalculator.
Methods included from Memoization
Constructor Details
- (RuleMemoryCalculator) initialize(params = {})
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
13 14 15 16 17 |
# File 'lib/nanoc/base/compilation/rule_memory_calculator.rb', line 13 def initialize(params = {}) @rules_collection = params.fetch(:rules_collection) do raise ArgumentError, 'Required :rules_collection option is missing' end end |
Instance Method Details
- (Array) [](obj)
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
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nanoc/base/compilation/rule_memory_calculator.rb', line 22 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 "Do not know how to calculate the rule memory for #{obj.inspect}" end result end |