Class: Cucumber::Core::Gherkin::AstBuilder::DocumentBuilder

Inherits:
Builder
  • Object
show all
Defined in:
lib/cucumber/core/gherkin/ast_builder.rb

Instance Method Summary collapse

Methods inherited from Builder

#handle_comments

Constructor Details

#initialize(file, attributes) ⇒ DocumentBuilder

Returns a new instance of DocumentBuilder.



99
100
101
102
# File 'lib/cucumber/core/gherkin/ast_builder.rb', line 99

def initialize(file, attributes)
  @file = file
  @attributes = rubify_keys(attributes.dup)
end

Instance Method Details

#all_commentsObject



111
112
113
114
115
116
117
118
# File 'lib/cucumber/core/gherkin/ast_builder.rb', line 111

def all_comments
  attributes[:comments].map do |comment|
    Ast::Comment.new(
      Ast::Location.new(file, comment[:location][:line]),
      comment[:text]
    )
  end
end

#featureObject



104
105
106
107
108
109
# File 'lib/cucumber/core/gherkin/ast_builder.rb', line 104

def feature
  return Ast::NullFeature.new unless attributes[:feature]
  feature_builder = FeatureBuilder.new(file, attributes[:feature])
  feature_builder.handle_comments(all_comments)
  feature_builder.result
end