module World

Public Class Methods

add(being) click to toggle source
# File lib/tools/world.rb, line 23
def self.add(being)
  @objects.push(being)
end
find_name(name) click to toggle source
# File lib/tools/world.rb, line 33
def self.find_name(name)
  @objects.each do |being|
    return being if being.name == name
  end
end
find_tag(tag) click to toggle source
# File lib/tools/world.rb, line 39
def self.find_tag(tag)
  beings = []
  @objects.each do |being|
    beings.push(being) if being.tags.include?(tag)
  end
  return beings
end
find_tags(tags) click to toggle source
# File lib/tools/world.rb, line 47
def self.find_tags(tags)
  return @objects if tags.empty?
  beings = []
  return @objects if tags.empty?
  @objects.each do |being|
    new = tags.clone
    new.delete_if { |t| being.tags.include?(t) }
    beings.push(being) if new.empty?
  end
  return beings
end
setup(beings) click to toggle source
# File lib/tools/world.rb, line 27
def self.setup(beings)
  beings.each do |ary|
    add(WorldObject.new(ary[0], ary[1], ary[2]))
  end
end