Class: Hairballs::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/hairballs/prompt.rb

Overview

Hairballs representation of IRB.conf. Method names here make prompt types clearer.

TODO: Make it nicer to define Pry prompts.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auto_indentObject

Parameters:

  • (Boolean)


8
9
10
# File 'lib/hairballs/prompt.rb', line 8

def auto_indent
  @auto_indent
end

#continued_statementObject Also known as: c

The prompt for when statements wrap multiple lines. Same as IRB.conf[ prompt name ][:PROMPT_C]

Parameters:

  • (String)


30
31
32
# File 'lib/hairballs/prompt.rb', line 30

def continued_statement
  @continued_statement
end

#continued_stringObject Also known as: s

The prompt for when strings wrap multiple lines. Same as IRB.conf[ prompt name ][:PROMPT_S]

Parameters:

  • (String)


22
23
24
# File 'lib/hairballs/prompt.rb', line 22

def continued_string
  @continued_string
end

#indented_codeObject Also known as: n

The prompt for when statements include indentation. Same as IRB.conf[ prompt name ][:PROMPT_N]

Parameters:

  • (String)


38
39
40
# File 'lib/hairballs/prompt.rb', line 38

def indented_code
  @indented_code
end

#normalObject Also known as: i

The normal prompt string. Same as IRB.conf[ prompt name ][:PROMPT_I]

Parameters:

  • (String)


14
15
16
# File 'lib/hairballs/prompt.rb', line 14

def normal
  @normal
end

#return_formatObject

The prompt for return values. Same as IRB.conf[ prompt name ][:RETURN]

Parameters:

  • (String)


46
47
48
# File 'lib/hairballs/prompt.rb', line 46

def return_format
  @return_format
end

Instance Method Details

#irb_configurationHash

Returns A set of key/value pairs that can be used to pass to a IRB.conf[ prompt name ].

Returns:

  • (Hash)

    A set of key/value pairs that can be used to pass to a IRB.conf[ prompt name ].



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/hairballs/prompt.rb', line 50

def irb_configuration
  vputs 'Setting up prompt...'

  prompt_values = {}
  prompt_values[:AUTO_INDENT] = @auto_indent if @auto_indent
  prompt_values[:PROMPT_C] = continued_statement unless continued_statement.empty?
  prompt_values[:PROMPT_I] = normal unless normal.empty?
  prompt_values[:PROMPT_N] = indented_code unless indented_code.empty?
  prompt_values[:PROMPT_S] = continued_string unless continued_string.empty?
  prompt_values[:RETURN] = @return_format if @return_format

  prompt_values
end