Class: XmlParsable::Elements::DateElement
- Inherits:
-
AbstractElement
- Object
- AbstractElement
- XmlParsable::Elements::DateElement
- Defined in:
- lib/xmlparsable/elements/date.rb
Overview
Parses content into a ruby Date value
Defined Under Namespace
Classes: Date
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize(name, attributes, parent, arguments) ⇒ DateElement
constructor
A new instance of DateElement.
- #read(text) ⇒ Object
Methods inherited from AbstractElement
Constructor Details
#initialize(name, attributes, parent, arguments) ⇒ DateElement
Returns a new instance of DateElement.
16 17 18 19 |
# File 'lib/xmlparsable/elements/date.rb', line 16 def initialize(name, attributes, parent, arguments) @name, @attributes, @parent, @string = name, attributes, parent, "" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/xmlparsable/elements/date.rb', line 14 def name @name end |
Instance Method Details
#finalize ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/xmlparsable/elements/date.rb', line 25 def finalize stripped = @string.strip date = stripped == "" ? nil : Date.parse(stripped) date.instance_variable_set(:@xmlattrs, @attributes) @parent.close(self, date) end |
#read(text) ⇒ Object
21 22 23 |
# File 'lib/xmlparsable/elements/date.rb', line 21 def read(text) @string << text end |