Class: Gobstones::Lang::Direction

Inherits:
Literal show all
Defined in:
lib/gobstones/lang/literals/direction.rb

Direct Known Subclasses

Este, Norte, Oeste, Sur

Constant Summary

Constants inherited from Literal

Literal::OPERATORS_MAPPING

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Literal

#<=>, #==, #evaluate, #if_false, #if_true, #not, #same_type_as, #true?

Methods inherited from Expression

#evaluate, #is_function_call?

Methods included from EqualityDefinition

#==, #equality_attributes

Class Method Details

.allObject



6
7
8
# File 'lib/gobstones/lang/literals/direction.rb', line 6

def self.all
  [Norte, Sur, Este, Oeste]
end

.orderObject



10
11
12
# File 'lib/gobstones/lang/literals/direction.rb', line 10

def self.order
  [Norte, Este, Sur, Oeste]
end

Instance Method Details

#<(other) ⇒ Object



14
15
16
# File 'lib/gobstones/lang/literals/direction.rb', line 14

def <(other)
  self.class.order.index(self.class) < self.class.order.index(other.class)
end

#return_typeObject



18
19
20
# File 'lib/gobstones/lang/literals/direction.rb', line 18

def return_type
  :Direction
end