Class: Ksql::Collection
- Inherits:
-
Struct
- Object
- Struct
- Ksql::Collection
- Includes:
- Enumerable
- Defined in:
- lib/ksql/collection.rb
Instance Attribute Summary collapse
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
-
#each(&block) ⇒ Array
Allow iterations block on Rows.
-
#initialize(struct_schema, items) ⇒ Collection
constructor
-
Generate a class to fit ksqlDB query returned data * Populate the collection.
-
Constructor Details
#initialize(struct_schema, items) ⇒ Collection
-
Generate a class to fit ksqlDB query returned data
-
Populate the collection
16 17 18 19 |
# File 'lib/ksql/collection.rb', line 16 def initialize(struct_schema, items) struct = Ksql.const_set(id_to_struct(struct_schema['queryId']), Class.new(Struct.new(*struct_schema['columnNames'].map { |n| n.downcase.to_sym }))) self.rows = items.map { |i| struct.new(*i) } end |
Instance Attribute Details
#rows ⇒ Object
Returns the value of attribute rows
6 7 8 |
# File 'lib/ksql/collection.rb', line 6 def rows @rows end |
Instance Method Details
#each(&block) ⇒ Array
Allow iterations block on Rows
28 29 30 31 32 |
# File 'lib/ksql/collection.rb', line 28 def each(&block) rows.each do |r| yield(r) end end |