Class: Direction
- Inherits:
-
Object
- Object
- Direction
- Defined in:
- lib/gamefic-standard/direction.rb
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.
7 8 9 10 11 |
# File 'lib/gamefic-standard/direction.rb', line 7 def initialize **args args.each { |key, value| send "#{key}=", value } end |
Instance Attribute Details
#adjective ⇒ String
14 15 16 |
# File 'lib/gamefic-standard/direction.rb', line 14 def adjective @adjective || @name end |
#adverb ⇒ String
19 20 21 |
# File 'lib/gamefic-standard/direction.rb', line 19 def adverb @adverb || @name end |
#name ⇒ String
5 6 7 |
# File 'lib/gamefic-standard/direction.rb', line 5 def name @name end |
Class Method Details
.compass ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gamefic-standard/direction.rb', line 37 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) } end |
Instance Method Details
#synonyms ⇒ String
24 25 26 |
# File 'lib/gamefic-standard/direction.rb', line 24 def synonyms "#{adjective} #{adverb}" end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/gamefic-standard/direction.rb', line 32 def to_s @name end |