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



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



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

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

#add_filter(filter_name, params) ⇒ Object



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



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



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

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



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

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

#serializeObject

TODO: Add contract



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

def serialize
  map(&:serialize)
end

#sizeObject



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

def size
  @actions.size
end

#snapshot_actionsObject



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