Class: Gm::Notepad::Table
- Inherits:
-
Object
- Object
- Gm::Notepad::Table
- Defined in:
- lib/gm/notepad/table.rb
Instance Method Summary collapse
- #all ⇒ Object
- #append(line:, write: false) ⇒ Object
- #column_names ⇒ Object
- #grep(expression) ⇒ Object
- #lookup(index: false, cell: false) ⇒ Object
Instance Method Details
#all ⇒ Object
27 28 29 |
# File 'lib/gm/notepad/table.rb', line 27 def all @table.values.uniq end |
#append(line:, write: false) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/gm/notepad/table.rb', line 45 def append(line:, write: false) process(lines: [line]) return unless filename return unless write File.open(filename, "a") do |file| file.puts(line) end end |
#column_names ⇒ Object
31 32 33 |
# File 'lib/gm/notepad/table.rb', line 31 def column_names @table_column_set.names end |
#grep(expression) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/gm/notepad/table.rb', line 35 def grep(expression) returning_value = [] @table.each_value do |entry| if expression.match(entry.entry_column) returning_value << entry end end returning_value end |
#lookup(index: false, cell: false) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gm/notepad/table.rb', line 15 def lookup(index: false, cell: false) if index && cell lookup_entry_by(index: index).lookup(cell: cell) elsif index lookup_entry_by(index: index) elsif cell lookup_random_entry.lookup(cell: cell) else lookup_random_entry end end |