Class: RubyVolt::VoltTable
- Inherits:
-
Object
- Object
- RubyVolt::VoltTable
- Defined in:
- lib/ruby_volt/volt_table.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#total_metadata_length ⇒ Object
readonly
Returns the value of attribute total_metadata_length.
-
#total_table_length ⇒ Object
readonly
Returns the value of attribute total_table_length.
Instance Method Summary collapse
- #add_struct(row) ⇒ Object
- #column_names ⇒ Object
-
#initialize(index, total_table_length, total_metadata_length, status_code, columns, rows = []) ⇒ VoltTable
constructor
A new instance of VoltTable.
- #inspect ⇒ Object
- #method_missing(m, *args, &block) ⇒ Object
- #struct(*row) ⇒ Object
Constructor Details
#initialize(index, total_table_length, total_metadata_length, status_code, columns, rows = []) ⇒ VoltTable
Returns a new instance of VoltTable.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/ruby_volt/volt_table.rb', line 5 def initialize(index, total_table_length, , status_code, columns, rows = []) @index = index @total_table_length = total_table_length @total_metadata_length = @status_code = status_code @columns = columns @row = ::Struct.new(*columns.map {|c| c[0].to_sym}) @rows = [] rows.each {|r| add_struct(r)} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
32 33 34 |
# File 'lib/ruby_volt/volt_table.rb', line 32 def method_missing(m, *args, &block) rows.send(m, *args, &block) end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
3 4 5 |
# File 'lib/ruby_volt/volt_table.rb', line 3 def columns @columns end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
3 4 5 |
# File 'lib/ruby_volt/volt_table.rb', line 3 def index @index end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
3 4 5 |
# File 'lib/ruby_volt/volt_table.rb', line 3 def rows @rows end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
3 4 5 |
# File 'lib/ruby_volt/volt_table.rb', line 3 def status_code @status_code end |
#total_metadata_length ⇒ Object (readonly)
Returns the value of attribute total_metadata_length.
3 4 5 |
# File 'lib/ruby_volt/volt_table.rb', line 3 def @total_metadata_length end |
#total_table_length ⇒ Object (readonly)
Returns the value of attribute total_table_length.
3 4 5 |
# File 'lib/ruby_volt/volt_table.rb', line 3 def total_table_length @total_table_length end |
Instance Method Details
#add_struct(row) ⇒ Object
28 29 30 |
# File 'lib/ruby_volt/volt_table.rb', line 28 def add_struct(row) @rows << struct(*row) end |
#column_names ⇒ Object
20 21 22 |
# File 'lib/ruby_volt/volt_table.rb', line 20 def column_names columns.map(&:last) end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/ruby_volt/volt_table.rb', line 16 def inspect "#<#{self.class.name} index=#{@index} total_table_length=#{@total_table_length} total_metadata_length=#{@total_metadata_length} rows=#{@rows.size}>" end |
#struct(*row) ⇒ Object
24 25 26 |
# File 'lib/ruby_volt/volt_table.rb', line 24 def struct(*row) @row.new(*row) end |