Class: Text2048::Tile

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/text2048/tile.rb

Overview

2048 tile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, status = nil) ⇒ Tile

Returns a new instance of Tile.



14
15
16
17
# File 'lib/text2048/tile.rb', line 14

def initialize(value, status = nil)
  @value = value
  @status = status
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/text2048/tile.rb', line 10

def status
  @status
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/text2048/tile.rb', line 9

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
# File 'lib/text2048/tile.rb', line 28

def ==(other)
  @value.to_i == other.to_i
end

#clear_statusObject



19
20
21
22
# File 'lib/text2048/tile.rb', line 19

def clear_status
  @status = nil
  self
end

#merged?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/text2048/tile.rb', line 24

def merged?
  @status == :merged
end