lib/notifaction/style.rb in notifaction-0.2.0 vs lib/notifaction/style.rb in notifaction-0.3.0

- old
+ new

@@ -1,32 +1,34 @@ -module Style - @map = { - :colour => { - :red => 31, - :green => 32, - :yellow => 33, - :blue => 34, - :magenta => 35, - :cyan => 36, - :white => 37, - :null => 0 - }, - :style => { - :reset => 0, - :bold => 1, - :underline => 4, - :normal => "" +module Notifaction + module Style + @map = { + colour: { + red: 31, + green: 32, + yellow: 33, + blue: 34, + magenta: 35, + cyan: 36, + white: 37, + null: 0 + }, + style: { + reset: 0, + bold: 1, + underline: 4, + normal: "" + } } - } - def self.format(message, colour = nil, style = nil) - c = @map[:colour][colour.to_sym] if !colour.nil? + def self.format(message, colour = nil, style = nil) + c = @map[:colour][colour.to_sym] unless colour.nil? - if style.nil? - t = 0 - else - t = @map[:style][style.to_sym] + if style.nil? + t = 0 + else + t = @map[:style][style.to_sym] + end + + "\e[#{t};#{c}m#{message}\e[0m" end - - "\e[#{t};#{c}m#{message}\e[0m" end -end \ No newline at end of file +end