class Wrapomatic::Line::Processor::Primary

A line processor that extracts the primary line, which is all parts of the line before the column cutoff, inclusive.

Private Instance Methods

breaking_whitespace() click to toggle source
# File lib/wrapomatic/line/processor/primary.rb, line 32
def breaking_whitespace
  text.rindex(/(\s|-)/, columns).to_i
end
last_leading_whitespace() click to toggle source
# File lib/wrapomatic/line/processor/primary.rb, line 19
def last_leading_whitespace
  [0, text.index(/[^\s]/).to_i - 1].max
end
line_break() click to toggle source
# File lib/wrapomatic/line/processor/primary.rb, line 23
def line_break
  case breaking_whitespace > last_leading_whitespace
  when true
    [columns, breaking_whitespace].min
  else
    columns
  end
end
primary_part() click to toggle source
# File lib/wrapomatic/line/processor/primary.rb, line 15
def primary_part
  text.slice(0..line_break).rstrip
end
processed() click to toggle source
# File lib/wrapomatic/line/processor/primary.rb, line 11
def processed
  @processed ||= primary_part
end