Class: Uh::Layout::Tag
- Inherits:
-
Object
- Object
- Uh::Layout::Tag
- Extended by:
- Forwardable
- Includes:
- GeoAccessors
- Defined in:
- lib/uh/layout/tag.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
- #clients ⇒ Object
- #current_column_or_create ⇒ Object
- #hide ⇒ Object
- #include?(client) ⇒ Boolean
-
#initialize(id, geo) ⇒ Tag
constructor
A new instance of Tag.
- #to_s ⇒ Object
Constructor Details
#initialize(id, geo) ⇒ Tag
Returns a new instance of Tag.
15 16 17 18 19 20 21 22 |
# File 'lib/uh/layout/tag.rb', line 15 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.
13 14 15 |
# File 'lib/uh/layout/tag.rb', line 13 def columns @columns end |
#geo ⇒ Object (readonly)
Returns the value of attribute geo.
13 14 15 |
# File 'lib/uh/layout/tag.rb', line 13 def geo @geo end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/uh/layout/tag.rb', line 13 def id @id end |
Instance Method Details
#clients ⇒ Object
28 29 30 |
# File 'lib/uh/layout/tag.rb', line 28 def clients @columns.inject([]) { |m, column| m + column.clients } end |
#current_column_or_create ⇒ Object
36 37 38 39 40 |
# File 'lib/uh/layout/tag.rb', line 36 def current_column_or_create current_column or Column.new(@geo).tap do |column| @columns << column end end |
#hide ⇒ Object
42 43 44 |
# File 'lib/uh/layout/tag.rb', line 42 def hide clients.each &:hide end |
#include?(client) ⇒ Boolean
32 33 34 |
# File 'lib/uh/layout/tag.rb', line 32 def include?(client) @columns.any? { |column| column.include? client } end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/uh/layout/tag.rb', line 24 def to_s "TAG ##{@id}, geo: #{@geo}" end |