Sha256: e43ac2b6928c966e0c41482019b83a37c0fe246f73a2557cea13f9a2788b5935

Contents?: true

Size: 859 Bytes

Versions: 3

Compression:

Stored size: 859 Bytes

Contents

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, _, 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
          IRB.conf[:MEASURE] = true
          added = IRB.set_measure_callback(type, arg)
          puts "#{added[0]} is added." if added
        end
        nil
      end
    end
  end
end
# :startdoc:

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
irb-1.3.2 lib/irb/cmd/measure.rb
irb-1.3.1 lib/irb/cmd/measure.rb
irb-1.3.0 lib/irb/cmd/measure.rb