Class: Uh::Layout::Arrangers::FixedWidth

Inherits:
Object
  • Object
show all
Defined in:
lib/uh/layout/arrangers/fixed_width.rb

Constant Summary collapse

DEFAULT_WIDTH =
484

Instance Method Summary collapse

Constructor Details

#initialize(entries, geo, width: DEFAULT_WIDTH) ⇒ FixedWidth

Returns a new instance of FixedWidth.



7
8
9
10
11
# File 'lib/uh/layout/arrangers/fixed_width.rb', line 7

def initialize entries, geo, width: DEFAULT_WIDTH
  @entries  = entries
  @geo      = geo
  @width    = width
end

Instance Method Details

#arrangeObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/uh/layout/arrangers/fixed_width.rb', line 13

def arrange
  return if @entries.empty?
  @entries.each_with_index do |column, i|
    column.x      = @width * i + @geo.x
    column.y      = @geo.y
    column.width  = @width
    column.height = @geo.height
  end
  @entries.last.width = @geo.width - (@entries.last.x - @geo.x)
end

#max_count?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/uh/layout/arrangers/fixed_width.rb', line 24

def max_count?
  (@geo.width / (@entries.size + 1)) < @width
end