Class: Xmlss::Element::Data
- Inherits:
-
Object
- Object
- Xmlss::Element::Data
- Includes:
- Enumeration
- Defined in:
- lib/xmlss/element/data.rb
Constant Summary collapse
- LB =
" "
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value = "", attrs = {}) ⇒ Data
constructor
A new instance of Data.
- #xml_value ⇒ Object
Constructor Details
#initialize(value = "", attrs = {}) ⇒ Data
Returns a new instance of Data.
21 22 23 24 |
# File 'lib/xmlss/element/data.rb', line 21 def initialize(value="", attrs={}) self.value = value self.type = attrs[:type] if attrs[:type] end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
19 20 21 |
# File 'lib/xmlss/element/data.rb', line 19 def value @value end |
Instance Method Details
#xml_value ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/xmlss/element/data.rb', line 33 def xml_value case self.value when ::Date, ::Time, ::DateTime self.value.strftime("%Y-%m-%dT%H:%M:%S") when ::String, ::Symbol self.value.to_s.gsub(/(\r|\n)+/, LB) else self.value.to_s end end |