Class: Gonzui::XMLFormatter
- Inherits:
-
Data
- Object
- Data
- Gonzui::XMLFormatter
- Defined in:
- ext/xmlformatter/xmlformatter.c
Instance Method Summary collapse
- #add_doctype ⇒ Object
- #add_xml_declaration ⇒ Object
- #format(xml) ⇒ Object
- #initialize ⇒ Object constructor
Constructor Details
#initialize ⇒ Object
109 110 111 112 113 114 115 116 117 118 |
# File 'ext/xmlformatter/xmlformatter.c', line 109
static VALUE xmlformatter_initialize(VALUE self)
{
gonzui_xmlformatter_t *xf;
Data_Get_Struct(self, gonzui_xmlformatter_t, xf);
if (xf)
rb_raise(rb_eArgError, "called twice");
DATA_PTR(self) = xmlformatter_new();
return self;
}
|
Instance Method Details
#add_doctype ⇒ Object
129 130 131 132 133 134 135 136 137 |
# File 'ext/xmlformatter/xmlformatter.c', line 129
static VALUE xmlformatter_add_doctype(VALUE self)
{
gonzui_xmlformatter_t *xf;
Data_Get_Struct(self, gonzui_xmlformatter_t, xf);
if (xf)
xmlformatter_write(xf, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
return Qnil;
}
|
#add_xml_declaration ⇒ Object
120 121 122 123 124 125 126 127 |
# File 'ext/xmlformatter/xmlformatter.c', line 120
static VALUE xmlformatter_add_xml_declaration(VALUE self)
{
gonzui_xmlformatter_t *xf;
Data_Get_Struct(self, gonzui_xmlformatter_t, xf);
if (xf)
xmlformatter_write(xf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
return Qnil;
}
|
#format(xml) ⇒ Object
187 188 189 190 191 192 193 194 195 196 |
# File 'ext/xmlformatter/xmlformatter.c', line 187
static VALUE xmlformatter_format(VALUE self, VALUE xml)
{
gonzui_xmlformatter_t *xf;
Data_Get_Struct(self, gonzui_xmlformatter_t, xf);
if (xf == NULL)
return Qnil;
Check_Type(xml, T_ARRAY);
format(xf, xml);
return rb_str_new(xf->data, xf->size);
}
|