Class: Direction
- Inherits:
-
Object
- Object
- Direction
- Includes:
- Gamefic::Serialize
- 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.
9 10 11 12 13 |
# File 'lib/gamefic-standard/direction.rb', line 9 def initialize **args args.each { |key, value| send "#{key}=", value } end |
Instance Attribute Details
#adjective ⇒ String
16 17 18 |
# File 'lib/gamefic-standard/direction.rb', line 16 def adjective @adjective || @name end |
#adverb ⇒ String
21 22 23 |
# File 'lib/gamefic-standard/direction.rb', line 21 def adverb @adverb || @name end |
#name ⇒ String
7 8 9 |
# File 'lib/gamefic-standard/direction.rb', line 7 def name @name end |
Class Method Details
.compass ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gamefic-standard/direction.rb', line 39 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
26 27 28 |
# File 'lib/gamefic-standard/direction.rb', line 26 def synonyms "#{adjective} #{adverb}" end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/gamefic-standard/direction.rb', line 34 def to_s @name end |