Class: Parqueteur::ColumnCollection
- Inherits:
-
Object
- Object
- Parqueteur::ColumnCollection
- Includes:
- Enumerable
- Defined in:
- lib/parqueteur/column_collection.rb
Instance Attribute Summary collapse
-
#column_names ⇒ Object
readonly
Returns the value of attribute column_names.
Instance Method Summary collapse
- #add(column) ⇒ Object
- #arrow_schema ⇒ Object
- #each(&block) ⇒ Object
- #find(name) ⇒ Object
-
#initialize ⇒ ColumnCollection
constructor
A new instance of ColumnCollection.
- #key?(key) ⇒ Boolean
Constructor Details
#initialize ⇒ ColumnCollection
Returns a new instance of ColumnCollection.
9 10 11 12 13 |
# File 'lib/parqueteur/column_collection.rb', line 9 def initialize @columns = [] @column_names = [] @columns_idx = {} end |
Instance Attribute Details
#column_names ⇒ Object (readonly)
Returns the value of attribute column_names.
7 8 9 |
# File 'lib/parqueteur/column_collection.rb', line 7 def column_names @column_names end |
Instance Method Details
#add(column) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/parqueteur/column_collection.rb', line 23 def add(column) unless @columns_idx.key?(column.name) @columns_idx[column.name] = column @columns << column @column_names << column.name end true end |
#arrow_schema ⇒ Object
37 38 39 |
# File 'lib/parqueteur/column_collection.rb', line 37 def arrow_schema @arrow_schema ||= Arrow::Schema.new(@columns.collect(&:to_arrow_field)) end |
#each(&block) ⇒ Object
19 20 21 |
# File 'lib/parqueteur/column_collection.rb', line 19 def each(&block) @columns.each(&block) end |
#find(name) ⇒ Object
33 34 35 |
# File 'lib/parqueteur/column_collection.rb', line 33 def find(name) @columns_idx.fetch(name, nil) end |
#key?(key) ⇒ Boolean
15 16 17 |
# File 'lib/parqueteur/column_collection.rb', line 15 def key?(key) @columns_idx.key?(key) end |