Class: Nanoc::Int::RuleMemory Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable, ContractsSupport
Defined in:
lib/nanoc/base/entities/rule_memory.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

Methods included from ContractsSupport

included

Constructor Details

#initialize(item_rep) ⇒ RuleMemory

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 RuleMemory.



6
7
8
9
# File 'lib/nanoc/base/entities/rule_memory.rb', line 6

def initialize(item_rep)
  @item_rep = item_rep
  @actions = []
end

Instance Method Details

#[](idx) ⇒ Object

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.



17
18
19
# File 'lib/nanoc/base/entities/rule_memory.rb', line 17

def [](idx)
  @actions[idx]
end

#add_filter(filter_name, params) ⇒ Object

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.



22
23
24
25
# File 'lib/nanoc/base/entities/rule_memory.rb', line 22

def add_filter(filter_name, params)
  @actions << Nanoc::Int::RuleMemoryActions::Filter.new(filter_name, params)
  self
end

#add_layout(layout_identifier, params) ⇒ Object

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.



28
29
30
31
# File 'lib/nanoc/base/entities/rule_memory.rb', line 28

def add_layout(layout_identifier, params)
  @actions << Nanoc::Int::RuleMemoryActions::Layout.new(layout_identifier, params)
  self
end

#add_snapshot(snapshot_name, final, path) ⇒ Object

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.



34
35
36
37
38
# File 'lib/nanoc/base/entities/rule_memory.rb', line 34

def add_snapshot(snapshot_name, final, path)
  will_add_snapshot(snapshot_name) if final
  @actions << Nanoc::Int::RuleMemoryActions::Snapshot.new(snapshot_name, final, path)
  self
end

#any_layouts?Boolean

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:

  • (Boolean)


46
47
48
# File 'lib/nanoc/base/entities/rule_memory.rb', line 46

def any_layouts?
  @actions.any? { |a| a.is_a?(Nanoc::Int::RuleMemoryActions::Layout) }
end

#eachObject

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.



56
57
58
59
# File 'lib/nanoc/base/entities/rule_memory.rb', line 56

def each
  @actions.each { |a| yield(a) }
  self
end

#serializeObject

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.

TODO: Add contract



51
52
53
# File 'lib/nanoc/base/entities/rule_memory.rb', line 51

def serialize
  map(&:serialize)
end

#sizeObject

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.



12
13
14
# File 'lib/nanoc/base/entities/rule_memory.rb', line 12

def size
  @actions.size
end

#snapshot_actionsObject

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.



41
42
43
# File 'lib/nanoc/base/entities/rule_memory.rb', line 41

def snapshot_actions
  @actions.select { |a| a.is_a?(Nanoc::Int::RuleMemoryActions::Snapshot) }
end