Class: Notiffany::Notifier::Tmux::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/notiffany/notifier/tmux/notification.rb

Overview

Wraps a notification with it's options

Instance Method Summary collapse

Constructor Details

#initialize(type, options) ⇒ Notification

Returns a new instance of Notification.


6
7
8
9
10
11
12
13
# File 'lib/notiffany/notifier/tmux/notification.rb', line 6

def initialize(type, options)
  @type = type
  @options = options
  @color = options[type.to_sym] || options[:default]
  @separator = options[:line_separator]
  @message_color = _value_for(:message_color)
  @client = Client.new(options[:display_on_all_clients] ? :all : nil)
end

Instance Method Details

#colorize(locations) ⇒ Object


33
34
35
36
37
# File 'lib/notiffany/notifier/tmux/notification.rb', line 33

def colorize(locations)
  locations.each do |location|
    client.set(location, color)
  end
end

#display_message(title, message) ⇒ Object


24
25
26
27
28
29
30
31
# File 'lib/notiffany/notifier/tmux/notification.rb', line 24

def display_message(title, message)
  message = _message_for(title, message)

  client.display_time = options[:timeout] * 1000
  client.message_fg = message_color
  client.message_bg = color
  client.display_message(message)
end

#display_title(title, message) ⇒ Object


15
16
17
18
19
20
21
22
# File 'lib/notiffany/notifier/tmux/notification.rb', line 15

def display_title(title, message)
  title_format = _value_for(:title_format)

  teaser_message = message.split("\n").first
  display_title = format(title_format, title, teaser_message)

  client.title = display_title
end