Class: Nanoc::Core::ActionSequence

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actions: []) ⇒ ActionSequence

Returns a new instance of ActionSequence.



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

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

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



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

def actions
  @actions
end

Instance Method Details

#[](idx) ⇒ Object

contract Numeric => C::Maybe



22
23
24
# File 'lib/nanoc/core/action_sequence.rb', line 22

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

#eachObject

contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self



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

def each(&)
  @actions.each(&)
  self
end

#mapObject

contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self



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

def map(&)
  self.class.new(
    actions: @actions.map(&),
  )
end

#pathsObject

contract C::None => Array



32
33
34
# File 'lib/nanoc/core/action_sequence.rb', line 32

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

#serializeObject



36
37
38
# File 'lib/nanoc/core/action_sequence.rb', line 36

def serialize
  serialize_uncached
end

#serialize_uncachedObject

contract C::None => Array



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

def serialize_uncached
  to_a.map(&:serialize)
end

#sizeObject

contract C::None => Numeric



17
18
19
# File 'lib/nanoc/core/action_sequence.rb', line 17

def size
  @actions.size
end

#snapshot_actionsObject

contract C::None => C::ArrayOf



27
28
29
# File 'lib/nanoc/core/action_sequence.rb', line 27

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