Archived
1
0
Fork 0

Add method Curses::React::Component#parent=

This commit is contained in:
Braiden Vasco 2017-07-27 23:50:29 +00:00
parent f375e2d103
commit c05be0af92

View file

@ -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