Module: Dogviz::Parent

Included in:
Container, System
Defined in:
lib/dogviz/parent.rb

Instance Method Summary collapse

Instance Method Details

#add(child) ⇒ Object



33
34
35
36
37
# File 'lib/dogviz/parent.rb', line 33

def add(child)
  @children << child
  nominate child.name => child if auto_nominate?
  child
end

#container(name, options = {}) ⇒ Object



21
22
23
# File 'lib/dogviz/parent.rb', line 21

def container(name, options={})
  add Container.new self, name, options
end

#find(name = nil, &matcher) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/dogviz/parent.rb', line 8

def find(name=nil, &matcher)
  if block_given?
    @by_name.find(&matcher)
  else
    raise 'Need to provide name or block' if name.nil?
    @by_name.lookup name
  end
end

#find_all(&matcher) ⇒ Object



3
4
5
6
# File 'lib/dogviz/parent.rb', line 3

def find_all(&matcher)
  raise MissingMatchBlockError.new unless block_given?
  @by_name.find_all(&matcher)
end

#group(name, options = {}) ⇒ Object



29
30
31
# File 'lib/dogviz/parent.rb', line 29

def group(name, options={})
  logical_container name, options
end

#logical_container(name, options = {}) ⇒ Object



25
26
27
# File 'lib/dogviz/parent.rb', line 25

def logical_container(name, options={})
  add LogicalContainer.new self, name, options
end

#root?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/dogviz/parent.rb', line 39

def root?
  not respond_to?(:parent)
end

#thing(name, options = {}) ⇒ Object



17
18
19
# File 'lib/dogviz/parent.rb', line 17

def thing(name, options={})
  add Thing.new self, name, options
end