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