Sha256: 6e32f128aa063e85201fa239a78b7296ec7ce53ede4f2c55c37b1697b835dfee

Contents?: true

Size: 1.33 KB

Versions: 44

Compression:

Stored size: 1.33 KB

Contents

#include <nokogiri.h>

VALUE cNokogiriXmlAttributeDecl;

/*
 * call-seq:
 *  attribute_type
 *
 * The attribute_type for this AttributeDecl
 */
static VALUE
attribute_type(VALUE self)
{
  xmlAttributePtr node;
  Noko_Node_Get_Struct(self, xmlAttribute, node);
  return INT2NUM((long)node->atype);
}

/*
 * call-seq:
 *  default
 *
 * The default value
 */
static VALUE
default_value(VALUE self)
{
  xmlAttributePtr node;
  Noko_Node_Get_Struct(self, xmlAttribute, node);

  if (node->defaultValue) { return NOKOGIRI_STR_NEW2(node->defaultValue); }
  return Qnil;
}

/*
 * call-seq:
 *  enumeration
 *
 * An enumeration of possible values
 */
static VALUE
enumeration(VALUE self)
{
  xmlAttributePtr node;
  xmlEnumerationPtr enm;
  VALUE list;

  Noko_Node_Get_Struct(self, xmlAttribute, node);

  list = rb_ary_new();
  enm = node->tree;

  while (enm) {
    rb_ary_push(list, NOKOGIRI_STR_NEW2(enm->name));
    enm = enm->next;
  }

  return list;
}

void
noko_init_xml_attribute_decl()
{
  assert(cNokogiriXmlNode);
  cNokogiriXmlAttributeDecl = rb_define_class_under(mNokogiriXml, "AttributeDecl", cNokogiriXmlNode);

  rb_define_method(cNokogiriXmlAttributeDecl, "attribute_type", attribute_type, 0);
  rb_define_method(cNokogiriXmlAttributeDecl, "default", default_value, 0);
  rb_define_method(cNokogiriXmlAttributeDecl, "enumeration", enumeration, 0);
}

Version data entries

44 entries across 44 versions & 3 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/nokogiri-1.13.8-arm64-darwin/ext/nokogiri/xml_attribute_decl.c
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/nokogiri-1.13.8-arm64-darwin/ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-x86_64-darwin ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-x86-mingw32 ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10 ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-x86_64-linux ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-arm64-darwin ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-java ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-x64-mingw32 ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-aarch64-linux ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-x86-linux ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.10-x64-mingw-ucrt ext/nokogiri/xml_attribute_decl.c
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/nokogiri-1.13.9-x86_64-linux/ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.9 ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.9-x86_64-linux ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.9-x86_64-darwin ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.9-x86-mingw32 ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.9-x86-linux ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.9-x64-mingw32 ext/nokogiri/xml_attribute_decl.c
nokogiri-1.13.9-x64-mingw-ucrt ext/nokogiri/xml_attribute_decl.c