Class: Cucumber::Ast::DocString
- Defined in:
- lib/cucumber/ast/doc_string.rb
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 DocString, 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.
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#file ⇒ Object
:nodoc:.
Class Method Summary collapse
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
-
#arguments_replaced(arguments) ⇒ Object
:nodoc:.
- #has_text?(text) ⇒ Boolean
-
#initialize(string, content_type) ⇒ DocString
constructor
A new instance of DocString.
-
#to_sexp ⇒ Object
For testing only.
- #to_step_definition_arg ⇒ Object
Methods inherited from String
Constructor Details
#initialize(string, content_type) ⇒ DocString
Returns a new instance of DocString.
28 29 30 31 |
# File 'lib/cucumber/ast/doc_string.rb', line 28 def initialize(string, content_type) @content_type = content_type super string end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
26 27 28 |
# File 'lib/cucumber/ast/doc_string.rb', line 26 def content_type @content_type end |
Class Method Details
.default_arg_name ⇒ Object
22 23 24 |
# File 'lib/cucumber/ast/doc_string.rb', line 22 def self.default_arg_name "string" end |
Instance Method Details
#accept(visitor) ⇒ Object
37 38 39 40 |
# File 'lib/cucumber/ast/doc_string.rb', line 37 def accept(visitor) return if Cucumber.wants_to_quit visitor.visit_doc_string(self) end |
#arguments_replaced(arguments) ⇒ Object
:nodoc:
42 43 44 45 46 47 48 49 |
# File 'lib/cucumber/ast/doc_string.rb', line 42 def arguments_replaced(arguments) #:nodoc: string = self arguments.each do |name, value| value ||= '' string = string.gsub(name, value) end DocString.new(string, content_type) end |
#has_text?(text) ⇒ Boolean
51 52 53 |
# File 'lib/cucumber/ast/doc_string.rb', line 51 def has_text?(text) index(text) end |
#to_sexp ⇒ Object
For testing only
56 57 58 |
# File 'lib/cucumber/ast/doc_string.rb', line 56 def to_sexp #:nodoc: [:doc_string, to_step_definition_arg] end |
#to_step_definition_arg ⇒ Object
33 34 35 |
# File 'lib/cucumber/ast/doc_string.rb', line 33 def to_step_definition_arg self end |