Class: Uh::Layout::View
- Inherits:
-
Object
- Object
- Uh::Layout::View
- Extended by:
- Forwardable
- Includes:
- GeoAccessors
- Defined in:
- lib/uh/layout/view.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#geo ⇒ Object
readonly
Returns the value of attribute geo.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #arrange_columns ⇒ Object
- #arranger ⇒ Object
- #clients ⇒ Object
- #current_column_or_create ⇒ Object
- #hide ⇒ Object
- #include?(client) ⇒ Boolean
-
#initialize(id, geo) ⇒ View
constructor
A new instance of View.
- #to_s ⇒ Object
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
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
14 15 16 |
# File 'lib/uh/layout/view.rb', line 14 def columns @columns end |
#geo ⇒ Object (readonly)
Returns the value of attribute geo.
14 15 16 |
# File 'lib/uh/layout/view.rb', line 14 def geo @geo end |
#id ⇒ Object (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_columns ⇒ Object
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 |
#arranger ⇒ Object
43 44 45 |
# File 'lib/uh/layout/view.rb', line 43 def arranger Arrangers::FixedWidth.new @columns, @geo end |
#clients ⇒ Object
29 30 31 |
# File 'lib/uh/layout/view.rb', line 29 def clients @columns.inject([]) { |m, column| m + column.clients } end |
#current_column_or_create ⇒ Object
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 |
#hide ⇒ Object
53 54 55 |
# File 'lib/uh/layout/view.rb', line 53 def hide clients.each &:hide end |
#include?(client) ⇒ Boolean
33 34 35 |
# File 'lib/uh/layout/view.rb', line 33 def include? client @columns.any? { |column| column.include? client } end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/uh/layout/view.rb', line 25 def to_s "VIEW ##{@id}, geo: #{@geo}" end |