Class: Notiffany::Notifier::Emacs::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/notiffany/notifier/emacs/client.rb

Overview

Handles evaluating ELISP code in Emacs via Erb

Defined Under Namespace

Classes: Elisp

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)

28
29
30
31
32
# File 'lib/notiffany/notifier/emacs/client.rb', line 28

def initialize(options)
  @client = options[:client]
  @elisp_erb = options[:elisp_erb]
  raise ArgumentError, 'No :elisp_erb option given!' unless elisp_erb
end

Instance Attribute Details

#elisp_erbObject (readonly)

Returns the value of attribute elisp_erb


7
8
9
# File 'lib/notiffany/notifier/emacs/client.rb', line 7

def elisp_erb
  @elisp_erb
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)

34
35
36
37
# File 'lib/notiffany/notifier/emacs/client.rb', line 34

def available?
  script = Elisp.new(@elisp_erb, nil, nil, nil).result
  _emacs_eval({ 'ALTERNATE_EDITOR' => 'false' }, script)
end

#notify(color, bgcolor, message = nil) ⇒ Object


39
40
41
42
# File 'lib/notiffany/notifier/emacs/client.rb', line 39

def notify(color, bgcolor, message = nil)
  elisp = Elisp.new(elisp_erb, color, bgcolor, message).result
  _emacs_eval({ 'ALTERNATE_EDITOR' => 'false' }, elisp)
end