Class: Lucid::AST::StepInvocations
- Includes:
- Enumerable
- Defined in:
- lib/lucid/ast/step_invocations.rb
Instance Method Summary collapse
- #+(step_invocations) ⇒ Object
- #accept(visitor) ⇒ Object
-
#dup(step_invocations = []) ⇒ Object
Duplicates this instance and adds
step_invocations
to the end. - #each(&proc) ⇒ Object
- #exception ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(steps) ⇒ StepInvocations
constructor
A new instance of StepInvocations.
- #length ⇒ Object
- #max_line_length(feature_element) ⇒ Object
- #previous_step(step) ⇒ Object
- #skip_invoke! ⇒ Object
- #status ⇒ Object
- #to_sexp ⇒ Object
Constructor Details
#initialize(steps) ⇒ StepInvocations
Returns a new instance of StepInvocations.
6 7 8 9 10 11 |
# File 'lib/lucid/ast/step_invocations.rb', line 6 def initialize(steps) @steps = steps @steps.each do |step| step.step_collection = self end end |
Instance Method Details
#+(step_invocations) ⇒ Object
34 35 36 |
# File 'lib/lucid/ast/step_invocations.rb', line 34 def +(step_invocations) dup(step_invocations) end |
#accept(visitor) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/lucid/ast/step_invocations.rb', line 13 def accept(visitor) visitor.visit_steps(self) do @steps.each do |step| step.accept(visitor) end end end |
#dup(step_invocations = []) ⇒ Object
Duplicates this instance and adds step_invocations
to the end
39 40 41 |
# File 'lib/lucid/ast/step_invocations.rb', line 39 def dup(step_invocations = []) StepInvocations.new(@steps + step_invocations) end |
#each(&proc) ⇒ Object
21 22 23 |
# File 'lib/lucid/ast/step_invocations.rb', line 21 def each(&proc) @steps.each(&proc) end |
#exception ⇒ Object
43 44 45 |
# File 'lib/lucid/ast/step_invocations.rb', line 43 def exception @exception ||= ((failed = @steps.detect {|step| step.exception}) && failed.exception) end |
#failed? ⇒ Boolean
54 55 56 |
# File 'lib/lucid/ast/step_invocations.rb', line 54 def failed? status == :failed end |
#length ⇒ Object
63 64 65 |
# File 'lib/lucid/ast/step_invocations.rb', line 63 def length @steps.length end |
#max_line_length(feature_element) ⇒ Object
25 26 27 28 |
# File 'lib/lucid/ast/step_invocations.rb', line 25 def max_line_length(feature_element) lengths = (@steps + [feature_element]).map{|e| e.text_length} lengths.max end |
#previous_step(step) ⇒ Object
58 59 60 61 |
# File 'lib/lucid/ast/step_invocations.rb', line 58 def previous_step(step) i = @steps.index(step) || -1 @steps[i-1] end |
#skip_invoke! ⇒ Object
30 31 32 |
# File 'lib/lucid/ast/step_invocations.rb', line 30 def skip_invoke! @steps.each{ |step_invocation| step_invocation.skip_invoke! } end |
#status ⇒ Object
47 48 49 50 51 52 |
# File 'lib/lucid/ast/step_invocations.rb', line 47 def status @steps.each do |step_invocation| return step_invocation.status if step_invocation.status != :passed end :passed end |
#to_sexp ⇒ Object
67 68 69 |
# File 'lib/lucid/ast/step_invocations.rb', line 67 def to_sexp @steps.map{|step| step.to_sexp} end |