Class: Gherkin::Formatter::Model::Step

Inherits:
BasicStatement show all
Defined in:
lib/gherkin/formatter/model.rb

Instance Attribute Summary collapse

Attributes inherited from BasicStatement

#comments, #keyword, #line, #name

Instance Method Summary collapse

Methods inherited from BasicStatement

#first_non_comment_line, #initialize

Constructor Details

This class inherits a constructor from Gherkin::Formatter::Model::BasicStatement

Instance Attribute Details

#multiline_argObject

Returns the value of attribute multiline_arg.



115
116
117
# File 'lib/gherkin/formatter/model.rb', line 115

def multiline_arg
  @multiline_arg
end

Instance Method Details

#line_rangeObject



117
118
119
120
121
122
123
124
125
126
# File 'lib/gherkin/formatter/model.rb', line 117

def line_range
  range = super
  case multiline_arg
  when Array
    range = range.first..multiline_arg[-1].line
  when Model::PyString
    range = range.first..multiline_arg.line_range.last
  end
  range
end

#outline_argsObject



132
133
134
135
136
137
138
# File 'lib/gherkin/formatter/model.rb', line 132

def outline_args
  offset = 0
  name.scan(/<[^<]*>/).map do |val|
    offset = name.index(val, offset)
    Argument.new(offset, val)
  end
end

#replay(formatter) ⇒ Object



128
129
130
# File 'lib/gherkin/formatter/model.rb', line 128

def replay(formatter)
  formatter.step(self)
end

#to_hashObject



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/gherkin/formatter/model.rb', line 140

def to_hash
  hash = super
  if Array === @multiline_arg
    hash['multiline_arg'] = {
      'type' => 'table',
      'value' => hash['multiline_arg']
    }
  elsif PyString === @multiline_arg
    hash['multiline_arg']['type'] = 'py_string'
  end
  hash
end