Class: Notiffany::Notifier::Base
- Inherits:
-
Object
- Object
- Notiffany::Notifier::Base
- Defined in:
- lib/notiffany/notifier/base.rb
Direct Known Subclasses
Emacs, File, GNTP, Growl, Libnotify, Notifu, NotifySend, TerminalNotifier, TerminalTitle, Tmux
Defined Under Namespace
Classes: RequireFailed, UnavailableError, UnsupportedPlatform
Constant Summary collapse
- HOSTS =
{ darwin: "Mac OS X", linux: "Linux", 'linux-gnu' => "Linux", freebsd: "FreeBSD", openbsd: "OpenBSD", sunos: "SunOS", solaris: "Solaris", mswin: "Windows", mingw: "Windows", cygwin: "Windows" }
- ERROR_ADD_GEM_AND_RUN_BUNDLE =
"Please add \"gem '%s'\" to your Gemfile "\ "and run your app with \"bundle exec\"."
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #_image_path(image) ⇒ Object
-
#initialize(opts = {}) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
- #notify(message, opts = {}) ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Base
Returns a new instance of Base.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/notiffany/notifier/base.rb', line 47 def initialize(opts = {}) = opts.dup .delete(:silent) @options = { title: "Notiffany" }. merge(self.class.const_get(:DEFAULTS)). merge().freeze @images_path = Pathname.new(__FILE__).dirname + "../../../images" _check_host_supported _require_gem _check_available(@options) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
45 46 47 |
# File 'lib/notiffany/notifier/base.rb', line 45 def @options end |
Instance Method Details
#_image_path(image) ⇒ Object
75 76 77 78 |
# File 'lib/notiffany/notifier/base.rb', line 75 def _image_path(image) images = [:failed, :pending, :success, :guard] images.include?(image) ? @images_path.join("#{image}.png").to_s : image end |
#name ⇒ Object
66 67 68 |
# File 'lib/notiffany/notifier/base.rb', line 66 def name title.gsub(/([a-z])([A-Z])/, '\1_\2').downcase end |
#notify(message, opts = {}) ⇒ Object
70 71 72 73 |
# File 'lib/notiffany/notifier/base.rb', line 70 def notify(, opts = {}) new_opts = (opts).freeze _perform_notify(, new_opts) end |
#title ⇒ Object
62 63 64 |
# File 'lib/notiffany/notifier/base.rb', line 62 def title self.class.to_s[/.+::(\w+)$/, 1] end |