Sha256: 6e073f9b3b76060a68c4f6db87bbf771a3e6c53a750e67bcfdb94a483bee8f5e

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'gherkin/rubify'

module Cucumber
  module Core
    module Ast
      module MultilineArgument

        class << self
          include Gherkin::Rubify

          # TODO: move this up to the front-end
          def from(argument, parent_location)
            return EmptyMultilineArgument.new unless argument
            return argument if argument.respond_to?(:to_step_definition_arg)

            argument = rubify(argument)
            case argument
            when String
              Ast::DocString.new(argument, 'text/plain', parent_location)
            when ::Gherkin::Formatter::Model::DocString
              Ast::DocString.new(argument.value, argument.content_type, parent_location.on_line(argument.line_range))
            when Array
              location = parent_location.on_line(argument.first.line..argument.last.line)
              Ast::DataTable.new(argument.map{|row| row.cells}, location)
            else
              raise ArgumentError, "Don't know how to convert #{argument.inspect} into a MultilineArgument"
            end
          end

        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cucumber-core-1.0.0.beta.2 lib/cucumber/core/ast/multiline_argument.rb
cucumber-core-1.0.0.beta.1 lib/cucumber/core/ast/multiline_argument.rb
cucumber-core-0.2.0 lib/cucumber/core/ast/multiline_argument.rb