Class: CXML::Status
- Inherits:
-
Object
- Object
- CXML::Status
- Defined in:
- lib/cxml/status.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#text ⇒ Object
Returns the value of attribute text.
-
#xml_lang ⇒ Object
Returns the value of attribute xml_lang.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Check if status is failure.
-
#initialize(data = {}) ⇒ Status
constructor
Initialize a new Status instance.
- #render(node) ⇒ Object
-
#success? ⇒ Boolean
Check if status is success.
Constructor Details
#initialize(data = {}) ⇒ Status
Initialize a new Status instance
9 10 11 12 13 14 15 16 17 |
# File 'lib/cxml/status.rb', line 9 def initialize(data={}) data = CXML.parse(data) if data.kind_of?(String) if data.kind_of?(Hash) && !data.empty? @code = data['code'].to_i @text = data['text'] @xml_lang = data['xml:lang'] end end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/cxml/status.rb', line 3 def code @code end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/cxml/status.rb', line 4 def text @text end |
#xml_lang ⇒ Object
Returns the value of attribute xml_lang.
5 6 7 |
# File 'lib/cxml/status.rb', line 5 def xml_lang @xml_lang end |
Instance Method Details
#failure? ⇒ Boolean
Check if status is failure
27 28 29 |
# File 'lib/cxml/status.rb', line 27 def failure? !success? end |
#render(node) ⇒ Object
31 32 33 |
# File 'lib/cxml/status.rb', line 31 def render(node) node.Status(:code => @code, :text => @text) end |
#success? ⇒ Boolean
Check if status is success
21 22 23 |
# File 'lib/cxml/status.rb', line 21 def success? [200, 201, 204, 280, 281].include?(code) end |