Class: Xmlss::Element::Data

Inherits:
Object
  • Object
show all
Includes:
Enumeration
Defined in:
lib/xmlss/element/data.rb

Constant Summary collapse

LB =
"
"

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#valueObject

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_valueObject



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