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.



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

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.



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

def eid
  @eid
end

#noteObject (readonly)

Returns the value of attribute note.



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

def note
  @note
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#to_sObject



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

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

#to_xmlObject

Return single error message as an xml element.



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

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