Class: Gm::Notepad::TableEntry

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#entry_columnObject Also known as: to_str

Returns the value of attribute entry_column.



24
25
26
# File 'lib/gm/notepad/table_entry.rb', line 24

def entry_column
  @entry_column
end

#lookup_columnObject

Returns the value of attribute lookup_column.



24
25
26
# File 'lib/gm/notepad/table_entry.rb', line 24

def lookup_column
  @lookup_column
end

Instance Method Details

#<=>(other) ⇒ Object



11
12
13
# File 'lib/gm/notepad/table_entry.rb', line 11

def <=>(other)
  to_str <=> String(other)
end

#lookup_rangeObject



16
17
18
19
20
21
22
# File 'lib/gm/notepad/table_entry.rb', line 16

def lookup_range
  if match = NUMBER_RANGE_REGEXP.match(lookup_column)
    (match[:left].to_i..match[:right].to_i).map(&:to_s)
  else
    [lookup_column]
  end
end

#to_sObject



26
27
28
# File 'lib/gm/notepad/table_entry.rb', line 26

def to_s
  "[#{lookup_column}]\t#{entry_column}"
end