Class: XmlParsable::Elements::TimeElement

Inherits:
AbstractElement show all
Defined in:
lib/xmlparsable/elements/time.rb

Overview

Parses content into a ruby Time value

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractElement

#comment, #open, parsable

Constructor Details

#initialize(name, attributes, parent, *arguments) ⇒ TimeElement

Returns a new instance of TimeElement.



11
12
13
# File 'lib/xmlparsable/elements/time.rb', line 11

def initialize(name, attributes, parent, *arguments)
  @name, @parent, @string = name, parent, ""
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/xmlparsable/elements/time.rb', line 9

def name
  @name
end

Instance Method Details

#finalizeObject



19
20
21
22
# File 'lib/xmlparsable/elements/time.rb', line 19

def finalize
  stripped = @string.strip
  @parent.close(self, stripped == "" ? nil : Time.parse(stripped))
end

#read(text) ⇒ Object



15
16
17
# File 'lib/xmlparsable/elements/time.rb', line 15

def read(text)
  @string << text
end