Class: Scad4r::Notification
- Inherits:
-
Object
- Object
- Scad4r::Notification
- Defined in:
- lib/scad4r/notification.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
Instance Method Summary collapse
- #image ⇒ Object
-
#initialize(attributes = {}) ⇒ Notification
constructor
A new instance of Notification.
- #priority ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Notification
Returns a new instance of Notification.
23 24 25 |
# File 'lib/scad4r/notification.rb', line 23 def initialize(attributes={}) @type, @message = attributes.to_a.pop end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
22 23 24 |
# File 'lib/scad4r/notification.rb', line 22 def @message end |
Class Method Details
.parse(result) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/scad4r/notification.rb', line 4 def parse(result) if error = result.fetch(:error, false) Array(new(error: error)) else timings = if real = result.fetch(:real,nil) new(success: real) else nil end Array(result.fetch(:warnings,nil)).map do |warning| new(warning: warning) end + Array(result.fetch(:echos,nil)).map do |echo| new(echo: echo) end + Array(timings) end end |
Instance Method Details
#image ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/scad4r/notification.rb', line 27 def image case @type when :error :error when :warning :error when :echo, :success :success end end |
#priority ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/scad4r/notification.rb', line 42 def priority case @type when :error 2 when :warning 1 when :echo 1 when :success -1 end end |
#title ⇒ Object
38 39 40 |
# File 'lib/scad4r/notification.rb', line 38 def title "openscad #{@type.to_s.upcase}" end |