Class: Falling::MessagesView
Constant Summary collapse
- MAX_MESSAGES =
64
Instance Method Summary collapse
- #add_message(message) ⇒ Object
-
#initialize(universe:) ⇒ MessagesView
constructor
A new instance of MessagesView.
- #refresh ⇒ Object
- #step! ⇒ Object
Constructor Details
#initialize(universe:) ⇒ MessagesView
Returns a new instance of MessagesView.
10 11 12 13 14 15 16 |
# File 'lib/falling/messages_view.rb', line 10 def initialize(universe:) Falling.logger.info "Initializing MapView." @universe = universe (Messaging::Message.new("Welcome to Falling.")) (Messaging::Message.new("Press ? for help.")) super() end |
Instance Method Details
#add_message(message) ⇒ Object
34 35 36 37 |
# File 'lib/falling/messages_view.rb', line 34 def () .insert(0, ) .slice(0, MAX_MESSAGES) end |
#refresh ⇒ Object
39 40 41 42 43 44 |
# File 'lib/falling/messages_view.rb', line 39 def refresh window.clear window.box(0, 0) super end |
#step! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/falling/messages_view.rb', line 18 def step! character = window.getch Falling.logger.debug "User input: #{character.inspect}." case character when "q" return false when "?" (Messaging::Message.new( "Controls:\n - q to quit\n - literally nothing else" )) end true end |