Sha256: ee2685a127a1e23f73cd46f86f6891cf73efb996416dbf9fd0e052b98c152b49

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

module Lucid
  module AST
    # This class holds an array of Step or StepDefinition.
    class StepCollection #:nodoc:
      include Enumerable

      def initialize(steps)
        @steps = steps
        @steps.each{|step| step.step_collection = self}
      end

      def accept(visitor)
        visitor.visit_steps(self) do
          @steps.each do |step|
            step.accept(visitor)
          end
        end
      end

      def step_invocations(background = false)
        StepInvocations.new(@steps.map{ |step|
          i = step.step_invocation
          i.background = background
          i
        })
      end

      def step_invocations_from_cells(cells)
        @steps.map{|step| step.step_invocation_from_cells(cells)}
      end

      def each(&proc)
        @steps.each(&proc)
      end

      def max_line_length(feature_element)
        lengths = (@steps + [feature_element]).map{|e| e.text_length}
        lengths.max
      end

      def exception
        @exception ||= ((failed = @steps.detect {|step| step.exception}) && failed.exception)
      end

      def failed?
        status == :failed
      end

      def passed?
        status == :passed
      end

      def status
        @steps.each{|step_invocation| return step_invocation.status if step_invocation.status != :passed}
        :passed
      end

      def length
        @steps.length
      end

      def to_sexp
        @steps.map{|step| step.to_sexp}
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lucid-0.5.1 lib/lucid/ast/step_collection.rb
lucid-0.4.1 lib/lucid/ast/step_collection.rb
lucid-0.4.0 lib/lucid/ast/step_collection.rb
lucid-0.3.3 lib/lucid/ast/step_collection.rb
lucid-0.3.0 lib/lucid/ast/step_collection.rb
lucid-0.2.1 lib/lucid/ast/step_collection.rb
lucid-0.2.0 lib/lucid/ast/step_collection.rb
lucid-0.1.1 lib/lucid/ast/step_collection.rb
lucid-0.1.0 lib/lucid/ast/step_collection.rb