Sha256: 7b5286136ef889e2b0545259401c8468f971061aa28d7aa8a8e8ccc59c6d2601

Contents?: true

Size: 1.05 KB

Versions: 11

Compression:

Stored size: 1.05 KB

Contents

module Embulk

  class Column < Struct.new(:index, :name, :type)
    def initialize(index, name, type)
      super(index, name, type)
    end

    if Embulk.java?
      def self.from_java(java_column)
        Column.new(
          java_column.getIndex,
          java_column.getName,
          Type.from_java(java_column.getType))
      end

      def to_java
        Java::Column.new(index, name, Type.new_java_type(type))
      end
    end
  end

  module Type
    if Embulk.java?
      def self.from_java(java_type)
        java_type.getName.to_sym
      end

      def self.new_java_type(ruby_type)
        case ruby_type
        when :boolean
          Java::Types::BOOLEAN
        when :long
          Java::Types::LONG
        when :double
          Java::Types::DOUBLE
        when :string
          Java::Types::STRING
        when :timestamp
          Java::Types::TIMESTAMP
        else
          raise ArgumentError, "Unknown type #{ruby_type.inspect}: supported types are :boolean, :long, :double, :string and :timestamp"
        end
      end
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
embulk-0.4.10 lib/embulk/column.rb
embulk-0.4.9 lib/embulk/column.rb
embulk-0.4.8 lib/embulk/column.rb
embulk-0.4.7 lib/embulk/column.rb
embulk-0.4.6 lib/embulk/column.rb
embulk-0.4.5 lib/embulk/column.rb
embulk-0.4.4 lib/embulk/column.rb
embulk-0.4.3 lib/embulk/column.rb
embulk-0.4.2 lib/embulk/column.rb
embulk-0.4.1 lib/embulk/column.rb
embulk-0.4.0 lib/embulk/column.rb