class Notiffany::Notifier::Emacs::Client

Handles evaluating ELISP code in Emacs via Erb

Attributes

elisp_erb[R]

Public Class Methods

new(options) click to toggle source
# 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

Public Instance Methods

available?() click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

_emacs_eval(env, code) click to toggle source
# File lib/notiffany/notifier/emacs/client.rb, line 46
def _emacs_eval(env, code)
  Shellany::Sheller.run(env, @client, '--eval', code)
end