Class: Cadre::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/cadre/notifier.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Notifier

Returns a new instance of Notifier.

Yields:

  • (_self)

Yield Parameters:


29
30
31
# File 'lib/cadre/notifier.rb', line 29

def initialize
  yield self if block_given?
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name


33
34
35
# File 'lib/cadre/notifier.rb', line 33

def app_name
  @app_name
end

#expire_timeObject

Returns the value of attribute expire_time


33
34
35
# File 'lib/cadre/notifier.rb', line 33

def expire_time
  @expire_time
end

#messageObject

Returns the value of attribute message


33
34
35
# File 'lib/cadre/notifier.rb', line 33

def message
  @message
end

#soundObject

Returns the value of attribute sound


33
34
35
# File 'lib/cadre/notifier.rb', line 33

def sound
  @sound
end

#summaryObject

Returns the value of attribute summary


33
34
35
# File 'lib/cadre/notifier.rb', line 33

def summary
  @summary
end

#transientObject

Returns the value of attribute transient


33
34
35
# File 'lib/cadre/notifier.rb', line 33

def transient
  @transient
end

Class Method Details

.availablesObject


20
21
22
# File 'lib/cadre/notifier.rb', line 20

def availables
  @availables ||= Hash.new{|h,k| h[k] = system("which", k, :out => "/dev/null")}
end

.getObject


12
13
14
15
16
17
18
# File 'lib/cadre/notifier.rb', line 12

def get
  registry.each_pair do |name, notifier|
    return notifier if notifier.available?
  end

  return DumbNotifier
end

.register(name) ⇒ Object


8
9
10
# File 'lib/cadre/notifier.rb', line 8

def register(name)
  Notifier.registry[name] = self
end

.registryObject


4
5
6
# File 'lib/cadre/notifier.rb', line 4

def registry
  @registry ||= {}
end

Instance Method Details

#available?(program) ⇒ Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/cadre/notifier.rb', line 25

def available?(program)
  self.class.availables[program]
end

#goObject


35
36
# File 'lib/cadre/notifier.rb', line 35

def go
end