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.



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

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.



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

def eid
  @eid
end

#noteObject (readonly)

Returns the value of attribute note.



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

def note
  @note
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#to_sObject



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

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

#to_xmlObject

Return single error message as an xml element.



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

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