class Argyle::Layout::Factory
Public Instance Methods
create(klass)
click to toggle source
@param klass [Class<Argyle::Layout::Base>] Subclass of Argyle::Layout::Base
@return [Argyle::Layout::Base]
@raise [Argyle::Error::TypeError] If the layout is not a subclass of Argyle::Layout::Base
# File lib/argyle/layout/factory.rb, line 8 def create(klass) Argyle::Assert.klass(Argyle::Layout::Base, klass) areas = klass.area_prototypes.transform_values(&:unwrap) windows = areas.map(&method(:create_window)).to_h klass.new(areas, windows) end
Private Instance Methods
create_window(id, area)
click to toggle source
@param area [Argyle::Layout::Area]
@return [Ncurses::WINDOW]
# File lib/argyle/layout/factory.rb, line 24 def create_window(id, area) max_height = Ncurses.getmaxy(Ncurses.stdscr) max_width = Ncurses.getmaxx(Ncurses.stdscr) width = area.width || max_width height = area.height || max_height y = 0 x = 0 [id, Ncurses::WINDOW.new(height, width, y, x)] end