Class: Raakt::ErrorMessage

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(eid, note = nil) ⇒ ErrorMessage

Returns a new instance of ErrorMessage.



57
58
59
60
61
62
63
64
65
66
# File 'lib/raakt.rb', line 57

def initialize(eid, note=nil)
  @eid = eid
  
  if note
    @text = MESSAGES[@eid].sub(/%s/, note)
  else
    @text = MESSAGES[@eid]
  end
  @note = note
end

Instance Attribute Details

#eidObject (readonly)

Returns the value of attribute eid.



55
56
57
# File 'lib/raakt.rb', line 55

def eid
  @eid
end

#noteObject (readonly)

Returns the value of attribute note.



55
56
57
# File 'lib/raakt.rb', line 55

def note
  @note
end

#textObject (readonly)

Returns the value of attribute text.



55
56
57
# File 'lib/raakt.rb', line 55

def text
  @text
end

Instance Method Details

#to_sObject



68
69
70
# File 'lib/raakt.rb', line 68

def to_s
  "#{@eid}: #{@text}"
end

#to_xmlObject

Return single error message as an xml element.



73
74
75
# File 'lib/raakt.rb', line 73

def to_xml
	"<message id=\"#{@eid}\">#{@text}</message>"
end