Module: Gomoku::Utility

Defined in:
lib/gomoku/utility.rb

Overview

Helper methods

Class Method Summary collapse

Class Method Details

.asset_path(asset) ⇒ Object



34
35
36
# File 'lib/gomoku/utility.rb', line 34

def asset_path(asset)
  File.expand_path("../../../assets/#{asset}", __FILE__)
end

.c_to_x(c) ⇒ Object



10
11
12
# File 'lib/gomoku/utility.rb', line 10

def c_to_x(c)
  c * 40 - 20
end

.in_range?(r, c) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/gomoku/utility.rb', line 22

def in_range?(r, c)
  r >= 1 && r <= 19 && c >= 1 && c <= 19
end

.r_to_y(r) ⇒ Object



6
7
8
# File 'lib/gomoku/utility.rb', line 6

def r_to_y(r)
  r * 40 - 20
end

.toggle_color(color) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/gomoku/utility.rb', line 26

def toggle_color(color)
  if color == :black
    :white
  else
    :black
  end
end

.x_to_c(x) ⇒ Object



14
15
16
# File 'lib/gomoku/utility.rb', line 14

def x_to_c(x)
  (x.to_i + 20) / 40
end

.y_to_r(y) ⇒ Object



18
19
20
# File 'lib/gomoku/utility.rb', line 18

def y_to_r(y)
  (y.to_i + 20) / 40
end