Class: Notifaction::Type::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/notifaction/type.rb

Direct Known Subclasses

Linux, OSX, Terminal

Constant Summary collapse

OK =

Exit code to indicate everything is ok!

0
QUIT =

Exit code to indicate a force quit (exit) call, meaning the program quit with an error

1
QUIT_SOFT =

Exit code to indicate that the program exited with a non-zero exit code, but not one that resulted in a force quit

2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.

Since:

  • 0.3.0.1



21
22
23
24
# File 'lib/notifaction/type.rb', line 21

def initialize
  @user_conf = Notifaction::Cfg.new
  @style = Notifaction::Style.new
end

Instance Attribute Details

#user_confObject (readonly)

Returns the value of attribute user_conf.



8
9
10
# File 'lib/notifaction/type.rb', line 8

def user_conf
  @user_conf
end

Instance Method Details

#fire_hooks(payload) ⇒ Object

Since:

  • 0.3.0



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/notifaction/type.rb', line 52

def fire_hooks(payload)
  mux = Mutex.new

  th = Thread.new do
    mux.synchronize do
      hooks = @user_conf.hooks

      return if hooks.nil?

      hooks.each do |uri|
        uri = URI.parse(uri)

        response = Net::HTTP.post_form(uri, payload)
        response.code.to_i < 300
      end
    end
  end.join.exit

  th.status == false
end

#okObject

Since:

  • 0.4.1



40
41
42
# File 'lib/notifaction/type.rb', line 40

def ok
  OK
end

#quitObject

Since:

  • 0.2.8



28
29
30
# File 'lib/notifaction/type.rb', line 28

def quit
  exit(QUIT)
end

#quit_okObject

Since:

  • 0.4.1



46
47
48
# File 'lib/notifaction/type.rb', line 46

def quit_ok
  exit(OK)
end

#quit_softObject

Since:

  • 0.4.1



34
35
36
# File 'lib/notifaction/type.rb', line 34

def quit_soft
  QUIT_SOFT
end