Class: Nanoc::RuleDSL::CompilationRuleContext Private
- Inherits:
-
RuleContext
- Object
- Core::Context
- RuleContext
- Nanoc::RuleDSL::CompilationRuleContext
- Includes:
- Core::ContractsSupport
- Defined in:
- lib/nanoc/rule_dsl/compilation_rule_context.rb
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.
Instance Method Summary collapse
-
#filter(filter_name, filter_args = {}) ⇒ void
private
Filters the current representation (calls Core::ItemRep#filter with the given arguments on the rep).
-
#initialize(rep:, site:, recorder:, view_context:) ⇒ CompilationRuleContext
constructor
private
A new instance of CompilationRuleContext.
-
#layout(layout_identifier, extra_filter_args = nil) ⇒ void
private
Layouts the current representation (calls Core::ItemRep#layout with the given arguments on the rep).
-
#snapshot(snapshot_name, path: Nanoc::Core::UNDEFINED) ⇒ void
private
Creates a snapshot of the current compiled item content.
-
#write(arg) ⇒ void
private
Creates a snapshot named :last the current compiled item content, with the given path.
Constructor Details
#initialize(rep:, site:, recorder:, view_context:) ⇒ CompilationRuleContext
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 CompilationRuleContext.
13 14 15 16 17 |
# File 'lib/nanoc/rule_dsl/compilation_rule_context.rb', line 13 def initialize(rep:, site:, recorder:, view_context:) @_recorder = recorder super(rep:, site:, view_context:) end |
Instance Method Details
#filter(filter_name, filter_args = {}) ⇒ void
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.
This method returns an undefined value.
Filters the current representation (calls Core::ItemRep#filter with the given arguments on the rep).
31 32 33 |
# File 'lib/nanoc/rule_dsl/compilation_rule_context.rb', line 31 def filter(filter_name, filter_args = {}) @_recorder.filter(filter_name, filter_args) end |
#layout(layout_identifier, extra_filter_args = nil) ⇒ void
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.
This method returns an undefined value.
Layouts the current representation (calls Core::ItemRep#layout with the given arguments on the rep).
44 45 46 |
# File 'lib/nanoc/rule_dsl/compilation_rule_context.rb', line 44 def layout(layout_identifier, extra_filter_args = nil) @_recorder.layout(layout_identifier, extra_filter_args) end |
#snapshot(snapshot_name, path: Nanoc::Core::UNDEFINED) ⇒ void
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.
This method returns an undefined value.
Creates a snapshot of the current compiled item content. Calls Core::ItemRep#snapshot with the given arguments on the rep.
58 59 60 |
# File 'lib/nanoc/rule_dsl/compilation_rule_context.rb', line 58 def snapshot(snapshot_name, path: Nanoc::Core::UNDEFINED) @_recorder.snapshot(snapshot_name, path:) end |
#write(arg) ⇒ void
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.
This method returns an undefined value.
Creates a snapshot named :last the current compiled item content, with the given path. This is a convenience method for #snapshot.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/nanoc/rule_dsl/compilation_rule_context.rb', line 70 def write(arg) @_write_snapshot_counter ||= 0 snapshot_name = :"_#{@_write_snapshot_counter}" @_write_snapshot_counter += 1 case arg when String, Nanoc::Core::Identifier, nil snapshot(snapshot_name, path: arg) when Hash if arg.key?(:ext) ext = arg[:ext].sub(/\A\./, '') path = @item.identifier.without_exts + '.' + ext snapshot(snapshot_name, path:) else raise ArgumentError, 'Cannot call #write this way (need path or :ext)' end else raise ArgumentError, 'Cannot call #write this way (need path or :ext)' end end |