Class: Gherkin::Listener::FormatterListener::Stash
- Inherits:
-
Object
- Object
- Gherkin::Listener::FormatterListener::Stash
- Defined in:
- lib/gherkin/listener/formatter_listener.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#ids ⇒ Object
readonly
Returns the value of attribute ids.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #comment(comment) ⇒ Object
- #examples(name) {|@comments, @tags, @examples_id| ... } ⇒ Object
- #feature(name) {|@comments, @tags, @feature_id| ... } ⇒ Object
- #feature_element(name) {|@comments, @tags, @feature_element_id| ... } ⇒ Object
- #id(name) ⇒ Object
-
#initialize ⇒ Stash
constructor
A new instance of Stash.
- #row {|@comments, defined?(@examples_id) ? "#{@examples_id};#{@row_index}" : :undefined_examples_id| ... } ⇒ Object
- #step {|@comments| ... } ⇒ Object
- #tag(tag) ⇒ Object
Constructor Details
#initialize ⇒ Stash
Returns a new instance of Stash.
94 95 96 97 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 94 def initialize @comments, @tags, @ids = [], [], [] @row_index = 0 end |
Instance Attribute Details
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
92 93 94 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 92 def comments @comments end |
#ids ⇒ Object (readonly)
Returns the value of attribute ids.
92 93 94 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 92 def ids @ids end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
92 93 94 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 92 def @tags end |
Instance Method Details
#comment(comment) ⇒ Object
99 100 101 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 99 def comment(comment) @comments << comment end |
#examples(name) {|@comments, @tags, @examples_id| ... } ⇒ Object
115 116 117 118 119 120 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 115 def examples(name) @examples_id = "#{@feature_element_id};#{id(name)}" @row_index = 0 yield @comments, @tags, @examples_id @comments, @tags = [], [] end |
#feature(name) {|@comments, @tags, @feature_id| ... } ⇒ Object
103 104 105 106 107 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 103 def feature(name) @feature_id = id(name) yield @comments, @tags, @feature_id @comments, @tags = [], [] end |
#feature_element(name) {|@comments, @tags, @feature_element_id| ... } ⇒ Object
109 110 111 112 113 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 109 def feature_element(name) @feature_element_id = "#{@feature_id};#{id(name)}" yield @comments, @tags, @feature_element_id @comments, @tags = [], [] end |
#id(name) ⇒ Object
138 139 140 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 138 def id(name) (name || '').gsub(/[\s_]/, '-').downcase end |
#row {|@comments, defined?(@examples_id) ? "#{@examples_id};#{@row_index}" : :undefined_examples_id| ... } ⇒ Object
128 129 130 131 132 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 128 def row @row_index += 1 yield @comments, defined?(@examples_id) ? "#{@examples_id};#{@row_index}" : :undefined_examples_id @comments = [] end |
#step {|@comments| ... } ⇒ Object
122 123 124 125 126 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 122 def step @row_index += 1 yield @comments @comments = [] end |
#tag(tag) ⇒ Object
134 135 136 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 134 def tag(tag) @tags << tag end |