Sha256: bcff1ad3a822dd4ff7f5b62e47adbd9a1bdee79c07005754be874d3cef678139

Contents?: true

Size: 872 Bytes

Versions: 3

Compression:

Stored size: 872 Bytes

Contents

module Debugger

  # Implements debugger "set_type" command
  class SetTypeCommand < Command
    self.need_context = true

    def regexp
      / ^\s*
         set_type? \s*
         (?:\s+(\S+))?\s*
         (?:\s+(\S+))?\s*
         $
      /ix
    end

    def execute
      if RUBY_VERSION < "1.9"
        print_msg "Not implemented"
        return
      end
      begin
        expr = @match[1] + " = " + @match[2] + "(" + @match[1] + ".inspect)"
        eval(expr)
      rescue
        begin
          expr = @match[1] + " = " + @match[2] + ".new(" + @match[1] + ".inspect)"
          eval(expr)
        rescue nil
        end
      end
    end

    class << self
      def help_command
        %w[set_type]
      end

      def help(cmd)
        %{
          set_type <var> <type>

          Change the type of <var> to <type>
         }
     end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
debugger-ide-0.0.2 lib/ruby-debug/commands/set_type.rb
ruby-debug-ide19-0.4.12 lib/ruby-debug/commands/set_type.rb
ruby-debug-ide19-0.4.11 lib/ruby-debug/commands/set_type.rb