Class: Tweet::Note

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

Overview

Represents a unique notification message. One of these objects is passed to the show() method of the Notifier.

The message can be printed by simply printing the Note or by accessing note.message. The Note also contains a title, a duration, a priority, the application (program) that activated it, the connection method that it used, and the timestamp of when the message was requested. All of these parameters (except for the method and time) rely on the application being honest, and have no built-in effects. Any interpretation is done by the Notifier.

A Note may also include an array of requested notifiers (see Monitor).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, message, duration, priority, application, notifiers = [], method_received = :built_in) ⇒ Note

Creates a new Note.



170
171
172
173
174
# File 'lib/tweet.rb', line 170

def initialize(title, message, duration, priority, application, notifiers=[], method_received=:built_in)
  @title, @message, @duration, @priority, @application, @method_received = title, message, duration.to_i, priority.to_i, application, method_received
  @requested_notifiers = notifiers
  time = Time.now
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



167
168
169
# File 'lib/tweet.rb', line 167

def application
  @application
end

#durationObject (readonly)

Returns the value of attribute duration.



167
168
169
# File 'lib/tweet.rb', line 167

def duration
  @duration
end

#messageObject (readonly)

Returns the value of attribute message.



167
168
169
# File 'lib/tweet.rb', line 167

def message
  @message
end

#method_receivedObject (readonly)

Returns the value of attribute method_received.



167
168
169
# File 'lib/tweet.rb', line 167

def method_received
  @method_received
end

#priorityObject (readonly)

Returns the value of attribute priority.



167
168
169
# File 'lib/tweet.rb', line 167

def priority
  @priority
end

#requested_notifiersObject (readonly)

Returns the value of attribute requested_notifiers.



167
168
169
# File 'lib/tweet.rb', line 167

def requested_notifiers
  @requested_notifiers
end

#timeObject (readonly)

Returns the value of attribute time.



167
168
169
# File 'lib/tweet.rb', line 167

def time
  @time
end

#titleObject (readonly)

Returns the value of attribute title.



167
168
169
# File 'lib/tweet.rb', line 167

def title
  @title
end

Class Method Details

.critical(title, message, duration, application, method_received = :built_in) ⇒ Object

Shortcut for making a new note with the CRITICAL priority.



197
198
199
# File 'lib/tweet.rb', line 197

def Note.critical(title, message, duration, application, method_received=:built_in)
  self.new(title, message, duration, PRI['CRITICAL'], application, [], method_received)
end

.debug(title, message, duration, application, method_received = :built_in) ⇒ Object

Shortcut for making a new note with the DEBUG priority.



202
203
204
# File 'lib/tweet.rb', line 202

def Note.debug(title, message, duration, application, method_received=:built_in)
  self.new(title, message, duration, PRI['DEBUG'], application, [], method_received)
end

.info(title, message, duration, application, method_received = :built_in) ⇒ Object

Shortcut for making a new note with the INFO priority.



182
183
184
# File 'lib/tweet.rb', line 182

def Note.info(title, message, duration, application, method_received=:built_in)
  self.new(title, message, duration, PRI['INFO'], application, [], method_received)
end

.low(title, message, duration, application, method_received = :built_in) ⇒ Object

Shortcut for making a new note with the LOW priority.



192
193
194
# File 'lib/tweet.rb', line 192

def Note.low(title, message, duration, application, method_received=:built_in)
  self.new(title, message, duration, PRI['LOW'], application, [], method_received)
end

.simple(message) ⇒ Object

Shortcut for calling Note.info with a duration of 0.



177
178
179
# File 'lib/tweet.rb', line 177

def Note.simple(message)
  self.info(message, message, 0, $0)
end

.warning(title, message, duration, application, method_received = :built_in) ⇒ Object

Shortcut for making a new note with the WARNING priority.



187
188
189
# File 'lib/tweet.rb', line 187

def Note.warning(title, message, duration, application, method_received=:built_in)
  self.new(title, message, duration, PRI['WARNING'], application, [], method_received)
end

Instance Method Details

#to_sObject

Printing the Note prints the message.



207
208
209
# File 'lib/tweet.rb', line 207

def to_s
  @message
end