Class: Cucumber::Ast::PyString
Overview
Represents an inline argument in a step. Example:
Given the
"""
I like
Cucumber sandwich
"""
The text between the pair of """
is stored inside a PyString, which is yielded to the StepDefinition block as the last argument.
The StepDefinition can then access the String via the #to_s method. In the example above, that would return: "I like\nCucumber sandwich"
Note how the indentation from the source is stripped away.
Defined Under Namespace
Classes: Builder
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
-
#arguments_replaced(arguments) ⇒ Object
:nodoc:.
- #has_text?(text) ⇒ Boolean
-
#initialize(string) ⇒ PyString
constructor
A new instance of PyString.
-
#to_sexp ⇒ Object
For testing only.
- #to_step_definition_arg ⇒ Object
Constructor Details
#initialize(string) ⇒ PyString
Returns a new instance of PyString.
48 49 50 |
# File 'lib/cucumber/ast/py_string.rb', line 48 def initialize(string) @string = string end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
35 36 37 |
# File 'lib/cucumber/ast/py_string.rb', line 35 def file @file end |
Class Method Details
.default_arg_name ⇒ Object
37 38 39 |
# File 'lib/cucumber/ast/py_string.rb', line 37 def self.default_arg_name "string" end |
Instance Method Details
#accept(visitor) ⇒ Object
56 57 58 59 |
# File 'lib/cucumber/ast/py_string.rb', line 56 def accept(visitor) return if Cucumber.wants_to_quit visitor.visit_py_string(@string) end |
#arguments_replaced(arguments) ⇒ Object
:nodoc:
61 62 63 64 65 66 67 68 |
# File 'lib/cucumber/ast/py_string.rb', line 61 def arguments_replaced(arguments) #:nodoc: string = @string arguments.each do |name, value| value ||= '' string = string.gsub(name, value) end PyString.new(string) end |
#has_text?(text) ⇒ Boolean
70 71 72 |
# File 'lib/cucumber/ast/py_string.rb', line 70 def has_text?(text) @string.index(text) end |
#to_sexp ⇒ Object
For testing only
75 76 77 |
# File 'lib/cucumber/ast/py_string.rb', line 75 def to_sexp #:nodoc: [:py_string, to_step_definition_arg] end |
#to_step_definition_arg ⇒ Object
52 53 54 |
# File 'lib/cucumber/ast/py_string.rb', line 52 def to_step_definition_arg @string end |