Class: Uh::Layout::View

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
GeoAccessors
Defined in:
lib/uh/layout/view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, geo) ⇒ View

Returns a new instance of View.



16
17
18
19
20
21
22
23
# File 'lib/uh/layout/view.rb', line 16

def initialize id, geo
  unless id.kind_of? String
    fail ArgumentError, "expect `id' to be a String, #{id.class} given"
  end
  @id       = id
  @geo      = geo.dup
  @columns  = Container.new
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



14
15
16
# File 'lib/uh/layout/view.rb', line 14

def columns
  @columns
end

#geoObject (readonly)

Returns the value of attribute geo.



14
15
16
# File 'lib/uh/layout/view.rb', line 14

def geo
  @geo
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/uh/layout/view.rb', line 14

def id
  @id
end

Instance Method Details

#arrange_columnsObject



47
48
49
50
51
# File 'lib/uh/layout/view.rb', line 47

def arrange_columns
  @columns.remove &:empty?
  arranger.arrange
  @columns.each &:arrange_clients
end

#arrangerObject



43
44
45
# File 'lib/uh/layout/view.rb', line 43

def arranger
  Arrangers::FixedWidth.new @columns, @geo
end

#clientsObject



29
30
31
# File 'lib/uh/layout/view.rb', line 29

def clients
  @columns.inject([]) { |m, column| m + column.clients }
end

#current_column_or_createObject



37
38
39
40
41
# File 'lib/uh/layout/view.rb', line 37

def current_column_or_create
  current_column or Column.new(@geo).tap do |column|
    @columns << column
  end
end

#hideObject



53
54
55
# File 'lib/uh/layout/view.rb', line 53

def hide
  clients.each &:hide
end

#include?(client) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/uh/layout/view.rb', line 33

def include? client
  @columns.any? { |column| column.include? client }
end

#to_sObject



25
26
27
# File 'lib/uh/layout/view.rb', line 25

def to_s
  "VIEW ##{@id}, geo: #{@geo}"
end