Sha256: e6133f79f31668d0b29259d967c823be51710b141db60dc841c9fe8d87e8ab58

Contents?: true

Size: 1.39 KB

Versions: 261

Compression:

Stored size: 1.39 KB

Contents

#include <nokogiri.h>

VALUE cNokogiriXmlElementDecl;

static ID id_document;

/*
 * call-seq:
 *   element_type → Integer
 *
 * The element_type
 */
static VALUE
element_type(VALUE self)
{
  xmlElementPtr node;
  Noko_Node_Get_Struct(self, xmlElement, node);
  return INT2NUM(node->etype);
}

/*
 * call-seq:
 *   content → Nokogiri::XML::ElementContent
 *
 * [Returns] The root of this element declaration's content tree.
 */
static VALUE
content(VALUE self)
{
  xmlElementPtr node;
  Noko_Node_Get_Struct(self, xmlElement, node);

  if (!node->content) { return Qnil; }

  return noko_xml_element_content_wrap(
           rb_funcall(self, id_document, 0),
           node->content
         );
}

/*
 * call-seq:
 *   prefix → String
 *
 * [Returns] The namespace +prefix+ for this element declaration.
 */
static VALUE
prefix(VALUE self)
{
  xmlElementPtr node;
  Noko_Node_Get_Struct(self, xmlElement, node);

  if (!node->prefix) { return Qnil; }

  return NOKOGIRI_STR_NEW2(node->prefix);
}

void
noko_init_xml_element_decl(void)
{
  assert(cNokogiriXmlNode);
  cNokogiriXmlElementDecl = rb_define_class_under(mNokogiriXml, "ElementDecl", cNokogiriXmlNode);

  rb_define_method(cNokogiriXmlElementDecl, "element_type", element_type, 0);
  rb_define_method(cNokogiriXmlElementDecl, "content", content, 0);
  rb_define_method(cNokogiriXmlElementDecl, "prefix", prefix, 0);

  id_document = rb_intern("document");
}

Version data entries

261 entries across 261 versions & 7 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/nokogiri-1.16.6-arm64-darwin/ext/nokogiri/xml_element_decl.c
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/ext/nokogiri/xml_element_decl.c
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/ext/nokogiri/xml_element_decl.c
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6 ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-x86_64-linux ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-x86_64-darwin ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-x86-mingw32 ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-x86-linux ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-x64-mingw32 ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-x64-mingw-ucrt ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-java ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-arm64-darwin ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-arm-linux ext/nokogiri/xml_element_decl.c
nokogiri-1.16.6-aarch64-linux ext/nokogiri/xml_element_decl.c
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/ext/nokogiri/xml_element_decl.c
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/ext/nokogiri/xml_element_decl.c
nokogiri-1.16.4 ext/nokogiri/xml_element_decl.c
nokogiri-1.16.4-x86_64-linux ext/nokogiri/xml_element_decl.c
nokogiri-1.16.4-x86_64-darwin ext/nokogiri/xml_element_decl.c