Class: ArrowFormat::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/arrow-format/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, nullable: true, metadata: nil) ⇒ Field

Returns a new instance of Field.



22
23
24
25
26
27
28
29
30
# File 'lib/arrow-format/field.rb', line 22

def initialize(name,
               type,
               nullable: true,
               metadata: nil)
  @name = name
  @type = type
  @nullable = nullable
  @metadata = 
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



21
22
23
# File 'lib/arrow-format/field.rb', line 21

def 
  @metadata
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/arrow-format/field.rb', line 19

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



20
21
22
# File 'lib/arrow-format/field.rb', line 20

def type
  @type
end

Instance Method Details

#nullable?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/arrow-format/field.rb', line 32

def nullable?
  @nullable
end

#to_flatbuffersObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/arrow-format/field.rb', line 36

def to_flatbuffers
  fb_field = FB::Field::Data.new
  fb_field.name = @name
  fb_field.nullable = @nullable
  if @type.respond_to?(:build_fb_field)
    @type.build_fb_field(fb_field)
  else
    fb_field.type = @type.to_flatbuffers
  end
  if @type.respond_to?(:child)
    fb_field.children = [@type.child.to_flatbuffers]
  elsif @type.respond_to?(:children)
    fb_field.children = @type.children.collect(&:to_flatbuffers)
  end
  fb_field. = FB.(@metadata)
  fb_field
end