diff options
Diffstat (limited to 'lib/irb/cmd/measure.rb')
-rw-r--r-- | lib/irb/cmd/measure.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/irb/cmd/measure.rb b/lib/irb/cmd/measure.rb new file mode 100644 index 0000000000..6161d15bcb --- /dev/null +++ b/lib/irb/cmd/measure.rb @@ -0,0 +1,34 @@ +require_relative "nop" + +# :stopdoc: +module IRB + module ExtendCommand + class Measure < Nop + def initialize(*args) + super(*args) + end + + def execute(type = nil, arg = nil) + case type + when :off + IRB.conf[:MEASURE] = nil + IRB.unset_measure_callback(arg) + when :list + IRB.conf[:MEASURE_CALLBACKS].each do |type_name, _| + puts "- #{type_name}" + end + when :on + IRB.conf[:MEASURE] = true + added = IRB.set_measure_callback(type) + puts "#{added.first} is added." + else + IRB.conf[:MEASURE] = true + added = IRB.set_measure_callback(type) + puts "#{added.first} is added." + end + nil + end + end + end +end +# :startdoc: |