Class: Field

Inherits:
Object
  • Object
show all
Defined in:
lib/software_challenge_client/field.rb

Overview

Ein Feld des Spielfelds. Ein Spielfeld ist durch den index eindeutig identifiziert. Das type Attribut gibt an, um welchen Feldtyp es sich handelt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, index) ⇒ Field

Konstruktor

Parameters:

  • type (FieldType)

    Feldtyp

  • index (Integer)

    Index



18
19
20
21
# File 'lib/software_challenge_client/field.rb', line 18

def initialize(type, index)
  self.type = type
  @index = index
end

Instance Attribute Details

#indexInteger (readonly)

Returns der Index des Feldes (0 bis 64).

Returns:

  • (Integer)

    der Index des Feldes (0 bis 64)



12
13
14
# File 'lib/software_challenge_client/field.rb', line 12

def index
  @index
end

#typeFieldType

Returns der Typ des Feldes.

Returns:



9
10
11
# File 'lib/software_challenge_client/field.rb', line 9

def type
  @type
end

Instance Method Details

#==(another_field) ⇒ Object



23
24
25
26
# File 'lib/software_challenge_client/field.rb', line 23

def ==(another_field)
  return self.type == another_field.type &&
    self.index == another_field.index
end

#to_sObject



28
29
30
# File 'lib/software_challenge_client/field.rb', line 28

def to_s
  return "Feld ##{self.index}, Typ = #{self.type}"
end