Class: Embulk::Column
- Inherits:
-
Struct
- Object
- Struct
- Embulk::Column
- Defined in:
- lib/embulk/column.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#index ⇒ Object
Returns the value of attribute index.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Column
constructor
A new instance of Column.
- #to_java ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Column
Returns a new instance of Column.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/embulk/column.rb', line 4 def initialize(*args) if args.length == 1 && args[0].is_a?(Hash) # initialize(hash) hash = args.first super(hash[:index], hash[:name], hash[:type], hash[:format]) else # initialize(index, name, type, format) super(*args) end end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format
3 4 5 |
# File 'lib/embulk/column.rb', line 3 def format @format end |
#index ⇒ Object
Returns the value of attribute index
3 4 5 |
# File 'lib/embulk/column.rb', line 3 def index @index end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/embulk/column.rb', line 3 def name @name end |
#type ⇒ Object
Returns the value of attribute type
3 4 5 |
# File 'lib/embulk/column.rb', line 3 def type @type end |
Class Method Details
.from_java(java_column) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/embulk/column.rb', line 23 def self.from_java(java_column) type = Type.from_java(java_column.getType) if type == :timestamp format = java_column.getType.getFormat else format = nil end Column.new(java_column.getIndex, java_column.getName, type, format) end |
Instance Method Details
#to_java ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/embulk/column.rb', line 34 def to_java if type == :timestamp && format Java::Column.new(index, name, Type.new_java_type(type).withFormat(format)) else Java::Column.new(index, name, Type.new_java_type(type)) end end |
#to_json(*args) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/embulk/column.rb', line 15 def to_json(*args) if type == :timestamp && format {"index"=>index, "name"=>name, "type"=>type, "format"=>format}.to_json(*args) else {"index"=>index, "name"=>name, "type"=>type}.to_json(*args) end end |