Skip to content

Commit

Permalink
Add a treenode example
Browse files Browse the repository at this point in the history
  • Loading branch information
tatut committed Jan 13, 2024
1 parent 4a392c5 commit c144d66
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/LiveWeb-Examples/LWTreeNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ Class {
#category : #'LiveWeb-Examples'
}

{ #category : #'as yet unclassified' }
LWTreeNode class >> exampleSimpleTree [
<lwExample: 'Simple tree few items'>
^ self new beBranch
label: 'root';
child: 'My Documents' do: [ :d | d beBranch; child: 'Music'; child: 'Pictures' ];
child: 'Secret stuff (don''t look)' do: [ :d | d beBranch; child: 'Passwords & codes' do: [ :p | p beBranch; child: 'Nuclear launch codes' ] ];
yourself
]

{ #category : #'as yet unclassified' }
LWTreeNode >> beBranch [
leaf := false
Expand Down Expand Up @@ -38,6 +48,12 @@ LWTreeNode >> child: childLabel [
]
]

{ #category : #'as yet unclassified' }
LWTreeNode >> child: aLabel do: block [
block value: (self child: aLabel).
^ self
]

{ #category : #accessing }
LWTreeNode >> children [
^ReadStream on: children
Expand Down

0 comments on commit c144d66

Please sign in to comment.