Class: Fir
- Inherits:
-
Object
- Object
- Fir
- Defined in:
- lib/fir.rb,
lib/fir/key.rb,
lib/fir/lines.rb,
lib/fir/cursor.rb,
lib/fir/eraser.rb,
lib/fir/indent.rb,
lib/fir/screen.rb,
lib/fir/history.rb,
lib/fir/version.rb,
lib/fir/renderer.rb,
lib/fir/evaluater.rb,
lib/fir/repl_state.rb,
lib/fir/suggestion.rb,
lib/fir/screen_helper.rb,
lib/fir/key_command/key_command.rb,
lib/fir/key_command/tab_command.rb,
lib/fir/key_command/enter_command.rb,
lib/fir/key_command/ctrl_a_command.rb,
lib/fir/key_command/ctrl_c_command.rb,
lib/fir/key_command/ctrl_d_command.rb,
lib/fir/key_command/ctrl_e_command.rb,
lib/fir/key_command/ctrl_v_command.rb,
lib/fir/key_command/ctrl_z_command.rb,
lib/fir/key_command/up_arrow_command.rb,
lib/fir/key_command/backspace_command.rb,
lib/fir/key_command/down_arrow_command.rb,
lib/fir/key_command/left_arrow_command.rb,
lib/fir/key_command/single_key_command.rb,
lib/fir/key_command/right_arrow_command.rb
Defined Under Namespace
Modules: ScreenHelper Classes: BackspaceCommand, CtrlACommand, CtrlCCommand, CtrlDCommand, CtrlECommand, CtrlVCommand, CtrlZCommand, Cursor, DownArrowCommand, EnterCommand, Eraser, Evaluater, History, Indent, Key, KeyCommand, LeftArrowCommand, Lines, Renderer, ReplState, RightArrowCommand, Screen, SingleKeyCommand, Suggestion, TabCommand, UpArrowCommand
Constant Summary collapse
- VERSION =
'0.1.1'
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#screen ⇒ Object
readonly
Returns the value of attribute screen.
Class Method Summary collapse
- .config ⇒ Object
- .parse_opts(output) ⇒ Object
- .process_immediate_opts(opts, output) ⇒ Object
- .start(input, output, error) ⇒ Object
Instance Method Summary collapse
-
#initialize(key, screen) ⇒ Fir
constructor
A new instance of Fir.
- #perform(state) ⇒ Object
Constructor Details
#initialize(key, screen) ⇒ Fir
Returns a new instance of Fir.
46 47 48 49 |
# File 'lib/fir.rb', line 46 def initialize(key, screen) @key = key @screen = screen end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
13 14 15 |
# File 'lib/fir.rb', line 13 def key @key end |
#screen ⇒ Object (readonly)
Returns the value of attribute screen.
14 15 16 |
# File 'lib/fir.rb', line 14 def screen @screen end |
Class Method Details
.config ⇒ Object
34 35 36 37 38 |
# File 'lib/fir.rb', line 34 def self.config @config ||= { history: '~/.irb_history' } end |
.parse_opts(output) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/fir.rb', line 24 def self.parse_opts(output) OptionParser.new do |cl_opts| cl_opts. = 'Usage: fir [options]' cl_opts.on('-v', '--version', 'Show version') do |v| config[:version] = v end end.parse! process_immediate_opts(config, output) end |
Instance Method Details
#perform(state) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/fir.rb', line 51 def perform(state) state = yield(state) if block_given? perform(state) do state.transition(KeyCommand.for(key.get, state)) do |new_state| screen.update(state, new_state) end end end |