Module: Ripl::Ripper

Defined in:
lib/ripl/ripper.rb

Constant Summary collapse

VERSION =
'0.1.0'

Instance Method Summary collapse

Instance Method Details

#before_loopObject



8
9
10
11
# File 'lib/ripl/ripper.rb', line 8

def before_loop
  super
  @buffer = []
end

#eval_input(input) ⇒ Object



28
29
30
31
32
# File 'lib/ripl/ripper.rb', line 28

def eval_input(input)
  @buffer << input
  @input = @buffer.join("\n")
  ripper_valid?(@input) ? super(@input) : throw(:multiline)
end

#loop_onceObject



17
18
19
20
21
22
# File 'lib/ripl/ripper.rb', line 17

def loop_once
  catch(:multiline) do
    super
    @buffer = []
  end
end

#promptObject



13
14
15
# File 'lib/ripl/ripper.rb', line 13

def prompt
  @buffer.empty? ? super : config[:ripper_prompt]
end

#ripper_valid?(str) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ripl/ripper.rb', line 24

def ripper_valid?(str)
  !!Ripper::SexpBuilder.new(str).parse
end