Class: Carbuncle::Container

Inherits:
Object show all
Includes:
Enumerable
Defined in:
gems/carbuncle-core/mrblib/container.rb

Direct Known Subclasses

Game, Scene, Viewport

Constant Summary

Constants included from Enumerable

Enumerable::NONE

Instance Method Summary collapse

Methods included from Enumerable

__update_hash, #all?, #any?, #chain, #collect, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_slice, #each_with_index, #each_with_object, #entries, #filter_map, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #hash, #include?, #inject, #lazy, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reject, #reverse_each, #sort, #sort_by, #sum, #take, #take_while, #tally, #to_h, #uniq, #zip

Constructor Details

#initializeContainer

Returns a new instance of Container.



5
6
7
# File 'gems/carbuncle-core/mrblib/container.rb', line 5

def initialize
  @children = []
end

Instance Method Details

#add_child(child) ⇒ Object Also known as: <<



13
14
15
16
# File 'gems/carbuncle-core/mrblib/container.rb', line 13

def add_child(child)
  @children.push(child) unless @children.include?(child)
  self
end

#add_children(*children) ⇒ Object



20
21
22
23
# File 'gems/carbuncle-core/mrblib/container.rb', line 20

def add_children(*children)
  children.each { |c| add_child(c) }
  self
end

#childrenObject



9
10
11
# File 'gems/carbuncle-core/mrblib/container.rb', line 9

def children
  @children.dup
end

#drawObject



41
42
43
# File 'gems/carbuncle-core/mrblib/container.rb', line 41

def draw
  each(&:draw)
end

#each(&block) ⇒ Object



45
46
47
# File 'gems/carbuncle-core/mrblib/container.rb', line 45

def each(&block)
  @children.each(&block)
end

#remove_child(child) ⇒ Object Also known as: >>



25
26
27
28
# File 'gems/carbuncle-core/mrblib/container.rb', line 25

def remove_child(child)
  @children.delete(child)
  self
end

#remove_children(*children) ⇒ Object



32
33
34
35
# File 'gems/carbuncle-core/mrblib/container.rb', line 32

def remove_children(*children)
  each { |c| remove_child(c) }
  self      
end

#update(dt) ⇒ Object



37
38
39
# File 'gems/carbuncle-core/mrblib/container.rb', line 37

def update(dt)
  each { |c| c.update(dt) }
end