Class: Nanoc::Int::ActionSequence
- Inherits:
-
Object
- Object
- Nanoc::Int::ActionSequence
- Includes:
- Enumerable
- Defined in:
- lib/nanoc/base/entities/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.
Class Method Summary collapse
Instance Method Summary collapse
-
#[](idx) ⇒ Object
-
#each ⇒ Object
-
#initialize(item_rep, actions: []) ⇒ ActionSequence
constructor
A new instance of ActionSequence.
-
#map ⇒ Object
-
#paths ⇒ Object
-
#size ⇒ Object
-
#snapshot_actions ⇒ Object
-
#snapshots_defs ⇒ Object
Constructor Details
#initialize(item_rep, actions: []) ⇒ ActionSequence
Returns a new instance of ActionSequence
12 13 14 15 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 12 def initialize(item_rep, actions: []) @item_rep = item_rep @actions = actions end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions
10 11 12 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 10 def actions @actions end |
#item_rep ⇒ Object (readonly)
Returns the value of attribute item_rep
9 10 11 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 9 def item_rep @item_rep end |
Class Method Details
.build(rep) {|builder| ... } ⇒ Object
17 18 19 20 21 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 17 def self.build(rep) builder = Nanoc::Int::ActionSequenceBuilder.new(rep) yield(builder) builder.action_sequence end |
Instance Method Details
#[](idx) ⇒ Object
29 30 31 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 29 def [](idx) @actions[idx] end |
#each ⇒ Object
49 50 51 52 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 49 def each @actions.each { |a| yield(a) } self end |
#map ⇒ Object
55 56 57 58 59 60 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 55 def map self.class.new( @item_rep, actions: @actions.map { |a| yield(a) }, ) end |
#paths ⇒ Object
39 40 41 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 39 def paths snapshot_actions.map { |a| [a.snapshot_names, a.paths] } end |
#size ⇒ Object
24 25 26 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 24 def size @actions.size end |
#snapshot_actions ⇒ Object
34 35 36 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 34 def snapshot_actions @actions.select { |a| a.is_a?(Nanoc::Int::ProcessingActions::Snapshot) } end |
#snapshots_defs ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/nanoc/base/entities/action_sequence.rb', line 62 def snapshots_defs is_binary = @item_rep.item.content.binary? snapshot_defs = [] each do |action| case action when Nanoc::Int::ProcessingActions::Snapshot action.snapshot_names.each do |snapshot_name| snapshot_defs << Nanoc::Int::SnapshotDef.new(snapshot_name, binary: is_binary) end when Nanoc::Int::ProcessingActions::Filter is_binary = Nanoc::Filter.named!(action.filter_name).to_binary? end end snapshot_defs end |