Class: CWM::TreeItem

Inherits:
Object
  • Object
show all
Defined in:
library/cwm/src/lib/cwm/tree.rb

Overview

A Tree widget item

Direct Known Subclasses

PagerTreeItem

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#childrenHash{id => TreeItem} (readonly)

Returns:



15
16
17
# File 'library/cwm/src/lib/cwm/tree.rb', line 15

def children
  @children
end

#iconString (readonly)

Returns icon filename

Returns:

  • (String)

    icon filename



11
12
13
# File 'library/cwm/src/lib/cwm/tree.rb', line 11

def icon
  @icon
end

#idObject (readonly)

Returns what to put in Id

Returns:

  • what to put in Id



7
8
9
# File 'library/cwm/src/lib/cwm/tree.rb', line 7

def id
  @id
end

#labelString (readonly)

Returns:

  • (String)


9
10
11
# File 'library/cwm/src/lib/cwm/tree.rb', line 9

def label
  @label
end

#openBoolean (readonly)

Returns is the subtree open?

Returns:

  • (Boolean)

    is the subtree open?



13
14
15
# File 'library/cwm/src/lib/cwm/tree.rb', line 13

def open
  @open
end

Instance Method Details

#ui_termObject



25
26
27
28
29
30
31
32
# File 'library/cwm/src/lib/cwm/tree.rb', line 25

def ui_term
  args = [Yast::Term.new(:id, id)]
  args << Yast::Term.new(:icon, icon) if icon
  args << label
  args << open
  args << children.values.map(&:ui_term)
  Yast::Term.new(:item, *args)
end