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

Constructor Details

#initializePrompt

Returns a new instance of Prompt.



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

def initialize
  vputs 'Setting up prompt...'
  @irb_prompt_options = IRB.conf[:PROMPT][:NULL].dup
end

Instance Attribute Details

#irb_prompt_optionsObject (readonly)

Returns the value of attribute irb_prompt_options.



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

def irb_prompt_options
  @irb_prompt_options
end

Instance Method Details

#continued_statementString

Returns:

  • (String)


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

def continued_statement
  @irb_prompt_options[:PROMPT_C]
end

#continued_statement=(new_continued_statement) ⇒ Object

Wrapper for setting IRB.conf[:MY_PROMPT]. The prompt for when statements wrap multiple lines.

Parameters:

  • new_continued_statement (String)


24
25
26
# File 'lib/hairballs/prompt.rb', line 24

def continued_statement=(new_continued_statement)
  @irb_prompt_options[:PROMPT_C] = new_continued_statement
end

#continued_stringString

Returns:

  • (String)


42
43
44
# File 'lib/hairballs/prompt.rb', line 42

def continued_string
  @irb_prompt_options[:PROMPT_S]
end

#continued_string=(new_continued_string) ⇒ Object

Wrapper for setting IRB.conf[:MY_PROMPT]. The prompt for when strings wrap multiple lines.

Parameters:

  • new_continued_string (String)


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

def continued_string=(new_continued_string)
  @irb_prompt_options[:PROMPT_S] = new_continued_string
end

#indented_codeString

Returns:

  • (String)


55
56
57
# File 'lib/hairballs/prompt.rb', line 55

def indented_code
  @irb_prompt_options[:PROMPT_N]
end

#indented_code=(new_indented_code) ⇒ Object

Wrapper for setting IRB.conf[:MY_PROMPT]. The prompt for when statements include indentation.

Parameters:

  • new_indented_code (String)


50
51
52
# File 'lib/hairballs/prompt.rb', line 50

def indented_code=(new_indented_code)
  @irb_prompt_options[:PROMPT_N] = new_indented_code
end

#normalString

Returns:

  • (String)


67
68
69
# File 'lib/hairballs/prompt.rb', line 67

def normal
  @irb_prompt_options[:PROMPT_I]
end

#normal=(new_normal) ⇒ Object

Wrapper for setting IRB.conf[:MY_PROMPT].

Parameters:

  • new_normal (String)


62
63
64
# File 'lib/hairballs/prompt.rb', line 62

def normal=(new_normal)
  @irb_prompt_options[:PROMPT_I] = new_normal
end

#return_formatString

Returns:

  • (String)


80
81
82
# File 'lib/hairballs/prompt.rb', line 80

def return_format
  @irb_prompt_options[:RETURN]
end

#return_format=(new_return_format) ⇒ Object

Wrapper for setting IRB.conf[:MY_PROMPT]. The prompt for how to display return values.

Parameters:

  • new_return_format (String)


75
76
77
# File 'lib/hairballs/prompt.rb', line 75

def return_format=(new_return_format)
  @irb_prompt_options[:RETURN] = new_return_format
end