Class: CWM::TreeItem
- Inherits:
-
Object
- Object
- CWM::TreeItem
- Defined in:
- library/cwm/src/lib/cwm/tree.rb
Overview
A Tree widget item
Direct Known Subclasses
Instance Attribute Summary collapse
- #children ⇒ Hash{id => TreeItem} readonly
-
#icon ⇒ String
readonly
Icon filename.
-
#id ⇒ Object
readonly
What to put in Id.
- #label ⇒ String readonly
-
#open ⇒ Boolean
readonly
Is the subtree open?.
Instance Method Summary collapse
-
#initialize(id, label, icon: nil, open: true, children: []) ⇒ TreeItem
constructor
A new instance of TreeItem.
- #ui_term ⇒ Object
Constructor Details
#initialize(id, label, icon: nil, open: true, children: []) ⇒ TreeItem
Returns a new instance of TreeItem.
17 18 19 20 21 22 23 |
# File 'library/cwm/src/lib/cwm/tree.rb', line 17 def initialize(id, label, icon: nil, open: true, children: []) @id = id @label = label @icon = icon @open = open @children = children.map { |c| [c.id, c] }.to_h end |
Instance Attribute Details
#children ⇒ Hash{id => TreeItem} (readonly)
15 16 17 |
# File 'library/cwm/src/lib/cwm/tree.rb', line 15 def children @children end |
#icon ⇒ String (readonly)
Returns icon filename.
11 12 13 |
# File 'library/cwm/src/lib/cwm/tree.rb', line 11 def icon @icon end |
#id ⇒ Object (readonly)
Returns what to put in Id.
7 8 9 |
# File 'library/cwm/src/lib/cwm/tree.rb', line 7 def id @id end |
#label ⇒ String (readonly)
9 10 11 |
# File 'library/cwm/src/lib/cwm/tree.rb', line 9 def label @label end |
#open ⇒ Boolean (readonly)
Returns is the subtree open?.
13 14 15 |
# File 'library/cwm/src/lib/cwm/tree.rb', line 13 def open @open end |