Class: Nanoc::Core::ActionSequence
- Inherits:
-
Object
- Object
- Nanoc::Core::ActionSequence
- Includes:
- Enumerable, MemoWise
- Defined in:
- lib/nanoc/core/action_sequence.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#item_rep ⇒ Object
readonly
Returns the value of attribute item_rep.
Instance Method Summary collapse
-
#[](idx) ⇒ Object
contract Numeric => C::Maybe.
-
#each ⇒ Object
contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self.
-
#initialize(item_rep, actions: []) ⇒ ActionSequence
constructor
A new instance of ActionSequence.
-
#map ⇒ Object
contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self.
-
#paths ⇒ Object
contract C::None => Array.
- #serialize ⇒ Object
-
#serialize_uncached ⇒ Object
contract C::None => Array.
-
#size ⇒ Object
contract C::None => Numeric.
-
#snapshot_actions ⇒ Object
contract C::None => C::ArrayOf.
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
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
11 12 13 |
# File 'lib/nanoc/core/action_sequence.rb', line 11 def actions @actions end |
#item_rep ⇒ Object (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
contract Numeric => C::Maybe
24 25 26 |
# File 'lib/nanoc/core/action_sequence.rb', line 24 def [](idx) @actions[idx] end |
#each ⇒ Object
contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self
49 50 51 52 |
# File 'lib/nanoc/core/action_sequence.rb', line 49 def each @actions.each { |a| yield(a) } self end |
#map ⇒ Object
contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self
55 56 57 58 59 60 |
# File 'lib/nanoc/core/action_sequence.rb', line 55 def map self.class.new( @item_rep, actions: @actions.map { |a| yield(a) }, ) end |
#paths ⇒ Object
contract C::None => Array
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 ⇒ Object
38 39 40 |
# File 'lib/nanoc/core/action_sequence.rb', line 38 def serialize serialize_uncached end |
#serialize_uncached ⇒ Object
contract C::None => Array
44 45 46 |
# File 'lib/nanoc/core/action_sequence.rb', line 44 def serialize_uncached to_a.map(&:serialize) end |
#size ⇒ Object
contract C::None => Numeric
19 20 21 |
# File 'lib/nanoc/core/action_sequence.rb', line 19 def size @actions.size end |
#snapshot_actions ⇒ Object
contract C::None => C::ArrayOf
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 |