Class: Nokolexbor::ProcessingInstruction
- Defined in:
- ext/nokolexbor/nl_processing_instruction.c
Constant Summary
Constants inherited from Node
Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAG_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::ENTITY_NODE, Node::ENTITY_REF_NODE, Node::LOOKS_LIKE_XPATH, Node::NOTATION_NODE, Node::PI_NODE, Node::TEXT_NODE
Instance Attribute Summary
Attributes inherited from Node
Class Method Summary collapse
-
.new(name, content, document) {|ProcessingInstruction| ... } ⇒ ProcessingInstruction
Create a new ProcessingInstruction from
name
andcontent
.
Methods inherited from Node
#<<, #==, #[], #[]=, #add_child, #add_class, #add_next_sibling, #add_previous_sibling, #add_sibling, #after, #ancestors, #append_class, #at, #at_css, #at_css_impl, #at_xpath, #attribute, #attribute_nodes, #attributes, #attrs, #before, #cdata?, #child, #children, #children=, #classes, #clone, #comment?, #content, #content=, #css, #css_impl, #css_path, #destroy, #document?, #each, #element?, #element_children, #first_element_child, #fragment, #fragment?, #inner_html, #inspect, #key?, #keys, #kwattr_add, #kwattr_append, #kwattr_remove, #kwattr_values, #last_element_child, #matches?, #name, #next, #next_element, #node_type, #nokogiri_at_css, #nokogiri_css, #outer_html, #parent, #parent=, #parse, #path, #prepend_child, #previous, #previous_element, #processing_instruction?, #remove, #remove_attr, #remove_class, #replace, #search, #source_location, #swap, #text?, #traverse, #value?, #values, #wrap, #write_to, #xpath
Class Method Details
.new(name, content, document) {|ProcessingInstruction| ... } ⇒ ProcessingInstruction
Create a new ProcessingInstruction from name
and content
.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'ext/nokolexbor/nl_processing_instruction.c', line 13
static VALUE
nl_processing_instruction_new(int argc, VALUE *argv, VALUE klass)
{
lxb_dom_document_t *document;
VALUE rb_name;
VALUE rb_content;
VALUE rb_document;
VALUE rest;
rb_scan_args(argc, argv, "3*", &rb_name, &rb_content, &rb_document, &rest);
if (!rb_obj_is_kind_of(rb_document, cNokolexborDocument)) {
rb_raise(rb_eArgError, "Document must be a Nokolexbor::Document");
}
document = nl_rb_document_unwrap(rb_document);
const char *c_name = StringValuePtr(rb_name);
size_t name_len = RSTRING_LEN(rb_name);
const char *c_content = StringValuePtr(rb_content);
size_t content_len = RSTRING_LEN(rb_content);
lxb_dom_processing_instruction_t *node = lxb_dom_document_create_processing_instruction(document, (const lxb_char_t *)c_name, name_len, (const lxb_char_t *)c_content, content_len);
if (node == NULL) {
rb_raise(rb_eRuntimeError, "Error creating processing instruction");
}
VALUE rb_node = nl_rb_node_create(&node->char_data.node, rb_document);
if (rb_block_given_p()) {
rb_yield(rb_node);
}
return rb_node;
}
|