Class: Tweet::Note
- Inherits:
-
Object
- Object
- Tweet::Note
- 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
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#method_received ⇒ Object
readonly
Returns the value of attribute method_received.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#requested_notifiers ⇒ Object
readonly
Returns the value of attribute requested_notifiers.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
-
.critical(title, message, duration, application, method_received = :built_in) ⇒ Object
Shortcut for making a new note with the CRITICAL priority.
-
.debug(title, message, duration, application, method_received = :built_in) ⇒ Object
Shortcut for making a new note with the DEBUG priority.
-
.info(title, message, duration, application, method_received = :built_in) ⇒ Object
Shortcut for making a new note with the INFO priority.
-
.low(title, message, duration, application, method_received = :built_in) ⇒ Object
Shortcut for making a new note with the LOW priority.
-
.simple(message) ⇒ Object
Shortcut for calling Note.info with a duration of 0.
-
.warning(title, message, duration, application, method_received = :built_in) ⇒ Object
Shortcut for making a new note with the WARNING priority.
Instance Method Summary collapse
-
#initialize(title, message, duration, priority, application, notifiers = [], method_received = :built_in) ⇒ Note
constructor
Creates a new Note.
-
#to_s ⇒ Object
Printing the Note prints the message.
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, , duration, priority, application, notifiers=[], method_received=:built_in) @title, @message, @duration, @priority, @application, @method_received = title, , duration.to_i, priority.to_i, application, method_received @requested_notifiers = notifiers time = Time.now end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
167 168 169 |
# File 'lib/tweet.rb', line 167 def application @application end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
167 168 169 |
# File 'lib/tweet.rb', line 167 def duration @duration end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
167 168 169 |
# File 'lib/tweet.rb', line 167 def @message end |
#method_received ⇒ Object (readonly)
Returns the value of attribute method_received.
167 168 169 |
# File 'lib/tweet.rb', line 167 def method_received @method_received end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
167 168 169 |
# File 'lib/tweet.rb', line 167 def priority @priority end |
#requested_notifiers ⇒ Object (readonly)
Returns the value of attribute requested_notifiers.
167 168 169 |
# File 'lib/tweet.rb', line 167 def requested_notifiers @requested_notifiers end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
167 168 169 |
# File 'lib/tweet.rb', line 167 def time @time end |
#title ⇒ Object (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, , duration, application, method_received=:built_in) self.new(title, , 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, , duration, application, method_received=:built_in) self.new(title, , 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, , duration, application, method_received=:built_in) self.new(title, , 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, , duration, application, method_received=:built_in) self.new(title, , 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() self.info(, , 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, , duration, application, method_received=:built_in) self.new(title, , duration, PRI['WARNING'], application, [], method_received) end |
Instance Method Details
#to_s ⇒ Object
Printing the Note prints the message.
207 208 209 |
# File 'lib/tweet.rb', line 207 def to_s @message end |