module EveryDayIrb

Constants

VERSION

Private Instance Methods

cat(path) click to toggle source

read file contents (also see ray for ruby source files ;) )

# File lib/every_day_irb.rb, line 20
def cat(path)
  File.read path
end
cd(path = nil) click to toggle source

patch cd so that it also shows the current directory and got some extras

# File lib/every_day_irb.rb, line 15
def cd(path = nil)
  Cd.cd(path)
end
clear() click to toggle source

just clear the screen

# File lib/every_day_irb.rb, line 53
def clear
  system 'clear'
end
ld(lib) click to toggle source

load shortcut, not suited for non-rb

# File lib/every_day_irb.rb, line 35
def ld(lib)
  load lib.to_s + '.rb'
end
ls(path = '.') click to toggle source

shows the contents of your current directory (more such commands available by FileUtils)

# File lib/every_day_irb.rb, line 10
def ls(path = '.')
  Cd.cd.ls(path)
end
rerequire(lib) click to toggle source

rerequire, not suited for non-rb, please note: can have non-intended side effects in rare cases

# File lib/every_day_irb.rb, line 40
def rerequire(lib)
  $".dup.each{ |path|
    if path =~ %r</#{lib}\.rb$>
      $".delete path.to_s
      require path.to_s
    end
  }
  require lib.to_s
  true
end
Also aliased as: rrq
reset!() click to toggle source

restart irb

# File lib/every_day_irb.rb, line 58
def reset!
  # remember history...
  reset_irb = proc{ exec $0 }
  if defined?(Ripl) && Ripl.started?
    Ripl.shell.write_history if Ripl.shell.respond_to? :write_history
    reset_irb.call
  else
    at_exit(&reset_irb)
    exit
  end
end
rq(lib) click to toggle source

allows concise syntax like rq:mathn

# File lib/every_day_irb.rb, line 25
def rq(lib)
  require lib.to_s
end
rr(lib) click to toggle source

same for require relative

# File lib/every_day_irb.rb, line 30
def rr(lib)
  require_relative lib.to_s
end
rrq(lib)
Alias for: rerequire
session_history(number_of_lines = nil) click to toggle source

returns the last lines

# File lib/every_day_irb.rb, line 71
def session_history(number_of_lines = nil)
  if !number_of_lines
    if defined?(Ripl) && Ripl.started?
      number_of_lines = Ripl.shell.line
    else
      number_of_lines = context.instance_variable_get(:@line_no)
    end
  end
  Readline::HISTORY.entries[-number_of_lines...-1]*"\n"
end