Class: Lucid::AST::Spec
- Includes:
- Enumerable
- Defined in:
- lib/lucid/ast/spec.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#accept(visitor) ⇒ Object
The ability to visit specs is the first step in turning a spec into what is traditionally called a feature.
- #add_feature(feature) ⇒ Object
- #each(&proc) ⇒ Object
-
#initialize ⇒ Spec
constructor
A new instance of Spec.
- #step_count ⇒ Object
Constructor Details
#initialize ⇒ Spec
Returns a new instance of Spec.
8 9 10 |
# File 'lib/lucid/ast/spec.rb', line 8 def initialize @features = [] end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/lucid/ast/spec.rb', line 6 def duration @duration end |
Instance Method Details
#[](index) ⇒ Object
12 13 14 |
# File 'lib/lucid/ast/spec.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.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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) ⇒ Object
21 22 23 |
# File 'lib/lucid/ast/spec.rb', line 21 def add_feature(feature) @features << feature end |
#each(&proc) ⇒ Object
16 17 18 |
# File 'lib/lucid/ast/spec.rb', line 16 def each(&proc) @features.each(&proc) end |
#step_count ⇒ Object
43 44 45 |
# File 'lib/lucid/ast/spec.rb', line 43 def step_count @features.inject(0) { |total, feature| total += feature.step_count } end |