Module: Debugger::ParseFunctions

### Home Classes Methods

### In Files

- lib/ruby-debug/helper.rb

### Methods

- #get_int
- #get_onoff
- #show_onoff
- #syntax_valid?

### Class/Module Index

Quicksearch

- Debugger
- Debugger::AddBreakpoint
- Debugger::Breakpoint
- Debugger::Context
- Debugger::ContinueCommand
- Debugger::DeleteBreakpointCommand
- Debugger::FinishCommand
- Debugger::HelpCommand
- Debugger::IRBCommand
- Debugger::InfoCommand
- Debugger::JumpCommand
- Debugger::KillCommand
- Debugger::ListCommand
- Debugger::LocalInterface
- Debugger::LocalInterface::Debugger
- Debugger::MethodCommand
- Debugger::MethodSigCommand
- Debugger::NextCommand
- Debugger::ParseFunctions
- Debugger::Processor
- Debugger::QuitCommand
- Debugger::ReloadCommand
- Debugger::SetCommand
- Debugger::ShowCommand
- Debugger::SkipCommand
- Debugger::SourceCommand
- Debugger::StepCommand
- Debugger::VarClassVarCommand
- Debugger::VarInheritCommand
- Debugger::VarLocalCommand
- Debugger::WhereCommand
- Printers
- Printers::Base
- Printers::Base::MissedArgument
- Printers::Base::MissedPath
- Printers::Plain
- Mocha
- Mocha::Call
- Mocha::Expectation
- Mocha::Mock
- MiniTest
- MiniTest::Assertions
- MiniTest::Expectations
- TestDsl
- TestDsl::ClassMethods
- TestDsl::Shared
- Kernel
- Module
- PrinterHelpers
- TestInterface

No matching classes.

# Debugger::ParseFunctions

### Constants

Position_regexp

### Public Instance Methods

get_int(str, cmd, min=nil, max=nil, default=1) click to toggle source

Parse 'str' of command 'cmd' as an integer between min and max. If either min or max is nil, that value has no bound.

    # File lib/ruby-debug/helper.rb, line 9
    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 Debugger.printer.print("parse.errors.int.too_low", cmd: cmd, str: str, min: min)
          return nil
        elsif max and int > max
          print Debugger.printer.print("parse.errors.int.too_high", cmd: cmd, str: str, max: max)
          return nil
        end
        return int
      rescue
        print Debugger.printer.print("parse.errors.int.not_number", cmd: cmd, str: str)
        return nil
      end
    end

get_onoff(arg, default=nil, print_error=true) click to toggle source

Return true if arg is 'on' or 1 and false arg is 'off' or 0. Any other value raises RuntimeError.

    # File lib/ruby-debug/helper.rb, line 29
    def get_onoff(arg, default=nil, print_error=true)
      if arg.nil? or arg == ''
        if default.nil?
          if print_error
            print Debugger.printer.print("parse.errors.onoff.syntax", arg: "nothing")
            raise RuntimeError
          end
          return default
        end
      end
      case arg.downcase
      when '1', 'on'
        return true
      when '0', 'off'
        return false
      else
        if print_error
          print Debugger.printer.print("parse.errors.onoff.syntax", arg: arg)
          raise RuntimeError
        end
      end
    end

show_onoff(bool) click to toggle source

Return 'on' or 'off' for supplied parameter. The parmeter should be true, false or nil.

    # File lib/ruby-debug/helper.rb, line 54
    def show_onoff(bool)
      if not [TrueClass, FalseClass, NilClass].member?(bool.class)
        return "??"
      end
      return bool ? 'on' : 'off'
    end

syntax_valid?(code) click to toggle source

Return true if code is syntactically correct for Ruby.

    # File lib/ruby-debug/helper.rb, line 62
    def syntax_valid?(code)
      eval("BEGIN {return true}\n#{code}", nil, "", 0)
    rescue Exception
      false
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.