Class: TreeOrganizer::Node

Inherits:
Object show all
Defined in:
lib/jirametrics/tree_organizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue: nil) ⇒ Node

Returns a new instance of Node.



10
11
12
13
# File 'lib/jirametrics/tree_organizer.rb', line 10

def initialize issue: nil
  @issue = issue
  @children = []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



8
9
10
# File 'lib/jirametrics/tree_organizer.rb', line 8

def children
  @children
end

#issueObject

Returns the value of attribute issue.



7
8
9
# File 'lib/jirametrics/tree_organizer.rb', line 7

def issue
  @issue
end

#parentObject

Returns the value of attribute parent.



7
8
9
# File 'lib/jirametrics/tree_organizer.rb', line 7

def parent
  @parent
end

Instance Method Details

#<=>(other) ⇒ Object



23
24
25
# File 'lib/jirametrics/tree_organizer.rb', line 23

def <=> other
  issue <=> other.issue
end

#children?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/jirametrics/tree_organizer.rb', line 27

def children?
  !@children.empty?
end

#inspectObject



19
20
21
# File 'lib/jirametrics/tree_organizer.rb', line 19

def inspect
  to_s
end

#to_sObject



15
16
17
# File 'lib/jirametrics/tree_organizer.rb', line 15

def to_s
  "Node(#{@issue&.key || 'Root'}, parent: #{@parent&.issue&.key || 'Root'}, children: #{@children.inspect})"
end