Class: HTree::ProcIns
- Inherits:
-
Object
- Object
- HTree::ProcIns
- Defined in:
- lib/htree/loc.rb,
lib/htree/leaf.rb,
lib/htree/rexml.rb,
lib/htree/output.rb,
lib/htree/modules.rb,
lib/htree/modules.rb,
lib/htree/modules.rb,
lib/htree/equality.rb,
lib/htree/raw_string.rb
Defined Under Namespace
Constant Summary
Constants included from HTree
DefaultContext, ElementContent, ElementExclusions, ElementInclusions, EmptyBindingObject, HTMLContext, NamedCharacters, NamedCharactersPattern, OmittedAttrName
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #eliminate_raw_string ⇒ Object
-
#initialize(target, content) ⇒ ProcIns
constructor
:notnew:.
- #make_exact_equal_object ⇒ Object
- #make_usual_equal_object ⇒ Object
- #node_test_string ⇒ Object
- #output(out, context) ⇒ Object
- #to_rexml_internal(parent, context) ⇒ Object
Methods included from Leaf::Trav
#traverse_all_element, #traverse_some_element, #traverse_text_internal
Methods included from Traverse
#bogusetag?, #comment?, #doc?, #doctype?, #elem?, #get_subnode, #procins?, #text?, #traverse_text, #xmldecl?
Methods included from Leaf
#extract_text, #init_raw_string, #pretty_print, #raw_string=, #raw_string_internal
Methods included from Node
#display_html, #display_xml, #extract_text, #generate_xml_output_code, #make_loc, #raw_string, #subst, #subst_internal, #to_node, #to_rexml
Methods included from HTree
#==, build_node, #check_equality, compile_template, #exact_equal?, #exact_equal_object, expand_template, fix_element, fix_structure_list, frozen_string, #hash, parse_as, parse_pairs, parse_xml, scan, #usual_equal_object, with_frozen_string_hash
Constructor Details
#initialize(target, content) ⇒ ProcIns
:notnew:
53 54 55 56 57 58 59 60 |
# File 'lib/htree/leaf.rb', line 53 def initialize(target, content) # :notnew: init_raw_string if content && /\?>/ =~ content raise HTree::Error, "invalid processing instruction content: #{content.inspect}" end @target = target @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
61 62 63 |
# File 'lib/htree/leaf.rb', line 61 def content @content end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
61 62 63 |
# File 'lib/htree/leaf.rb', line 61 def target @target end |
Class Method Details
.new(target, content) ⇒ Object
:startdoc:
48 49 50 51 |
# File 'lib/htree/leaf.rb', line 48 def ProcIns.new(target, content) content = content.gsub(/\?>/, '? >') if content new! target, content end |
.new! ⇒ Object
44 |
# File 'lib/htree/leaf.rb', line 44 alias new! new |
.parse(raw_string) ⇒ Object
384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/htree/parse.rb', line 384 def ProcIns.parse(raw_string) unless /\A#{Pat::XmlProcIns_C}\z/o =~ raw_string raise HTree::Error, "cannot recognize as processing instruction: #{raw_string.inspect}" end target = $1 content = $2 result = ProcIns.new(target, content) result.raw_string = raw_string result end |
Instance Method Details
#eliminate_raw_string ⇒ Object
116 117 118 |
# File 'lib/htree/raw_string.rb', line 116 def eliminate_raw_string ProcIns.new(@target, @content) end |
#make_exact_equal_object ⇒ Object
185 186 187 |
# File 'lib/htree/equality.rb', line 185 def make_exact_equal_object [@raw_string, @target, @content] end |
#make_usual_equal_object ⇒ Object
189 190 191 |
# File 'lib/htree/equality.rb', line 189 def make_usual_equal_object [@target, @content] end |
#node_test_string ⇒ Object
96 |
# File 'lib/htree/loc.rb', line 96 def node_test_string() 'processing-instruction()' end |
#output(out, context) ⇒ Object
198 199 200 201 202 |
# File 'lib/htree/output.rb', line 198 def output(out, context) out.output_string "<?#{@target}" out.output_string " #{@content}" if @content out.output_string "?>" end |
#to_rexml_internal(parent, context) ⇒ Object
111 112 113 114 115 |
# File 'lib/htree/rexml.rb', line 111 def to_rexml_internal(parent, context) r = REXML::Instruction.new(self.target, self.content) parent << r if parent r end |