Sha256: 11d98f7ca1b84ee48b711dc9f536aeede154bd06e0bffbc276a271b7badbe260
Contents?: true
Size: 1.09 KB
Versions: 7
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true class Room < Thing attr_writer :explicit_exits set_default explicit_exits: true def explicit_exits? @explicit_exits end def tell(message) children.each { |c| c.tell message } end # @return [Array<Portal>] def portals children.that_are(Portal) end # @param destination [Room] # @param direction [Direction, String, nil] # @param type [Class<Portal>] # @param two_way [Boolean] # @return [Portal, Array<Portal>] def connect destination, direction: nil, type: Portal, two_way: true direction = Direction.find(direction) here = type.new(parent: self, destination: destination, direction: Direction.find(direction)) return here unless two_way there = type.new(parent: destination, destination: self, direction: direction&.reverse) [here, there] end class << self def explicit_exits? default_attributes[:explicit_exits] end def explicit_exits=(bool) set_default explicit_exits: bool end end end
Version data entries
7 entries across 7 versions & 1 rubygems