Sha256: cf6beda6ba40ab769202a9dda72d13ff964d562392eb232af15e8b07f28263c9

Contents?: true

Size: 1004 Bytes

Versions: 6

Compression:

Stored size: 1004 Bytes

Contents

module Lucid
  module AST
    class Specs #:nodoc:
      include Enumerable

      attr_reader :duration

      def initialize
        @features = []
      end

      def [](index)
        @features[index]
      end

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

      def add_feature(feature)
        @features << feature
      end

      # The ability to visit specs is the first step in turning a spec into
      # what is traditionally called a feature. The spec file and the feature
      # are initially the same concept. When the spec is visited, the high
      # level construct (feature, ability) is determined.
      def accept(visitor)
        visitor.visit_features(self) do
          start = Time.now

          self.each do |feature|
            feature.accept(visitor)
          end

          @duration = Time.now - start
        end
      end

      def step_count
        @features.inject(0) { |total, feature| total += feature.step_count }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lucid-0.3.3 lib/lucid/ast/specs.rb
lucid-0.3.0 lib/lucid/ast/specs.rb
lucid-0.2.1 lib/lucid/ast/specs.rb
lucid-0.2.0 lib/lucid/ast/specs.rb
lucid-0.1.1 lib/lucid/ast/specs.rb
lucid-0.1.0 lib/lucid/ast/specs.rb