class Lucid::AST::Spec

Attributes

duration[R]

Public Class Methods

new() click to toggle source
# File lib/lucid/ast/spec.rb, line 8
def initialize
  @features = []
end

Public Instance Methods

[](index) click to toggle source
# File lib/lucid/ast/spec.rb, line 12
def [](index)
  @features[index]
end
accept(visitor) click to toggle source

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.

# File lib/lucid/ast/spec.rb, line 29
def accept(visitor)
  visitor.visit_features(self) do
    start = Time.now

    self.each do |feature|
      log.debug('Feature AST:')
      log.debug(feature)
      feature.accept(visitor)
    end

    @duration = Time.now - start
  end
end
add_feature(feature) click to toggle source

@see Lucid::SpecLoader.load

# File lib/lucid/ast/spec.rb, line 21
def add_feature(feature)
  @features << feature
end
each(&proc) click to toggle source
# File lib/lucid/ast/spec.rb, line 16
def each(&proc)
  @features.each(&proc)
end
step_count() click to toggle source
# File lib/lucid/ast/spec.rb, line 43
def step_count
  @features.inject(0) { |total, feature| total += feature.step_count }
end

Private Instance Methods

log() click to toggle source
# File lib/lucid/ast/spec.rb, line 49
def log
  Lucid.logger
end