Module: Gherkin::Rubify

Included in:
I18n
Defined in:
lib/gherkin/rubify.rb

Instance Method Summary collapse

Instance Method Details

#rubify(o) ⇒ Object

Translate Java objects to Ruby. This is especially important to convert java.util.List coming from Java and back to a Ruby Array.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gherkin/rubify.rb', line 7

def rubify(o)
  case (o)
    when Java.java.util.Collection, Array
      rubified_array = o.map{ |e| rubify(e) }
      if o.respond_to?(:line)
        class << rubified_array
          attr_accessor :line
        end
        rubified_array.line = o.line
      end
      rubified_array
    when Java.gherkin.formatter.model.DocString
      require 'gherkin/formatter/model'
      Formatter::Model::DocString.new(o.content_type, o.value, o.line)
    else
      o
  end
end