Class: Lucid::AST::StepCollection
- Includes:
- Enumerable
- Defined in:
- lib/lucid/ast/step_collection.rb
Overview
This class holds an array of Step or StepDefinition.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #each(&proc) ⇒ Object
- #exception ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(steps) ⇒ StepCollection
constructor
A new instance of StepCollection.
- #length ⇒ Object
- #max_line_length(feature_element) ⇒ Object
- #passed? ⇒ Boolean
- #status ⇒ Object
- #step_invocations(background = false) ⇒ Object
- #step_invocations_from_cells(cells) ⇒ Object
- #to_sexp ⇒ Object
Constructor Details
#initialize(steps) ⇒ StepCollection
Returns a new instance of StepCollection.
7 8 9 10 |
# File 'lib/lucid/ast/step_collection.rb', line 7 def initialize(steps) @steps = steps @steps.each{|step| step.step_collection = self} end |
Instance Method Details
#accept(visitor) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/lucid/ast/step_collection.rb', line 12 def accept(visitor) visitor.visit_steps(self) do @steps.each do |step| step.accept(visitor) end end end |
#each(&proc) ⇒ Object
32 33 34 |
# File 'lib/lucid/ast/step_collection.rb', line 32 def each(&proc) @steps.each(&proc) end |
#exception ⇒ Object
41 42 43 |
# File 'lib/lucid/ast/step_collection.rb', line 41 def exception @exception ||= ((failed = @steps.detect {|step| step.exception}) && failed.exception) end |
#failed? ⇒ Boolean
45 46 47 |
# File 'lib/lucid/ast/step_collection.rb', line 45 def failed? status == :failed end |
#length ⇒ Object
58 59 60 |
# File 'lib/lucid/ast/step_collection.rb', line 58 def length @steps.length end |
#max_line_length(feature_element) ⇒ Object
36 37 38 39 |
# File 'lib/lucid/ast/step_collection.rb', line 36 def max_line_length(feature_element) lengths = (@steps + [feature_element]).map{|e| e.text_length} lengths.max end |
#passed? ⇒ Boolean
49 50 51 |
# File 'lib/lucid/ast/step_collection.rb', line 49 def passed? status == :passed end |
#status ⇒ Object
53 54 55 56 |
# File 'lib/lucid/ast/step_collection.rb', line 53 def status @steps.each{|step_invocation| return step_invocation.status if step_invocation.status != :passed} :passed end |
#step_invocations(background = false) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/lucid/ast/step_collection.rb', line 20 def step_invocations(background = false) StepInvocations.new(@steps.map{ |step| i = step.step_invocation i.background = background i }) end |
#step_invocations_from_cells(cells) ⇒ Object
28 29 30 |
# File 'lib/lucid/ast/step_collection.rb', line 28 def step_invocations_from_cells(cells) @steps.map{|step| step.step_invocation_from_cells(cells)} end |
#to_sexp ⇒ Object
62 63 64 |
# File 'lib/lucid/ast/step_collection.rb', line 62 def to_sexp @steps.map{|step| step.to_sexp} end |