Class: Upwords::Graphics

Inherits:
Curses::Window
  • Object
show all
Defined in:
lib/upwords/graphics.rb

Instance Method Summary collapse

Constructor Details

#initialize(game) ⇒ Graphics

Returns a new instance of Graphics.



6
7
8
9
10
11
12
13
# File 'lib/upwords/graphics.rb', line 6

def initialize(game)
  super(0,0,0,0)
  @game = game
  @board = @game.board
  @cursor = @game.cursor 
  @message = ''
  @rack_visibility = false
end

Instance Method Details

#hide_rackObject



39
40
41
# File 'lib/upwords/graphics.rb', line 39

def hide_rack
  @rack_visibility = false
end

#message=(new_message) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/upwords/graphics.rb', line 27

def message=(new_message)
  if new_message.nil?
    @message = ""
  else
    @message = new_message 
  end
end

#refreshObject



15
16
17
18
19
# File 'lib/upwords/graphics.rb', line 15

def refresh
  clear
  self << self.to_s
  super
end

#show_rackObject



35
36
37
# File 'lib/upwords/graphics.rb', line 35

def show_rack
  @rack_visibility = true
end

#to_sObject



21
22
23
24
25
# File 'lib/upwords/graphics.rb', line 21

def to_s
  (draw_board + draw_message).zip(draw_stats).map do |board_row, stats_row|
    (board_row.to_s) + (stats_row.to_s)
  end.join("\n")
end

#toggle_rack_visibilityObject



43
44
45
# File 'lib/upwords/graphics.rb', line 43

def toggle_rack_visibility
  @rack_visibility = !@rack_visibility
end