Class: Nanoc::Core::ActionSequence

Inherits:
Object
  • Object
show all
Includes:
Enumerable, ContractsSupport
Defined in:
lib/nanoc/core/action_sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

#initialize(item_rep, actions: []) ⇒ ActionSequence

Returns a new instance of ActionSequence.



13
14
15
16
# File 'lib/nanoc/core/action_sequence.rb', line 13

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

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



11
12
13
# File 'lib/nanoc/core/action_sequence.rb', line 11

def actions
  @actions
end

#item_repObject (readonly)

Returns the value of attribute item_rep.



10
11
12
# File 'lib/nanoc/core/action_sequence.rb', line 10

def item_rep
  @item_rep
end

Instance Method Details

#[](idx) ⇒ Object



24
25
26
# File 'lib/nanoc/core/action_sequence.rb', line 24

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

#eachObject



48
49
50
51
# File 'lib/nanoc/core/action_sequence.rb', line 48

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

#mapObject



54
55
56
57
58
59
# File 'lib/nanoc/core/action_sequence.rb', line 54

def map
  self.class.new(
    @item_rep,
    actions: @actions.map { |a| yield(a) },
  )
end

#pathsObject



34
35
36
# File 'lib/nanoc/core/action_sequence.rb', line 34

def paths
  snapshot_actions.map { |a| [a.snapshot_names, a.paths] }
end

#serialize_uncachedObject



43
44
45
# File 'lib/nanoc/core/action_sequence.rb', line 43

def serialize_uncached
  to_a.map(&:serialize)
end

#sizeObject



19
20
21
# File 'lib/nanoc/core/action_sequence.rb', line 19

def size
  @actions.size
end

#snapshot_actionsObject



29
30
31
# File 'lib/nanoc/core/action_sequence.rb', line 29

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