Class: Cucumber::Core::Ast::DocString
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Cucumber::Core::Ast::DocString
- Includes:
- DescribesItself, HasLocation
- Defined in:
- lib/cucumber/core/ast/doc_string.rb
Overview
Represents an inline argument in a step. Example:
Given the message """ 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 ⇒ Object
readonly
Returns the value of attribute content.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #data_table? ⇒ Boolean
- #doc_string? ⇒ Boolean
-
#initialize(content, content_type, location) ⇒ DocString
constructor
A new instance of DocString.
- #inspect ⇒ Object
- #map ⇒ Object
- #to_step_definition_arg ⇒ Object
Methods included from DescribesItself
Methods included from HasLocation
#all_locations, #attributes, #comments, #file, #file_colon_line, #line, #location, #multiline_arg, #tags
Constructor Details
#initialize(content, content_type, location) ⇒ DocString
Returns a new instance of DocString.
28 29 30 31 32 33 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 28 def initialize(content, content_type, location) @content = content @content_type = content_type @location = location super @content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
26 27 28 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 26 def content @content end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
26 27 28 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 26 def content_type @content_type end |
Instance Method Details
#==(other) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 53 def ==(other) if other.respond_to?(:content_type) return false unless content_type == other.content_type end if other.respond_to?(:to_str) return content == other.to_str end false end |
#data_table? ⇒ Boolean
35 36 37 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 35 def data_table? false end |
#doc_string? ⇒ Boolean
39 40 41 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 39 def doc_string? true end |
#inspect ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 63 def inspect [ %{#<#{self.class} (#{location})}, %{ """#{content_type}}, %{ #{@content}}, %{ """>} ].join("\n") end |
#map ⇒ Object
43 44 45 46 47 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 43 def map raise ArgumentError, "No block given" unless block_given? new_content = yield content self.class.new(new_content, content_type, location) end |
#to_step_definition_arg ⇒ Object
49 50 51 |
# File 'lib/cucumber/core/ast/doc_string.rb', line 49 def to_step_definition_arg self end |