class Fir::ReplState
Attributes
cursor[RW]
history[R]
indent[R]
lines[RW]
repl_binding[R]
Public Class Methods
blank()
click to toggle source
# File lib/fir/repl_state.rb, line 15 def self.blank new(Lines.blank, Cursor.blank) end
new( lines, cursor, repl_binding = TOPLEVEL_BINDING, history = Fir::History.new )
click to toggle source
# File lib/fir/repl_state.rb, line 19 def initialize( lines, cursor, repl_binding = TOPLEVEL_BINDING, history = Fir::History.new ) @lines = lines @cursor = cursor @repl_binding = repl_binding @history = history set_indent end
Public Instance Methods
==(other)
click to toggle source
# File lib/fir/repl_state.rb, line 62 def ==(other) lines == other.lines && cursor == other.cursor end
blank()
click to toggle source
# File lib/fir/repl_state.rb, line 49 def blank self.class.new( Lines.blank, Cursor.blank, repl_binding, history ) end
blank?()
click to toggle source
# File lib/fir/repl_state.rb, line 58 def blank? lines.blank? && cursor.blank? end
clone()
click to toggle source
# File lib/fir/repl_state.rb, line 40 def clone self.class.new( lines.clone, cursor.clone, repl_binding, history ) end
commit_current_line_to_history()
click to toggle source
# File lib/fir/repl_state.rb, line 86 def commit_current_line_to_history Fir::History.add_line_to_history_file( current_line.join ) end
current_line()
click to toggle source
# File lib/fir/repl_state.rb, line 70 def current_line lines[cursor.y] end
current_line=(new_line)
click to toggle source
# File lib/fir/repl_state.rb, line 66 def current_line=(new_line) lines[cursor.y] = new_line end
executable?()
click to toggle source
# File lib/fir/repl_state.rb, line 78 def executable? indent.executable? end
indents()
click to toggle source
# File lib/fir/repl_state.rb, line 74 def indents indent.indents end
suggestion()
click to toggle source
# File lib/fir/repl_state.rb, line 82 def suggestion history.suggestion(current_line.join) end
transition(command) { |new_state| ... }
click to toggle source
# File lib/fir/repl_state.rb, line 32 def transition(command) new_state = command.execute new_state.set_indent yield new_state if block_given? return blank if new_state.executable? new_state end
Protected Instance Methods
indent!()
click to toggle source
# File lib/fir/repl_state.rb, line 98 def indent! Fir::Indent.new(lines.map(&:join)).generate end
set_indent()
click to toggle source
# File lib/fir/repl_state.rb, line 94 def set_indent @indent = indent! end