class Frepl::MultilineStatement

Attributes

lines[R]

Public Class Methods

new(lines = []) click to toggle source
# File lib/frepl/statement.rb, line 47
def initialize(lines = [])
  @lines = lines
end

Public Instance Methods

complete?() click to toggle source
# File lib/frepl/statement.rb, line 59
def complete?
  @lines.last.match(terminal_regex) != nil && !nested?
end
incomplete?() click to toggle source
# File lib/frepl/statement.rb, line 55
def incomplete?
  !complete?
end
output() click to toggle source
# File lib/frepl/statement.rb, line 51
def output
  @lines.join("\n") + "\n"
end
terminal_regex() click to toggle source
# File lib/frepl/statement.rb, line 63
def terminal_regex
  raise NotImplementedError
end

Private Instance Methods

nested?() click to toggle source
# File lib/frepl/statement.rb, line 73
def nested?
  start_count = lines.select { |line| line.match(/\A\s*#{starting_regex}\z/) != nil }.count
  end_count = lines.select { |line| line.match(/\A\s*#{terminal_regex}\z/) != nil }.count
  start_count > end_count
end
starting_regex() click to toggle source
# File lib/frepl/statement.rb, line 69
def starting_regex
  raise NotImplementedError
end