Class: Nanoc::Int::RuleMemory

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nanoc/base/entities/rule_memory.rb

Instance Method Summary collapse

Constructor Details

#initialize(item_rep) ⇒ RuleMemory

Returns a new instance of RuleMemory



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

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

Instance Method Details

#[](idx) ⇒ Object



14
15
16
# File 'lib/nanoc/base/entities/rule_memory.rb', line 14

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

#add_filter(filter_name, params) ⇒ Object



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

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

#add_layout(layout_identifier, params) ⇒ Object



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

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

#add_snapshot(snapshot_name, final, path) ⇒ Object



26
27
28
29
# File 'lib/nanoc/base/entities/rule_memory.rb', line 26

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

#any_layouts?Boolean

Returns:

  • (Boolean)


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

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

#eachObject



43
44
45
# File 'lib/nanoc/base/entities/rule_memory.rb', line 43

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

#serializeObject



39
40
41
# File 'lib/nanoc/base/entities/rule_memory.rb', line 39

def serialize
  map(&:serialize)
end

#sizeObject



10
11
12
# File 'lib/nanoc/base/entities/rule_memory.rb', line 10

def size
  @actions.size
end

#snapshot_actionsObject



31
32
33
# File 'lib/nanoc/base/entities/rule_memory.rb', line 31

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