Class: GeekPainter::Canvas
- Inherits:
-
Object
- Object
- GeekPainter::Canvas
show all
- Includes:
- EscapingTools
- Defined in:
- lib/geek_painter/canvas.rb
Overview
The main DSL, every single call to the “label” method pushes the parameters to an array and “raw” method then joins the array to generate the actual string to be used in PS1 or wherever.
ie. canvas = Canvas.new
canvas.label "\\[\\033[33m\\]user:" => yellow text
canvas.label "\\[\\033[34m\\]host" => blue text
canvas.show => \\[\\033[33m\\]user:\\[\\033[34m\\]host => user:host
Instance Attribute Summary collapse
Instance Method Summary
collapse
#end_color, #end_escape, #escape, #open_escape, #start_color
Constructor Details
#initialize ⇒ Canvas
18
19
20
|
# File 'lib/geek_painter/canvas.rb', line 18
def initialize
@labels = []
end
|
Instance Attribute Details
#labels ⇒ Object
Returns the value of attribute labels.
16
17
18
|
# File 'lib/geek_painter/canvas.rb', line 16
def labels
@labels
end
|
Instance Method Details
#for_prompt ⇒ Object
36
37
38
|
# File 'lib/geek_painter/canvas.rb', line 36
def for_prompt
prompt.to_raw
end
|
#for_text ⇒ Object
40
41
42
|
# File 'lib/geek_painter/canvas.rb', line 40
def for_text
text.to_raw
end
|
#label(string_color_pair) ⇒ Object
Also known as:
trace
22
23
24
|
# File 'lib/geek_painter/canvas.rb', line 22
def label(string_color_pair)
@labels << string_color_pair
end
|
#prompt ⇒ Object
28
29
30
|
# File 'lib/geek_painter/canvas.rb', line 28
def prompt
render :for_prompt
end
|
#reset_color ⇒ Object
44
45
46
|
# File 'lib/geek_painter/canvas.rb', line 44
def reset_color
@labels << ["", :default]
end
|
#text ⇒ Object
32
33
34
|
# File 'lib/geek_painter/canvas.rb', line 32
def text
render :for_text
end
|