Class: Hut::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/hut/window.rb

Instance Method Summary collapse

Constructor Details

#initialize(hut) ⇒ Window

Returns a new instance of Window.



5
6
7
8
9
10
# File 'lib/hut/window.rb', line 5

def initialize(hut)
  @out = $stdout
  @columns, @lines = HighLine::SystemExtensions.terminal_size
  @room = nil
  @input = Input.new self
end

Instance Method Details

#new_message(body) ⇒ Object



33
34
35
# File 'lib/hut/window.rb', line 33

def new_message(body)
  @room.new_message body
end

#room=(room) ⇒ Object



12
13
14
15
# File 'lib/hut/window.rb', line 12

def room=(room)
  @room = room
  update
end

#room_was_updated(room) ⇒ Object



27
28
29
30
31
# File 'lib/hut/window.rb', line 27

def room_was_updated(room)
  if room == @room
    update
  end
end

#updateObject



17
18
19
20
21
22
23
24
25
# File 'lib/hut/window.rb', line 17

def update
  clear
  print_header
  @room.last_messages(@lines - 4).each do |msg|
    @out.print "#{msg.formatted_for_print}\n"
  end
  @out.flush
  print_footer
end