Class: Soundcloud2000::UI::Table
- Inherits:
-
View
- Object
- View
- Soundcloud2000::UI::Table
show all
- Defined in:
- lib/soundcloud2000/ui/table.rb
Constant Summary
collapse
- SEPARATOR =
' | '
Constants inherited
from View
View::INTERSECTION, View::LINE_SEPARATOR, View::ROW_SEPARATOR
Instance Attribute Summary collapse
Attributes inherited from View
#rect
Instance Method Summary
collapse
Methods inherited from View
#body_width, #clear, #padding, #render, #with_color
Constructor Details
#initialize(*args) ⇒ Table
Returns a new instance of Table.
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/soundcloud2000/ui/table.rb', line 11
def initialize(*args)
super
@sizes = []
@rows = []
@current, @top = 0, 0
@selected = nil
reset
end
|
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
8
9
10
|
# File 'lib/soundcloud2000/ui/table.rb', line 8
def collection
@collection
end
|
#current ⇒ Object
Returns the value of attribute current.
8
9
10
|
# File 'lib/soundcloud2000/ui/table.rb', line 8
def current
@current
end
|
Returns the value of attribute header.
9
10
11
|
# File 'lib/soundcloud2000/ui/table.rb', line 9
def
@header
end
|
#keys ⇒ Object
Returns the value of attribute keys.
9
10
11
|
# File 'lib/soundcloud2000/ui/table.rb', line 9
def keys
@keys
end
|
Instance Method Details
#bind_to(collection) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/soundcloud2000/ui/table.rb', line 22
def bind_to(collection)
raise ArgumentError if @collection
@collection = collection
@collection.events.on(:append) { render }
@collection.events.on(:replace) { clear; render }
end
|
#body_height ⇒ Object
34
35
36
|
# File 'lib/soundcloud2000/ui/table.rb', line 34
def body_height
rect.height - @header.size
end
|
#bottom? ⇒ Boolean
38
39
40
|
# File 'lib/soundcloud2000/ui/table.rb', line 38
def bottom?
current + 1 >= length
end
|
#deselect ⇒ Object
63
64
65
66
|
# File 'lib/soundcloud2000/ui/table.rb', line 63
def deselect
@selected = nil
render
end
|
#down ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/soundcloud2000/ui/table.rb', line 50
def down
if (@current + 1) < length
@current += 1
@top += 1 if @current > body_height
render
end
end
|
#length ⇒ Object
30
31
32
|
# File 'lib/soundcloud2000/ui/table.rb', line 30
def length
@collection.size
end
|
#select ⇒ Object
58
59
60
61
|
# File 'lib/soundcloud2000/ui/table.rb', line 58
def select
@selected = @current
render
end
|
#up ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/soundcloud2000/ui/table.rb', line 42
def up
if @current > 0
@current -= 1
@top -= 1 if @current < @top
render
end
end
|