Sha256: 3cea18693cf5f55b0c595bb27dcb6c4272c6b6079246d3d0b19d07abd43303c5

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module IRB
  class Statement
    attr_reader :code

    def is_assignment?
      raise NotImplementedError
    end

    def suppresses_echo?
      raise NotImplementedError
    end

    def should_be_handled_by_debugger?
      raise NotImplementedError
    end

    class EmptyInput < Statement
      def is_assignment?
        false
      end

      def suppresses_echo?
        true
      end

      # Debugger takes empty input to repeat the last command
      def should_be_handled_by_debugger?
        true
      end

      def code
        ""
      end
    end

    class Expression < Statement
      def initialize(code, is_assignment)
        @code = code
        @is_assignment = is_assignment
      end

      def suppresses_echo?
        @code.match?(/;\s*\z/)
      end

      def should_be_handled_by_debugger?
        true
      end

      def is_assignment?
        @is_assignment
      end
    end

    class Command < Statement
      attr_reader :command_class, :arg

      def initialize(original_code, command_class, arg)
        @code = original_code
        @command_class = command_class
        @arg = arg
      end

      def is_assignment?
        false
      end

      def suppresses_echo?
        true
      end

      def should_be_handled_by_debugger?
        require_relative 'command/debug'
        IRB::Command::DebugCommand > @command_class
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/irb-1.14.0/lib/irb/statement.rb
irb-1.14.3 lib/irb/statement.rb
irb-1.14.2 lib/irb/statement.rb
irb-1.14.1 lib/irb/statement.rb
irb-1.14.0 lib/irb/statement.rb