Class: PryBot::InputProxy

Inherits:
Struct
  • Object
show all
Defined in:
lib/input-proxy.rb

Overview

A class to represent an input object created from DRb. This is used because Pry checks for arity to know if a prompt should be passed to the object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#input#readline

Object to proxy

Returns:

  • (#readline)

    the current value of input



6
7
8
# File 'lib/input-proxy.rb', line 6

def input
  @input
end

Instance Method Details

#readline(prompt) ⇒ Object

Reads a line from the input



8
9
10
11
12
13
# File 'lib/input-proxy.rb', line 8

def readline(prompt)
  case readline_arity
  when 1 then input.readline(prompt)
  else        input.readline
  end
end

#readline_arityObject



15
16
17
18
19
# File 'lib/input-proxy.rb', line 15

def readline_arity
  input.method_missing(:method, :readline).arity
rescue NameError
  0
end