class Cucumber::Core::Gherkin::AstBuilder::Builder
Attributes
attributes[R]
comments[R]
file[R]
line[R]
Public Class Methods
new(file, attributes)
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 30 def initialize(file, attributes) @file = file @attributes = rubify_keys(attributes.dup) @comments = [] @line = @attributes[:location][:line] end
Public Instance Methods
handle_comments(comments)
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 37 def handle_comments(comments) remaining_comments = [] comments.each do |comment| if line > comment.location.line @comments << comment else remaining_comments << comment end end children.each { |child| remaining_comments = child.handle_comments(remaining_comments) } remaining_comments end
Private Instance Methods
children()
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 76 def children [] end
description()
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 60 def description attributes[:description] ||= "" end
keyword()
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 52 def keyword attributes[:keyword] end
location()
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 72 def location Ast::Location.new(file, attributes[:location][:line]) end
name()
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 56 def name attributes[:name] end
rubify_keys(hash)
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 80 def rubify_keys(hash) hash.keys.each do |key| if key.downcase != key hash[underscore(key).to_sym] = hash.delete(key) end end return hash end
underscore(string)
click to toggle source
# File lib/cucumber/core/gherkin/ast_builder.rb, line 89 def underscore(string) string.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end