class Cucumber::Core::Ast::Feature

Represents the root node of a parsed feature.

Attributes

background[R]
comments[R]
description[R]
feature_elements[R]
keyword[R]
language[R]
location[R]
tags[R]

Public Class Methods

new(language, location, background, comments, tags, keyword, name, description, scenario_definitions) click to toggle source
# File lib/cucumber/core/ast/feature.rb, line 19
def initialize(language, location, background, comments, tags, keyword, name, description, scenario_definitions)
  @language = language
  @location = location
  @background = background
  @comments = comments
  @tags = tags
  @keyword = keyword
  @name = name
  @description = description
  @feature_elements = scenario_definitions
end

Public Instance Methods

children() click to toggle source
# File lib/cucumber/core/ast/feature.rb, line 31
def children
  [background] + @feature_elements
end
short_name() click to toggle source
# File lib/cucumber/core/ast/feature.rb, line 35
def short_name
  first_line = name.split(/\n/)[0]
  if first_line =~ /#{language.feature_keywords}:(.*)/
    $1.strip
  else
    first_line
  end
end
to_sexp() click to toggle source
# File lib/cucumber/core/ast/feature.rb, line 44
def to_sexp
  sexp = [:feature, file, name]
  comment = @comment.to_sexp
  sexp += [comment] if comment
  tags = @tags.to_sexp
  sexp += tags if tags.any?
  sexp += [@background.to_sexp] if @background
  sexp += @feature_elements.map{|fe| fe.to_sexp}
  sexp
end

Private Instance Methods

description_for_visitors() click to toggle source
# File lib/cucumber/core/ast/feature.rb, line 57
def description_for_visitors
  :feature
end