Class: RubyVolt::VoltTable

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_volt/volt_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#columnsObject (readonly)

Returns the value of attribute columns.



3
4
5
# File 'lib/ruby_volt/volt_table.rb', line 3

def columns
  @columns
end

#indexObject (readonly)

Returns the value of attribute index.



3
4
5
# File 'lib/ruby_volt/volt_table.rb', line 3

def index
  @index
end

#rowsObject (readonly)

Returns the value of attribute rows.



3
4
5
# File 'lib/ruby_volt/volt_table.rb', line 3

def rows
  @rows
end

#status_codeObject (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_lengthObject (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_lengthObject (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_namesObject



20
21
22
# File 'lib/ruby_volt/volt_table.rb', line 20

def column_names
  columns.map(&:last)
end

#inspectObject



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