Class: Gamefic::Standard::Direction
- Inherits:
-
Object
- Object
- Gamefic::Standard::Direction
- Defined in:
- lib/gamefic/standard/direction.rb
Overview
Descriptions of the geographical relationships between entities. Portals can use directions to identify the path to their destination, such as north, southwest, up, etc.
Constant Summary collapse
- NORTH =
compass[:north]
- SOUTH =
compass[:south]
- WEST =
compass[:west]
- EAST =
compass[:east]
- NORTHWEST =
compass[:northwest]
- SOUTHEAST =
compass[:southeast]
- NORTHEAST =
compass[:northeast]
- SOUTHWEST =
compass[:southwest]
- UP =
compass[:up]
- DOWN =
compass[:down]
- IN =
compass[:in]
- OUT =
compass[:out]
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**args) ⇒ Direction
constructor
A new instance of Direction.
- #synonyms ⇒ String
- #to_s ⇒ Object
Constructor Details
#initialize(**args) ⇒ Direction
Returns a new instance of Direction.
13 14 15 16 17 |
# File 'lib/gamefic/standard/direction.rb', line 13 def initialize **args args.each { |key, value| send "#{key}=", value } end |
Instance Attribute Details
#adjective ⇒ String
20 21 22 |
# File 'lib/gamefic/standard/direction.rb', line 20 def adjective @adjective || @name end |
#adverb ⇒ String
25 26 27 |
# File 'lib/gamefic/standard/direction.rb', line 25 def adverb @adverb || @name end |
#name ⇒ String
11 12 13 |
# File 'lib/gamefic/standard/direction.rb', line 11 def name @name end |
Class Method Details
.compass ⇒ Hash{Symbol => Direction}
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gamefic/standard/direction.rb', line 44 def compass @compass ||= { north: Direction.new(name: 'north', adjective: 'northern', reverse: :south), south: Direction.new(name: 'south', adjective: 'southern', reverse: :north), west: Direction.new(name: 'west', adjective: 'western', reverse: :east), east: Direction.new(name: 'east', adjective: 'eastern', reverse: :west), northwest: Direction.new(name: 'northwest', adjective: 'northwestern', reverse: :southeast), southeast: Direction.new(name: 'southeast', adjective: 'southeastern', reverse: :northwest), northeast: Direction.new(name: 'northeast', adjective: 'northeastern', reverse: :southwest), southwest: Direction.new(name: 'southwest', adjective: 'southwestern', reverse: :northeast), up: Direction.new(name: 'up', adjective: 'upwards', reverse: :down), down: Direction.new(name: 'down', adjective: 'downwards', reverse: :up), in: Direction.new(name: 'in', adjective: 'inside', reverse: :out), out: Direction.new(name: 'in', adjective: 'inside', reverse: :in) } end |
.find(dir) ⇒ Direction?
67 68 69 70 71 |
# File 'lib/gamefic/standard/direction.rb', line 67 def find(dir) return dir if dir.is_a?(Direction) compass[dir.to_s.downcase.to_sym] end |
.names ⇒ Object
61 62 63 |
# File 'lib/gamefic/standard/direction.rb', line 61 def names compass.values.map(&:name) end |
Instance Method Details
#synonyms ⇒ String
30 31 32 |
# File 'lib/gamefic/standard/direction.rb', line 30 def synonyms "#{adjective} #{adverb}" end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/gamefic/standard/direction.rb', line 38 def to_s @name end |