Class: Cline::Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cline::Notification
- Defined in:
- lib/cline/notification.rb
Class Method Summary collapse
Instance Method Summary collapse
- #detect_url(protocols = %w(http https)) ⇒ Object
- #display ⇒ Object
- #display_message ⇒ Object
- #id_alias_string ⇒ Object
- #message=(m) ⇒ Object
Class Method Details
.clean(pool_size) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/cline/notification.rb', line 48 def clean(pool_size) order('notified_at DESC'). order(:display_count). offset(pool_size). destroy_all end |
.display(offset = 0) ⇒ Object
40 41 42 |
# File 'lib/cline/notification.rb', line 40 def display(offset = 0) earliest(1, offset).first.display end |
.normalize_message(m) ⇒ Object
44 45 46 |
# File 'lib/cline/notification.rb', line 44 def (m) m.gsub(/[\r\n]/, '') end |
Instance Method Details
#detect_url(protocols = %w(http https)) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/cline/notification.rb', line 72 def detect_url(protocols = %w(http https)) regexp = URI.regexp(protocols) if match = .match(regexp) match.to_s else nil end end |
#display ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/cline/notification.rb', line 56 def display Cline.out_stream.tap do |out| out.puts out.flush if out.respond_to?(:flush) end increment! :display_count end |
#display_message ⇒ Object
66 67 68 69 70 |
# File 'lib/cline/notification.rb', line 66 def display_time = notified_at.strftime('%Y/%m/%d %H:%M') "[#{display_time}][#{display_count}][#{id_alias_string}] #{}" end |
#id_alias_string ⇒ Object
82 83 84 |
# File 'lib/cline/notification.rb', line 82 def id_alias_string id_alias.to_i.to_s(36) end |
#message=(m) ⇒ Object
35 36 37 |
# File 'lib/cline/notification.rb', line 35 def (m) super Notification.(m) end |