Class: Soundcloud9000::UI::View
- Inherits:
-
Object
- Object
- Soundcloud9000::UI::View
show all
- Defined in:
- lib/soundcloud9000/ui/view.rb
Overview
class responsible for helping keep our app tidy and populated
Constant Summary
collapse
- ROW_SEPARATOR =
'|'.freeze
- LINE_SEPARATOR =
'-'.freeze
- INTERSECTION =
'+'.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(rect) ⇒ View
Returns a new instance of View.
15
16
17
18
19
20
21
|
# File 'lib/soundcloud9000/ui/view.rb', line 15
def initialize(rect)
@rect = rect
@window = Curses::Window.new(rect.height, rect.width, rect.y, rect.x)
@line = 0
@padding = 0
end
|
Instance Attribute Details
#rect ⇒ Object
Returns the value of attribute rect.
13
14
15
|
# File 'lib/soundcloud9000/ui/view.rb', line 13
def rect
@rect
end
|
Instance Method Details
#body_width ⇒ Object
34
35
36
|
# File 'lib/soundcloud9000/ui/view.rb', line 34
def body_width
rect.width - 2 * padding
end
|
#clear ⇒ Object
42
43
44
|
# File 'lib/soundcloud9000/ui/view.rb', line 42
def clear
@window.clear
end
|
#padding(value = nil) ⇒ Object
23
24
25
|
# File 'lib/soundcloud9000/ui/view.rb', line 23
def padding(value = nil)
value.nil? ? @padding : @padding = value
end
|
#render ⇒ Object
27
28
29
30
31
32
|
# File 'lib/soundcloud9000/ui/view.rb', line 27
def render
perform_layout
reset
draw
refresh
end
|
#with_color(name, &block) ⇒ Object
38
39
40
|
# File 'lib/soundcloud9000/ui/view.rb', line 38
def with_color(name, &block)
@window.attron(Color.get(name), &block)
end
|