Class: DJNML::Modification::XMLText

Inherits:
Object
  • Object
show all
Defined in:
lib/djnml/modification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ XMLText

Returns a new instance of XMLText.



94
95
96
97
98
99
100
101
102
# File 'lib/djnml/modification.rb', line 94

def initialize(data)
  if data.is_a?(Nokogiri::XML::Element)
    @text = data.children.text.strip
    @html = data.children.to_xml
  elsif data.is_a?(Hash)
    @text = data['text']
    @html = data['html']
  end
end

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



92
93
94
# File 'lib/djnml/modification.rb', line 92

def html
  @html
end

#textObject (readonly)

Returns the value of attribute text.



92
93
94
# File 'lib/djnml/modification.rb', line 92

def text
  @text
end

Instance Method Details

#to_sObject



104
105
106
# File 'lib/djnml/modification.rb', line 104

def to_s
  @text.to_s
end