Class: RubyJard::LayoutCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_jard/layout_calculator.rb

Overview

Layout calculator based on screen resolution to decide the height, width, visibility, data size of each children screen. TODO: Right now, the sizes are fixed regardless of current screen data size.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(layout_template:, width: 0, height: 0, x: 0, y: 0, config: RubyJard.config) ⇒ LayoutCalculator

Returns a new instance of LayoutCalculator.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby_jard/layout_calculator.rb', line 14

def initialize(
  layout_template:, width: 0, height: 0, x: 0, y: 0,
  config: RubyJard.config
)
  @layout_template = layout_template
  @width = width
  @height = height
  @x = x
  @y = y
  @layouts = []
  @config = config
end

Class Method Details

.calculate(**args) ⇒ Object



10
11
12
# File 'lib/ruby_jard/layout_calculator.rb', line 10

def self.calculate(**args)
  new(**args).calculate
end

Instance Method Details

#calculateObject



27
28
29
30
31
# File 'lib/ruby_jard/layout_calculator.rb', line 27

def calculate
  @layouts = []
  calculate_layout(@layout_template, @width, @height, @x, @y, nil)
  @layouts
end