Class: ArrowFormat::UnionType
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#type_ids ⇒ Object
readonly
Returns the value of attribute type_ids.
Instance Method Summary collapse
-
#initialize(mode, children, type_ids) ⇒ UnionType
constructor
A new instance of UnionType.
- #resolve_type_index(type) ⇒ Object
- #to_flatbuffers ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(mode, children, type_ids) ⇒ UnionType
Returns a new instance of UnionType.
962 963 964 965 966 967 968 |
# File 'lib/arrow-format/type.rb', line 962 def initialize(mode, children, type_ids) super() @mode = mode @children = children @type_ids = type_ids @type_indexes = {} end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
960 961 962 |
# File 'lib/arrow-format/type.rb', line 960 def children @children end |
#type_ids ⇒ Object (readonly)
Returns the value of attribute type_ids.
961 962 963 |
# File 'lib/arrow-format/type.rb', line 961 def type_ids @type_ids end |
Instance Method Details
#resolve_type_index(type) ⇒ Object
970 971 972 |
# File 'lib/arrow-format/type.rb', line 970 def resolve_type_index(type) @type_indexes[type] ||= @type_ids.index(type) end |
#to_flatbuffers ⇒ Object
981 982 983 984 985 986 |
# File 'lib/arrow-format/type.rb', line 981 def to_flatbuffers fb_type = FB::Union::Data.new fb_type.mode = FB::UnionMode.try_convert(@mode.to_s.capitalize) fb_type.type_ids = @type_ids fb_type end |
#to_s ⇒ Object
974 975 976 977 978 979 |
# File 'lib/arrow-format/type.rb', line 974 def to_s children = @children.collect.with_index do |child, i| "#{child.name}: #{child.type}=#{@type_ids[i]}" end "#{super}<#{children.join(", ")}>" end |