Class: ConsoleShogi::Terminal::DisplayArea

Inherits:
Object
  • Object
show all
Defined in:
lib/console_shogi/terminal/display_area.rb

Defined Under Namespace

Modules: Komadai Classes: Board, History, Infomation, Others, Position

Constant Summary collapse

OTHERS =
:others
BOARD =
:board
SENTE_KOMADAI =
:sente_komadai
GOTE_KOMADAI =
:gote_komadai

Class Method Summary collapse

Class Method Details

.board?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/console_shogi/terminal/display_area.rb', line 32

def board?
  Board == self
end

.end_positionObject



24
25
26
# File 'lib/console_shogi/terminal/display_area.rb', line 24

def end_position
  self::END_POSITION
end

.fetch_area(x:, y:) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/console_shogi/terminal/display_area.rb', line 12

def fetch_area(x:, y:)
  [Board, Komadai::Gote, Komadai::Sente, History::Back, History::Forward, History::Resume, Infomation].each do |klass|
    return klass if klass.in?(x: x, y: y)
  end

  Others
end

.history?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/console_shogi/terminal/display_area.rb', line 40

def history?
  [History::Back, History::Forward, History::Resume].include?(self)
end

.in?(x:, y:) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/console_shogi/terminal/display_area.rb', line 48

def in?(x:, y:)
  Range.new(start_position.x, end_position.x).include?(x) &&
    Range.new(start_position.y, end_position.y).include?(y)
end

.komadai?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/console_shogi/terminal/display_area.rb', line 36

def komadai?
  [Komadai::Gote, Komadai::Sente].include?(self)
end

.nameObject



28
29
30
# File 'lib/console_shogi/terminal/display_area.rb', line 28

def name
  self::NAME
end

.outside?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/console_shogi/terminal/display_area.rb', line 44

def outside?
  [History::Back, History::Forward, History::Resume, Infomation, Others].include?(self)
end

.start_positionObject



20
21
22
# File 'lib/console_shogi/terminal/display_area.rb', line 20

def start_position
  self::START_POSITION
end