Module: Lucid::AST::MultilineArgument

Extended by:
Gherkin::Rubify
Defined in:
lib/lucid/ast/multiline_argument.rb

Class Method Summary collapse

Class Method Details

.from(argument) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lucid/ast/multiline_argument.rb', line 10

def from(argument)
  return unless argument
  return argument if argument.respond_to?(:to_step_definition_arg)

  case(rubify(argument))
  when String
    # TODO: This duplicates work that Gherkin already does.
    # Ideally the string should be passed directly to Gherkin for parsing.
    AST::DocString.new(argument, '')
  when Gherkin::Formatter::Model::DocString
    AST::DocString.new(argument.value, argument.content_type)
  when Array
    AST::Table.new(argument.map{|row| row.cells})
  else
    raise ArgumentError, "Lucid does not know how to convert #{argument} into a multi-line argument."
  end
end