/*
 * call-seq:
 *   attribute_at(index)
 *
 * Get the value of attribute at +index+
 */
static VALUE attribute_at(VALUE self, VALUE index)
{
  xmlTextReaderPtr reader;
  Data_Get_Struct(self, xmlTextReader, reader);

  if(NIL_P(index)) return Qnil;
  index = rb_Integer(index);

  xmlChar * value = xmlTextReaderGetAttributeNo(
      reader,
      NUM2INT(index)
  );
  if(value == NULL) return Qnil;

  VALUE rb_value = NOKOGIRI_STR_NEW2(value);
  xmlFree(value);
  return rb_value;
}