Class: Lucid::AST::Specs

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/lucid/ast/specs.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpecs

Returns a new instance of Specs.



8
9
10
# File 'lib/lucid/ast/specs.rb', line 8

def initialize
  @features = []
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



6
7
8
# File 'lib/lucid/ast/specs.rb', line 6

def duration
  @duration
end

Instance Method Details

#[](index) ⇒ Object



12
13
14
# File 'lib/lucid/ast/specs.rb', line 12

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

#accept(visitor) ⇒ Object

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.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/lucid/ast/specs.rb', line 28

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

#add_feature(feature) ⇒ Object



20
21
22
# File 'lib/lucid/ast/specs.rb', line 20

def add_feature(feature)
  @features << feature
end

#each(&proc) ⇒ Object



16
17
18
# File 'lib/lucid/ast/specs.rb', line 16

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

#step_countObject



40
41
42
# File 'lib/lucid/ast/specs.rb', line 40

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