Class: RubiksCube::Cubie

Inherits:
Struct
  • Object
show all
Defined in:
lib/rubiks_cube/cubie.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



3
4
5
# File 'lib/rubiks_cube/cubie.rb', line 3

def state
  @state
end

Instance Method Details

#==(other) ⇒ Object



4
5
6
# File 'lib/rubiks_cube/cubie.rb', line 4

def ==(other)
  state == other.state
end

#rotateObject



13
14
15
# File 'lib/rubiks_cube/cubie.rb', line 13

def rotate
  Cubie.new(state.dup).rotate!
end

#rotate!Object



8
9
10
11
# File 'lib/rubiks_cube/cubie.rb', line 8

def rotate!
  self.state = state.split('').rotate.join
  self
end

#to_sObject



17
18
19
# File 'lib/rubiks_cube/cubie.rb', line 17

def to_s
  state
end