Class: Pdtable::Table
- Inherits:
-
CSV::Table
- Object
- CSV::Table
- Pdtable::Table
- Defined in:
- lib/pdtable/pdtable.rb
Instance Attribute Summary collapse
-
#dtype ⇒ Object
readonly
Returns the value of attribute dtype.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #delete(index_or_header) ⇒ Object
-
#initialize(path, dtype: nil, skiprows: nil) ⇒ Table
constructor
A new instance of Table.
- #set_mode!(mode, t = self) ⇒ Object
Constructor Details
#initialize(path, dtype: nil, skiprows: nil) ⇒ Table
Returns a new instance of Table.
6 7 8 9 10 11 12 13 |
# File 'lib/pdtable/pdtable.rb', line 6 def initialize(path, dtype: nil, skiprows: nil) @table = CSV.table path @mode = :col_or_row delete_rows(@table, skiprows) unless skiprows.nil? @dtype = inspect_data_types(@table) @dtype.merge!(dtype) unless dtype.nil? convert(@table, @dtype) end |
Instance Attribute Details
#dtype ⇒ Object (readonly)
Returns the value of attribute dtype.
15 16 17 |
# File 'lib/pdtable/pdtable.rb', line 15 def dtype @dtype end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
15 16 17 |
# File 'lib/pdtable/pdtable.rb', line 15 def table @table end |
Instance Method Details
#delete(index_or_header) ⇒ Object
27 28 29 |
# File 'lib/pdtable/pdtable.rb', line 27 def delete(index_or_header) @table.delete index_or_header end |
#set_mode!(mode, t = self) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/pdtable/pdtable.rb', line 17 def set_mode!(mode, t = self) if mode == :row t.by_row! elsif mode == :column t.by_col! elsif mode == :col_or_row t.by_col_or_row! end end |