Module: FastHaml::AttributeBuilder

Defined in:
ext/attribute_builder/attribute_builder.c

Class Method Summary collapse

Class Method Details

.build(*args) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'ext/attribute_builder/attribute_builder.c', line 213

static VALUE
m_build(int argc, VALUE *argv, VALUE self)
{
  VALUE attr_quote, attributes, keys, buf;
  long len, i;

  rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
  attr_quote = argv[0];
  attributes = rb_hash_new();
  rb_hash_aset(attributes, rb_str_new_cstr("id"), rb_ary_new());
  rb_hash_aset(attributes, rb_str_new_cstr("class"), rb_ary_new());
  merge(attributes, argc-1, argv+1);

  keys = rb_funcall(attributes, id_keys, 0);
  rb_funcall(keys, id_sort_bang, 0);
  len = RARRAY_LEN(keys);
  buf = rb_ary_new_capa(len);
  for (i = 0; i < len; i++) {
    VALUE k = RARRAY_AREF(keys, i);
    rb_ary_push(buf, build_attribute(attr_quote, k, rb_hash_lookup(attributes, k)));
  }

  return rb_ary_join(buf, Qnil);
}

.normalize_data(data) ⇒ Object



238
239
240
241
242
# File 'ext/attribute_builder/attribute_builder.c', line 238

static VALUE
m_normalize_data(VALUE self, VALUE data)
{
  return normalize_data(data);
}