Class: Gm::Notepad::TableEntry
- Inherits:
-
Object
- Object
- Gm::Notepad::TableEntry
- Includes:
- Comparable
- Defined in:
- lib/gm/notepad/table_entry.rb
Constant Summary collapse
- NUMBER_RANGE_REGEXP =
%r{(?<left>\d+) *- *(?<right>\d+)}
Instance Attribute Summary collapse
-
#cells ⇒ Object
readonly
Returns the value of attribute cells.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #entry ⇒ Object (also: #entry_column, #to_str)
- #lookup(cell:) ⇒ Object
- #lookup_range ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#cells ⇒ Object
Returns the value of attribute cells.
31 32 33 |
# File 'lib/gm/notepad/table_entry.rb', line 31 def cells @cells end |
#index ⇒ Object
Returns the value of attribute index.
31 32 33 |
# File 'lib/gm/notepad/table_entry.rb', line 31 def index @index end |
Instance Method Details
#<=>(other) ⇒ Object
13 14 15 |
# File 'lib/gm/notepad/table_entry.rb', line 13 def <=>(other) to_str <=> String(other) end |
#entry ⇒ Object Also known as: entry_column, to_str
33 34 35 |
# File 'lib/gm/notepad/table_entry.rb', line 33 def entry cells.join("\t") end |
#lookup(cell:) ⇒ Object
17 18 19 20 |
# File 'lib/gm/notepad/table_entry.rb', line 17 def lookup(cell:) # TODO: Need to deal with named columns cells[cell.to_i] end |
#lookup_range ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/gm/notepad/table_entry.rb', line 23 def lookup_range if match = NUMBER_RANGE_REGEXP.match(index) (match[:left].to_i..match[:right].to_i).map(&:to_s) else [index] end end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/gm/notepad/table_entry.rb', line 38 def to_s "[#{index}]\t#{entry}" end |