123456789_123456789_123456789_123456789_123456789_

Class: IRB::ExtendCommand::Measure

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Nop
Instance Chain:
self, Nop
Inherits: IRB::ExtendCommand::Nop
Defined in: lib/irb/cmd/measure.rb

Class Method Summary

Nop - Inherited

.execute

See additional method definition at line 18.

.new

Instance Attribute Summary

Nop - Inherited

Instance Method Summary

Constructor Details

.new(*args) ⇒ Measure

[ GitHub ]

  
# File 'lib/irb/cmd/measure.rb', line 7

def initialize(*args)
  super(*args)
end

Instance Method Details

#execute(type = nil, arg = nil, &block)

[ GitHub ]

  
# File 'lib/irb/cmd/measure.rb', line 11

def execute(type = nil, arg = nil, &block)
  # Please check IRB.init_config in lib/irb/init.rb that sets
  # IRB.conf[:MEASURE_PROC] to register default "measure" methods,
  # "measure :time" (abbreviated as "measure") and "measure :stackprof".
  case type
  when :off
    IRB.conf[:MEASURE] = nil
    IRB.unset_measure_callback(arg)
  when :list
    IRB.conf[:MEASURE_CALLBACKS].each do |type_name, _, arg_val|
      puts "- #{type_name}" + (arg_val ? "(#{arg_val.inspect})" : '')
    end
  when :on
    IRB.conf[:MEASURE] = true
    added = IRB.set_measure_callback(type, arg)
    puts "#{added[0]} is added." if added
  else
    if block_given?
      IRB.conf[:MEASURE] = true
      added = IRB.set_measure_callback(&block)
      puts "#{added[0]} is added." if added
    else
      IRB.conf[:MEASURE] = true
      added = IRB.set_measure_callback(type, arg)
      puts "#{added[0]} is added." if added
    end
  end
  nil
end