Class: Leptris::XML::ProcessingInstruction

Inherits:
Node
  • Object
show all
Defined in:
lib/leptris/xml/processing_instruction.rb

Instance Attribute Summary

Attributes inherited from Node

#c_ptr, #document

Instance Method Summary collapse

Methods inherited from Node

#<=>, #==, #cdata?, #child, #children, #comment?, #css_path, #dup, #element?, #element_children, #ensure_alive!, #ensure_writable!, #first_element_child, #initialize, #inner_text, #inspect, #last_element_child, #line, #next_element, #next_sibling, #parent, #path, #previous_element, #previous_sibling, #processing_instruction?, #readonly_document?, #text, #text?, #traverse, #type, #unlink, wrap

Methods included from Searchable

#at, #at_css, #at_xpath, #css, #search, wrap_xpath_result, #xpath

Constructor Details

This class inherits a constructor from Leptris::XML::Node

Instance Method Details

#contentObject



13
14
15
16
17
18
19
# File 'lib/leptris/xml/processing_instruction.rb', line 13

def content
  return @content if readonly_cached?(:@content)
  ensure_alive!
  Leptris::XML::FFI.leptris_pi_node_get_data(@c_ptr).to_s.tap do |data|
    @content = data if @document&.readonly?
  end
end

#data=(new_data) ⇒ Object



28
29
30
31
32
33
# File 'lib/leptris/xml/processing_instruction.rb', line 28

def data=(new_data)
  ensure_writable!
  Leptris::XML::FFI.check_status(
    Leptris::XML::FFI.leptris_pi_node_set_data(@c_ptr, new_data.to_s))
  new_data
end

#nameObject Also known as: target



4
5
6
7
8
9
10
# File 'lib/leptris/xml/processing_instruction.rb', line 4

def name
  return @name if readonly_cached?(:@name)
  ensure_alive!
  Leptris::XML::FFI.leptris_pi_node_get_target(@c_ptr).tap do |target|
    @name = target if @document&.readonly?
  end
end

#target=(new_target) ⇒ Object



21
22
23
24
25
26
# File 'lib/leptris/xml/processing_instruction.rb', line 21

def target=(new_target)
  ensure_writable!
  Leptris::XML::FFI.check_status(
    Leptris::XML::FFI.leptris_pi_node_set_target(@c_ptr, new_target.to_s))
  new_target
end