class Dill::Table::Columns
Attributes
parent[R]
Public Class Methods
new(parent)
click to toggle source
# File lib/dill/widgets/table.rb, line 30 def initialize(parent) @parent = parent end
Public Instance Methods
[](header_or_index)
click to toggle source
# File lib/dill/widgets/table.rb, line 34 def [](header_or_index) case header_or_index when Integer values_by_index(header_or_index) when String values_by_header(header_or_index) else raise TypeError, "can't convert #{header_or_index.inspect} to Integer or String" end end
each(&block)
click to toggle source
# File lib/dill/widgets/table.rb, line 46 def each(&block) parent.each(&block) end
Private Instance Methods
find_header_index(header)
click to toggle source
# File lib/dill/widgets/table.rb, line 62 def find_header_index(header) parent.widget(:header_row).value.find_index(header) or raise ArgumentError, "header not found: #{header.inspect}" end
values_by_header(header)
click to toggle source
# File lib/dill/widgets/table.rb, line 58 def values_by_header(header) values_by_index(find_header_index(header)) end
values_by_index(index)
click to toggle source
# File lib/dill/widgets/table.rb, line 54 def values_by_index(index) parent.rows.transpose[index] end