Sha256: b20a789170fb873e6abfeca6caf6a21e7a4aa1b75b1aa1ba9511cb1e2ad19fbf

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 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

      def accept(visitor)
        return if Lucid.wants_to_quit

        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

2 entries across 2 versions & 1 rubygems

Version Path
lucid-0.0.8 lib/lucid/ast/specs.rb
lucid-0.0.7 lib/lucid/ast/specs.rb