Class: Reight::Navigator::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/reight/app/navigator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessage

Returns a new instance of Message.



133
134
135
# File 'lib/reight/app/navigator.rb', line 133

def initialize()
  @priority = 0
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



137
138
139
# File 'lib/reight/app/navigator.rb', line 137

def text
  @text
end

Instance Method Details

#flash(str, priority: 1) ⇒ Object



139
140
141
142
143
144
145
# File 'lib/reight/app/navigator.rb', line 139

def flash(str, priority: 1)
  return if priority < @priority
  @text, @priority = str, priority
  set_timeout 2, id: :message_flash do
    @text, @priority = '', 0
  end
end

#spriteObject



147
148
149
150
151
152
153
154
155
156
# File 'lib/reight/app/navigator.rb', line 147

def sprite()
  @sprite ||= RubySketch::Sprite.new.tap do |sp|
    sp.draw do
      next unless @text
      fill 100
      text_align LEFT, CENTER
      draw_text @text, 0, 0, sp.w, sp.h
    end
  end
end