Class: Uh::Layout::Tag

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#columnsObject (readonly)

Returns the value of attribute columns.



13
14
15
# File 'lib/uh/layout/tag.rb', line 13

def columns
  @columns
end

#geoObject (readonly)

Returns the value of attribute geo.



13
14
15
# File 'lib/uh/layout/tag.rb', line 13

def geo
  @geo
end

#idObject (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

#clientsObject



28
29
30
# File 'lib/uh/layout/tag.rb', line 28

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

#current_column_or_createObject



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

#hideObject



42
43
44
# File 'lib/uh/layout/tag.rb', line 42

def hide
  clients.each &:hide
end

#include?(client) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/uh/layout/tag.rb', line 32

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

#to_sObject



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

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