Class: Blinkr::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/blinkr/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/blinkr/error.rb', line 6

def initialize (opts = {})
  raise TypeError 'severity must be a string or symbol' unless opts[:severity].is_a?(String) || opts[:severity].is_a?(Symbol)
  raise 'severity not a recognized value' unless SEVERITY.include? opts[:severity].to_sym

  @severity = opts[:severity].to_sym
  @category = opts[:category]
  @type = opts[:type]
  @title = opts[:title]
  @message = opts[:message]
  @snippet = opts[:snippet]
  @icon = opts[:icon]
  @code = opts[:code]
  @url = opts[:url]
  @detail = opts[:detail]
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def category
  @category
end

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def code
  @code
end

#detailObject (readonly)

Returns the value of attribute detail.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def detail
  @detail
end

#iconObject (readonly)

Returns the value of attribute icon.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def icon
  @icon
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def message
  @message
end

#severityObject (readonly)

Returns the value of attribute severity.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def severity
  @severity
end

#snippetObject (readonly)

Returns the value of attribute snippet.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def snippet
  @snippet
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/blinkr/error.rb', line 4

def url
  @url
end

Instance Method Details

#to_json(*args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/blinkr/error.rb', line 22

def to_json(*args)
  content = {}
  instance_variables.each do |v|
    content[v.to_s[1..-1]] = instance_variable_get v
  end
  content.to_json
end