Skip to content

Commit

Permalink
CWM::Tree: made label a mandatory constructor argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed May 19, 2017
1 parent 9028c7d commit aa590ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion library/cwm/examples/object_api_tree.rb
Expand Up @@ -151,7 +151,7 @@ def run

tl_item = ::CWM::PagerTreeItem.new(true_love_tab)
ln_item = ::CWM::PagerTreeItem.new(lucky_number_tab, children: [tl_item])
tabs = ::CWM::TreePager.new(ln_item)
tabs = ::CWM::TreePager.new(ln_item, label: "")

contents = VBox(tabs)

Expand Down
10 changes: 4 additions & 6 deletions library/cwm/src/lib/cwm/tree.rb
Expand Up @@ -35,13 +35,11 @@ def ui_term
class Tree < CustomWidget
# @return [Enumerable<TreeItem>]
attr_reader :items
def initialize(* items)
@items = items
end
attr_reader :label

# FIXME: handle labels better
def label
"?"
def initialize(* items, label:)
@label = label
@items = items
end

def contents
Expand Down
4 changes: 2 additions & 2 deletions library/cwm/src/lib/cwm/tree_pager.rb
Expand Up @@ -23,8 +23,8 @@ def pages
# A {Pager} that uses a {Tree} to select the {Page}s
class TreePager < Pager
# @param items [Array<PagerTreeItem>]
def initialize(*items)
@tree = Tree.new(*items)
def initialize(*items, label:)
@tree = Tree.new(*items, label: label)
pages = items.flat_map(&:pages)
super(*pages)
end
Expand Down

0 comments on commit aa590ca

Please sign in to comment.