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.
225 226 227 228 |
# File 'lib/lutaml/xml/data_model.rb', line 225 def initialize(target, content) @target = target @content = content end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
223 224 225 |
# File 'lib/lutaml/xml/data_model.rb', line 223 def content @content end |
#target ⇒ Object
Returns the value of attribute target.
223 224 225 |
# File 'lib/lutaml/xml/data_model.rb', line 223 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"}
242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/lutaml/xml/data_model.rb', line 242 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
230 231 232 |
# File 'lib/lutaml/xml/data_model.rb', line 230 def to_s "<?#{target} #{content}?>" end |