Class: Gobstones::Lang::Color

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

Direct Known Subclasses

Azul, Negro, Rojo, Verde

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



7
8
9
# File 'lib/gobstones/lang/literals/color.rb', line 7

def self.all
  [Azul, Negro, Rojo, Verde]
end

.orderObject



11
12
13
# File 'lib/gobstones/lang/literals/color.rb', line 11

def self.order
  [Azul, Negro, Rojo, Verde]
end

Instance Method Details

#<(other) ⇒ Object



15
16
17
# File 'lib/gobstones/lang/literals/color.rb', line 15

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

#oppositeObject



19
20
21
# File 'lib/gobstones/lang/literals/color.rb', line 19

def opposite
  raise Runner::GobstonesTypeError, "colors don't have opposite"
end

#return_typeObject



23
24
25
# File 'lib/gobstones/lang/literals/color.rb', line 23

def return_type
  :Color
end