summaryrefslogtreecommitdiff
path: root/lib/irb/cmd
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-02-06 20:23:51 +0900
committergit <svn-admin@ruby-lang.org>2021-02-06 20:45:08 +0900
commit5704b5fe5e42bd5b1f42a27368cd5d52dd5a9060 (patch)
tree4c8f1a274875baa8613c2c4012fc79851b866ee4 /lib/irb/cmd
parente1e61e256bd65ac3f293ba1513d1a934b9a3bff9 (diff)
[ruby/irb] Allow "measure" command to take block
https://github.com/ruby/irb/commit/20f1ca23e9
Diffstat (limited to 'lib/irb/cmd')
-rw-r--r--lib/irb/cmd/measure.rb14
-rw-r--r--lib/irb/cmd/nop.rb4
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/irb/cmd/measure.rb b/lib/irb/cmd/measure.rb
index 5e0bef62af..58eaec2ded 100644
--- a/lib/irb/cmd/measure.rb
+++ b/lib/irb/cmd/measure.rb
@@ -8,7 +8,7 @@ module IRB
super(*args)
end
- def execute(type = nil, arg = nil)
+ def execute(type = nil, arg = nil, &block)
case type
when :off
IRB.conf[:MEASURE] = nil
@@ -22,9 +22,15 @@ module IRB
added = IRB.set_measure_callback(type, arg)
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
+ 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
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb
index 9cf4337c28..fa3c011b5f 100644
--- a/lib/irb/cmd/nop.rb
+++ b/lib/irb/cmd/nop.rb
@@ -15,9 +15,9 @@ module IRB
class Nop
- def self.execute(conf, *opts)
+ def self.execute(conf, *opts, &block)
command = new(conf)
- command.execute(*opts)
+ command.execute(*opts, &block)
end
def initialize(conf)