class Rchess::Paths::Rook

Public Class Methods

new(params) click to toggle source
Calls superclass method Rchess::Paths::Base::new
# File lib/rchess/paths/rook.rb, line 4
def initialize(params)
  @power = params.fetch(:power, 8)
  super(params)
end

Public Instance Methods

paths() click to toggle source
# File lib/rchess/paths/rook.rb, line 9
def paths
  [linear_paths].flatten(1)
end

Private Instance Methods

linear_paths() click to toggle source
# File lib/rchess/paths/rook.rb, line 15
def linear_paths
  [
    (1..@power).map{ |i| { x: 0,  y: i  } },
    (1..@power).map{ |i| { x: 0,  y: -i } },
    (1..@power).map{ |i| { x: i,  y: 0  } },
    (1..@power).map{ |i| { x: -i, y: 0  } }
  ]
end