Class: ONIX::ETextType
- Inherits:
-
ROXML::XMLRef
- Object
- ROXML::XMLRef
- ONIX::ETextType
- Defined in:
- lib/onix/etext_type.rb
Overview
- ::nodoc
Instance Attribute Summary collapse
-
#cdata ⇒ Object
readonly
Returns the value of attribute cdata.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(accessor, args, &block) ⇒ ETextType
constructor
A new instance of ETextType.
-
#update_xml(xml, value) ⇒ Object
Updates the text in the given xml block to the value provided.
- #value(xml) ⇒ Object
Constructor Details
#initialize(accessor, args, &block) ⇒ ETextType
Returns a new instance of ETextType.
6 7 8 9 10 |
# File 'lib/onix/etext_type.rb', line 6 def initialize(accessor, args, &block) super(accessor, args, &block) @content = args.content? @cdata = args.cdata? end |
Instance Attribute Details
#cdata ⇒ Object (readonly)
Returns the value of attribute cdata.
4 5 6 |
# File 'lib/onix/etext_type.rb', line 4 def cdata @cdata end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/onix/etext_type.rb', line 4 def content @content end |
Instance Method Details
#update_xml(xml, value) ⇒ Object
Updates the text in the given xml block to the value provided.
14 15 16 17 18 19 |
# File 'lib/onix/etext_type.rb', line 14 def update_xml(xml, value) value = value.to_s.gsub("&","&").gsub("<","<").gsub(">",">") parent = wrap(xml) add(parent.child_add(LibXML::XML::Node.new_element(name)), value) xml end |
#value(xml) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/onix/etext_type.rb', line 21 def value(xml) if content value = xml.content else child = xml.search(name).first value = child.content if child end value = value.gsub("&","&").gsub("<","<").gsub(">",">") if value block ? block.call(value) : value end |