Module: IRB

Defined in:
lib/irb_callbacks.rb,
lib/irb_callbacks.rb

Defined Under Namespace

Classes: Context, Irb

Class Method Summary collapse

Class Method Details

.after_evalObject

Called after evaling the user’s input.

module IRB
  def self.after_eval
    puts "(After eval)"
  end
end

Sample session:

$ irb
irb(main):001:0> true
(After eval)
=> true


204
205
# File 'lib/irb_callbacks.rb', line 204

def self.after_eval
end

.after_outputObject

Called after outputing the result of the eval.

module IRB
  def self.after_output
    puts "(After output)"
  end
end

Sample session:

$ irb
irb(main):001:0> true
=> true
(After output)


263
264
# File 'lib/irb_callbacks.rb', line 263

def self.after_output
end

.after_promptObject

Called after prompting the user for each line of input.

module IRB
  def self.after_prompt
    puts "(after prompt)"
  end
end

$ irb
irb(main):009:0> if true
(after prompt)
irb(main):010:1> false
(after prompt)
irb(main):011:1> end
(after prompt)
=> false


143
144
# File 'lib/irb_callbacks.rb', line 143

def self.after_prompt
end

.around_evalObject

Called immediately before evaling the user’s input. Choose when to fire off the eval by calling yield.

module IRB
  def self.around_eval
    puts "(Before eval)"
    yield
    puts "(After eval)"
  end
end

Sample session:

$ irb
irb(main):001:0> true
(Before eval)
(After eval)
=> true


226
227
228
# File 'lib/irb_callbacks.rb', line 226

def self.around_eval
  yield
end

.around_outputObject

Called immediately before outputing the result of the eval. Choose when to output the results by calling yield.

module IRB
  def self.around_output
    puts "(Before output)"
    yield
    puts "(After output)"
  end
end

Sample session:

$ irb
irb(main):001:0> true
(Before output)
=> true
(After output)


286
287
288
# File 'lib/irb_callbacks.rb', line 286

def self.around_output
  yield
end

.around_promptObject

Called immediately before the prompt. Choose when to call the prompt by calling yield. If you don’t call yield, undefined bahavior will occur.

module IRB
  def self.around_prompt
    puts "(Before prompt)"
    yield
    puts "(After prompt)"
  end
end

Sample session:

$ irb
(Before prompt)
irb(main):001:0> true
(After prompt)
=> true


166
167
168
# File 'lib/irb_callbacks.rb', line 166

def self.around_prompt
  yield
end

.before_evalObject

Called before evaling the user’s input.

module IRB
  def self.before_eval
    puts "(Before eval)"
  end
end

Sample session:

$ irb
irb(main):001:0> true
(Before eval)
=> true


185
186
# File 'lib/irb_callbacks.rb', line 185

def self.before_eval
end

.before_outputObject

Called before outputing the result of the eval.

module IRB
  def self.before_output
    puts "(Before output)"
  end
end

Sample session:

$ irb
irb(main):001:0> true
(Before output)
=> true


245
246
# File 'lib/irb_callbacks.rb', line 245

def self.before_output
end

.before_promptObject

Called before prompting the user for each line of input. Example:

module IRB
  def self.before_prompt
    puts "(before prompt)"
  end
end

$ irb
(before prompt)
irb(main):009:0> if true
(before prompt)
irb(main):010:1> false
(before prompt)
irb(main):011:1> end
=> false


123
124
# File 'lib/irb_callbacks.rb', line 123

def self.before_prompt
end