Class: Yildun::Pane
- Inherits:
-
Object
- Object
- Yildun::Pane
- Defined in:
- lib/yildun/pane.rb,
sig/yildun.rbs
Instance Attribute Summary collapse
-
#children ⇒ Array[untyped]
readonly
Returns the value of attribute children.
-
#orientation ⇒ Symbol
readonly
Returns the value of attribute orientation.
Instance Method Summary collapse
-
#initialize(tab = nil, orientation: :leaf) ⇒ Pane
constructor
A new instance of Pane.
- #leaf? ⇒ Boolean
- #split(tab, orientation: :horizontal) ⇒ Pane
Constructor Details
#initialize(tab = nil, orientation: :leaf) ⇒ Pane
Returns a new instance of Pane.
7 8 9 |
# File 'lib/yildun/pane.rb', line 7 def initialize(tab = nil, orientation: :leaf) @children, @orientation = tab ? [tab] : [], orientation end |
Instance Attribute Details
#children ⇒ Array[untyped] (readonly)
Returns the value of attribute children.
5 6 7 |
# File 'lib/yildun/pane.rb', line 5 def children @children end |
#orientation ⇒ Symbol (readonly)
Returns the value of attribute orientation.
5 6 7 |
# File 'lib/yildun/pane.rb', line 5 def orientation @orientation end |
Instance Method Details
#leaf? ⇒ Boolean
11 |
# File 'lib/yildun/pane.rb', line 11 def leaf? = @orientation == :leaf |
#split(tab, orientation: :horizontal) ⇒ Pane
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/yildun/pane.rb', line 12 def split(tab, orientation: :horizontal) if leaf? && @children.empty? @children << (tab.is_a?(Pane) ? tab : Pane.new(tab)) return self end if leaf? existing = @children.map { |child| child.is_a?(Pane) ? child : Pane.new(child) } @children = existing end @orientation = orientation @children << (tab.is_a?(Pane) ? tab : Pane.new(tab)) self end |