123456789_123456789_123456789_123456789_123456789_

Class: Nokogiri::HTML4::ElementDescription

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Class Method Details

.[](tag_name)

Get ElementDescription for tag_name

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 266

static VALUE
get_description(VALUE klass, VALUE tag_name)
{
  const htmlElemDesc *description = htmlTagLookup(
                                      (const xmlChar *)StringValueCStr(tag_name)
                                    );

  if (NULL == description) { return Qnil; }
  return TypedData_Wrap_Struct(klass, &html_elem_desc_type, DISCARD_CONST_QUAL(void *, description));
}

Instance Attribute Details

#block?Boolean (readonly)

Is this element a block element?

[ GitHub ]

  
# File 'lib/nokogiri/html4/element_description.rb', line 8

def block?
  !inline?
end

#deprecated?Boolean (readonly)

Is this element deprecated?

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 170

static VALUE
deprecated_eh(VALUE self)
{
  const htmlElemDesc *description;
  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  if (description->depr) { return Qtrue; }
  return Qfalse;
}

#empty?Boolean (readonly)

Is this an empty element?

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 186

static VALUE
empty_eh(VALUE self)
{
  const htmlElemDesc *description;
  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  if (description->empty) { return Qtrue; }
  return Qfalse;
}

#implied_end_tag?Boolean (readonly)

Can the end tag be implied for this tag?

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 218

static VALUE
implied_end_tag_eh(VALUE self)
{
  const htmlElemDesc *description;
  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  if (description->endTag) { return Qtrue; }
  return Qfalse;
}

#implied_start_tag?Boolean (readonly)

Can the start tag be implied for this tag?

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 234

static VALUE
implied_start_tag_eh(VALUE self)
{
  const htmlElemDesc *description;
  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  if (description->startTag) { return Qtrue; }
  return Qfalse;
}

#inline?Boolean (readonly)

Is this element an inline element?

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 154

static VALUE
inline_eh(VALUE self)
{
  const htmlElemDesc *description;
  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  if (description->isinline) { return Qtrue; }
  return Qfalse;
}

#save_end_tag?Boolean (readonly)

Should the end tag be saved?

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 202

static VALUE
save_end_tag_eh(VALUE self)
{
  const htmlElemDesc *description;
  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  if (description->saveEndTag) { return Qtrue; }
  return Qfalse;
}

Instance Method Details

#default_desc (private)

[ GitHub ]

  
# File 'lib/nokogiri/html4/element_description_defaults.rb', line 32

def default_desc
  DefaultDescriptions[name.downcase]
end

#default_sub_element

The default sub element for this element

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 94

static VALUE
default_sub_element(VALUE self)
{
  const htmlElemDesc *description;
  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  if (description->defaultsubelt) {
    return NOKOGIRI_STR_NEW2(description->defaultsubelt);
  }

  return Qnil;
}

#deprecated_attributes

A list of deprecated attributes for this element

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 42

static VALUE
deprecated_attributes(VALUE self)
{
  const htmlElemDesc *description;
  VALUE list;
  int i;

  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  list = rb_ary_new();

  if (NULL == description->attrs_depr) { return list; }

  for (i = 0; description->attrs_depr[i]; i++) {
    rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_depr[i]));
  }

  return list;
}

#description

The description for this element

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 139

static VALUE
description(VALUE self)
{
  const htmlElemDesc *description;
  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  return NOKOGIRI_STR_NEW2(description->desc);
}

#inspect

Inspection information

[ GitHub ]

  
# File 'lib/nokogiri/html4/element_description.rb', line 20

def inspect
  "#<#{self.class.name}: #{name} #{description}>"
end

#name

Alias for XML::Reader#name.

#optional_attributes

A list of optional attributes for this element

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 68

static VALUE
optional_attributes(VALUE self)
{
  const htmlElemDesc *description;
  VALUE list;
  int i;

  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  list = rb_ary_new();

  if (NULL == description->attrs_opt) { return list; }

  for (i = 0; description->attrs_opt[i]; i++) {
    rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_opt[i]));
  }

  return list;
}

#required_attributes

A list of required attributes for this element

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 16

static VALUE
required_attributes(VALUE self)
{
  const htmlElemDesc *description;
  VALUE list;
  int i;

  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  list = rb_ary_new();

  if (NULL == description->attrs_req) { return list; }

  for (i = 0; description->attrs_depr[i]; i++) {
    rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_req[i]));
  }

  return list;
}

#sub_elements

A list of allowed sub elements for this element.

[ GitHub ]

  
# File 'ext/nokogiri/html4_element_description.c', line 113

static VALUE
sub_elements(VALUE self)
{
  const htmlElemDesc *description;
  VALUE list;
  int i;

  TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

  list = rb_ary_new();

  if (NULL == description->subelts) { return list; }

  for (i = 0; description->subelts[i]; i++) {
    rb_ary_push(list, NOKOGIRI_STR_NEW2(description->subelts[i]));
  }

  return list;
}

#to_s

Convert this description to a string

[ GitHub ]

  
# File 'lib/nokogiri/html4/element_description.rb', line 14

def to_s
  "#{name}: #{description}"
end