Class: Boppers::Notifier::Stdout
- Inherits:
-
Object
- Object
- Boppers::Notifier::Stdout
- Defined in:
- lib/boppers/notifier/stdout.rb
Constant Summary collapse
- COLORS =
{ green: "\e[32m", red: "\e[31m" }.freeze
- NO_COLOR =
"\e[0m"
Instance Attribute Summary collapse
-
#subscribe ⇒ Object
readonly
Returns the value of attribute subscribe.
Instance Method Summary collapse
- #call(title, message, options) ⇒ Object
-
#initialize(subscribe: nil) ⇒ Stdout
constructor
A new instance of Stdout.
Constructor Details
#initialize(subscribe: nil) ⇒ Stdout
Returns a new instance of Stdout.
15 16 17 |
# File 'lib/boppers/notifier/stdout.rb', line 15 def initialize(subscribe: nil) @subscribe = subscribe end |
Instance Attribute Details
#subscribe ⇒ Object (readonly)
Returns the value of attribute subscribe.
13 14 15 |
# File 'lib/boppers/notifier/stdout.rb', line 13 def subscribe @subscribe end |
Instance Method Details
#call(title, message, options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/boppers/notifier/stdout.rb', line 19 def call(title, , ) color = COLORS.fetch([:color], NO_COLOR) = .gsub(/^/m, " ") .lines .map {|line| "#{color}#{line}#{NO_COLOR}" } .join puts [ "#{color}## #{title}#{NO_COLOR}", , "\n" ].join("\n") end |