Class: Gamefic::Direction

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/direction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Direction

Returns a new instance of Direction.



5
6
7
8
9
10
11
12
13
# File 'lib/gamefic/direction.rb', line 5

def initialize args = {}
  args.each { |key, value|
    send "#{key}=", value
  }
  if !reverse.nil?
    reverse.reverse = self
  end
  proper_named = true
end

Instance Attribute Details

#adjectiveObject

Returns the value of attribute adjective.



4
5
6
# File 'lib/gamefic/direction.rb', line 4

def adjective
  @adjective
end

#adverbObject

Returns the value of attribute adverb.



4
5
6
# File 'lib/gamefic/direction.rb', line 4

def adverb
  @adverb
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/gamefic/direction.rb', line 4

def name
  @name
end

#reverseObject

Returns the value of attribute reverse.



4
5
6
# File 'lib/gamefic/direction.rb', line 4

def reverse
  @reverse
end

Class Method Details

.find(str) ⇒ Object



29
30
31
32
# File 'lib/gamefic/direction.rb', line 29

def self.find(str)
  x = { "north" => NORTH, "south" => SOUTH, "west" => WEST, "east" => EAST, "up" => UP, "down" => DOWN, "northwest" => NORTHWEST, "northeast" => NORTHEAST, "southwest" => SOUTHWEST, "southeast" => SOUTHEAST }
  x[str]
end

Instance Method Details

#synonymsObject



23
24
25
# File 'lib/gamefic/direction.rb', line 23

def synonyms
  "#{adjective} #{adverb}"
end

#to_sObject



26
27
28
# File 'lib/gamefic/direction.rb', line 26

def to_s
  @name
end