Module: Ripl::Rc::SqueezeHistory
- Includes:
- U
- Defined in:
- lib/ripl/rc/squeeze_history.rb
Defined Under Namespace
Modules: Imp
Instance Method Summary collapse
- #before_loop ⇒ Object
-
#eval_input(input) ⇒ Object
squeeze history on memory too.
-
#history ⇒ Object
avoid some complicated conditions…
-
#write_history ⇒ Object
write squeezed history.
Methods included from U
Methods included from Imp
Methods included from Ripl::Rc::StripBacktrace::Imp
#cwd, #home, #snip, #strip_backtrace
Methods included from Anchor::Imp
Methods included from Color::Imp
#black, #blue, #color, #colors, #cyan, #find_color, #green, #magenta, #red, #reset, #white, #yellow
Instance Method Details
#before_loop ⇒ Object
28 29 30 31 |
# File 'lib/ripl/rc/squeeze_history.rb', line 28 def before_loop return super if SqueezeHistory.disabled? super if history.empty? end |
#eval_input(input) ⇒ Object
squeeze history on memory too
21 22 23 24 25 26 |
# File 'lib/ripl/rc/squeeze_history.rb', line 21 def eval_input input return super if SqueezeHistory.disabled? history.pop if input.strip == '' || (history.size > 1 && input == history[-2]) super end |
#history ⇒ Object
avoid some complicated conditions…
8 9 10 |
# File 'lib/ripl/rc/squeeze_history.rb', line 8 def history super || (@history ||= []) end |
#write_history ⇒ Object
write squeezed history
13 14 15 16 17 18 |
# File 'lib/ripl/rc/squeeze_history.rb', line 13 def write_history return super if SqueezeHistory.disabled? File.open(history_file, 'w'){ |f| f.puts U.squeeze_history(history).join("\n") } end |