Add method Curses::React::Component#parent=
This commit is contained in:
parent
f375e2d103
commit
c05be0af92
1 changed files with 7 additions and 1 deletions
|
@ -4,7 +4,7 @@ module Curses
|
|||
module React
|
||||
class Component
|
||||
def initialize(parent)
|
||||
@parent = parent
|
||||
self.parent = parent
|
||||
@props = {}.freeze
|
||||
end
|
||||
|
||||
|
@ -29,6 +29,12 @@ module Curses
|
|||
|
||||
attr_reader :parent, :props
|
||||
|
||||
def parent=(value)
|
||||
return if value.nil?
|
||||
raise TypeError, "expected #parent to be a #{Component}" unless value.is_a? Component
|
||||
@parent = value
|
||||
end
|
||||
|
||||
def window
|
||||
@window ||= parent&.subwin(props[:x], props[:y], props[:width], props[:height]) || Curses.stdscr
|
||||
end
|
||||
|
|
Reference in a new issue