Class: Cucumber::Core::Ast::Step

Inherits:
Object
  • Object
show all
Includes:
DescribesItself, HasLocation
Defined in:
lib/cucumber/core/ast/step.rb

Direct Known Subclasses

ExpandedOutlineStep

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DescribesItself

#describe_to

Methods included from HasLocation

#all_locations, #attributes, #file, #file_colon_line, #line, #location, #tags

Constructor Details

#initialize(language, location, comments, keyword, text, multiline_arg) ⇒ Step

Returns a new instance of Step.



14
15
16
# File 'lib/cucumber/core/ast/step.rb', line 14

def initialize(language, location, comments, keyword, text, multiline_arg)
  @language, @location, @comments, @keyword, @text, @multiline_arg = language, location, comments, keyword, text, multiline_arg
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



12
13
14
# File 'lib/cucumber/core/ast/step.rb', line 12

def comments
  @comments
end

#exceptionObject (readonly)

Returns the value of attribute exception.



12
13
14
# File 'lib/cucumber/core/ast/step.rb', line 12

def exception
  @exception
end

#keywordObject (readonly)

Returns the value of attribute keyword.



12
13
14
# File 'lib/cucumber/core/ast/step.rb', line 12

def keyword
  @keyword
end

#languageObject (readonly)

Returns the value of attribute language.



12
13
14
# File 'lib/cucumber/core/ast/step.rb', line 12

def language
  @language
end

#multiline_argObject (readonly)

Returns the value of attribute multiline_arg.



12
13
14
# File 'lib/cucumber/core/ast/step.rb', line 12

def multiline_arg
  @multiline_arg
end

#textObject (readonly)

Returns the value of attribute text.



12
13
14
# File 'lib/cucumber/core/ast/step.rb', line 12

def text
  @text
end

Instance Method Details

#actual_keyword(previous_step_keyword = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cucumber/core/ast/step.rb', line 26

def actual_keyword(previous_step_keyword = nil)
  if [language.and_keywords, language.but_keywords].flatten.uniq.include? keyword
    if previous_step_keyword.nil?
      language.given_keywords.reject{|kw| kw == '* '}[0]
    else
      previous_step_keyword
    end
  else
    keyword
  end
end

#backtrace_lineObject



22
23
24
# File 'lib/cucumber/core/ast/step.rb', line 22

def backtrace_line
  "#{location}:in `#{keyword}#{text}'"
end

#inspectObject



42
43
44
45
# File 'lib/cucumber/core/ast/step.rb', line 42

def inspect
  keyword_and_text = [keyword, text].join(": ")
  %{#<#{self.class} "#{keyword_and_text}" (#{location})>}
end

#original_locationObject



38
39
40
# File 'lib/cucumber/core/ast/step.rb', line 38

def original_location
  location
end

#to_sObject



18
19
20
# File 'lib/cucumber/core/ast/step.rb', line 18

def to_s
  text
end