Module: Chell::ReinforcedCSVTable
- Defined in:
- lib/chell.rb
Instance Method Summary collapse
- #col(index = 0, &block) ⇒ Object
- #col!(index = 0, &block) ⇒ Object
-
#csv ⇒ Object
Alias methods.
- #h ⇒ Object
- #l ⇒ Object
- #row(index = 0, &block) ⇒ Object
- #s ⇒ Object
- #write(filename) ⇒ Object
Instance Method Details
#col(index = 0, &block) ⇒ Object
22 23 24 |
# File 'lib/chell.rb', line 22 def col(index = 0, &block) map_wrapper(block){ map{|x| x[index] } } end |
#col!(index = 0, &block) ⇒ Object
26 27 28 |
# File 'lib/chell.rb', line 26 def col!(index = 0, &block) map.with_index{|x,i| x[index] = (yield x[index], i) } if block_given? end |
#csv ⇒ Object
Alias methods
39 |
# File 'lib/chell.rb', line 39 def csv; self; end |
#h ⇒ Object
42 |
# File 'lib/chell.rb', line 42 def h; headers; end |
#l ⇒ Object
41 |
# File 'lib/chell.rb', line 41 def l; length; end |
#row(index = 0, &block) ⇒ Object
30 31 32 |
# File 'lib/chell.rb', line 30 def row(index = 0, &block) map_wrapper(block){ self[index] } end |
#s ⇒ Object
40 |
# File 'lib/chell.rb', line 40 def s; size; end |
#write(filename) ⇒ Object
34 35 36 |
# File 'lib/chell.rb', line 34 def write(filename) File.write(filename, self.to_csv(write_headers: true)) end |