Sha256: c376de995441878475f8895d989bc92b0ae10e553763a438011d4acf930da9c3

Contents?: true

Size: 739 Bytes

Versions: 4

Compression:

Stored size: 739 Bytes

Contents

module Debugger

  module ParseFunctions
    # Parse 'str' of command 'cmd' as an integer between
    # min and max. If either min or max is nil, that
    # value has no bound.
    def get_int(str, cmd, min=nil, max=nil, default=1)
      return default unless str
      begin
        int = Integer(str)
        if min and int < min
          print_error "%s argument '%s' needs to at least %s.\n" % [cmd, str, min]
          return nil
        elsif max and int > max
          print_error "%s argument '%s' needs to at most %s.\n" % [cmd, str, max]
          return nil
        end
        return int
      rescue
        print_error "%s argument '%s' needs to be a number.\n" % [cmd, str]
        return nil
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-debug-ide-0.1.10 lib/ruby-debug/helper.rb
ruby-debug-ide-0.1.9 lib/ruby-debug/helper.rb
ruby-debug-ide-0.1.8 lib/ruby-debug/helper.rb
ruby-debug-ide-0.1.7 lib/ruby-debug/helper.rb