Class: Lutaml::Xml::DataModel::XmlProcessingInstruction
- Inherits:
-
Object
- Object
- Lutaml::Xml::DataModel::XmlProcessingInstruction
- Defined in:
- lib/lutaml/xml/data_model.rb
Overview
Represents an XML processing instruction.
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
-
.parse_pseudo_attributes(content) ⇒ Hash
Parse pseudo-attributes from PI content string.
Instance Method Summary collapse
-
#initialize(target, content) ⇒ XmlProcessingInstruction
constructor
A new instance of XmlProcessingInstruction.
- #to_s ⇒ Object
Constructor Details
#initialize(target, content) ⇒ XmlProcessingInstruction
Returns a new instance of XmlProcessingInstruction.
233 234 235 236 |
# File 'lib/lutaml/xml/data_model.rb', line 233 def initialize(target, content) @target = target @content = content end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
231 232 233 |
# File 'lib/lutaml/xml/data_model.rb', line 231 def content @content end |
#target ⇒ Object
Returns the value of attribute target.
231 232 233 |
# File 'lib/lutaml/xml/data_model.rb', line 231 def target @target end |
Class Method Details
.parse_pseudo_attributes(content) ⇒ Hash
Parse pseudo-attributes from PI content string.
Handles both single and multiple pseudo-attributes:
'strict="yes"' → {"strict"=>"yes"}
'toc="yes" oxy-markup="no"' → {"toc"=>"yes", "oxy-markup"=>"no"}
250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/lutaml/xml/data_model.rb', line 250 def self.parse_pseudo_attributes(content) return {} unless content.is_a?(String) && !content.strip.empty? chunks = content.split(/=['"]([^'"]*)['"]/) result = {} chunks.each_slice(2) do |key, value| next unless key && value result[key.strip] = value end result end |
Instance Method Details
#to_s ⇒ Object
238 239 240 |
# File 'lib/lutaml/xml/data_model.rb', line 238 def to_s "<?#{target} #{content}?>" end |