class Rchess::Paths::Bishop
Public Class Methods
new(params)
click to toggle source
Calls superclass method
Rchess::Paths::Base::new
# File lib/rchess/paths/bishop.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/bishop.rb, line 9 def paths [diag_paths].flatten(1).select do |path| path.select end end
Private Instance Methods
diag_paths()
click to toggle source
# File lib/rchess/paths/bishop.rb, line 17 def diag_paths [ (1..@power).map{ |i| { x: i, y: i } }, (1..@power).map{ |i| { x: i, y: -i } }, (1..@power).map{ |i| { x: -i, y: i } }, (1..@power).map{ |i| { x: -i, y: -i } } ] end