Class: MD4C::StringAttribute

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/md4c.rb,
ext/md4c/rb_md4c.c

Instance Method Summary collapse

Instance Method Details

#eachObject



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'ext/md4c/rb_md4c.c', line 261

static VALUE
rbm_cStringAttribute_m_each (VALUE self)
{
  RETURN_ENUMERATOR (self, 0, NULL);

  MD_ATTRIBUTE *attr = RTYPEDDATA_DATA (self);
  size_t index = 0;
  while (attr->substr_offsets[index] >= attr->size)
    {
      VALUE klass = rbm_get_text_class (attr->substr_types[index]);
      VALUE substr = rb_class_new_instance (0, NULL, klass);
      VALUE content = rb_str_new (attr->text + attr->substr_offsets[index],
                                  attr->substr_offsets[index + 1]
                                      - attr->substr_offsets[index]);
      rb_iv_set (substr, "@content", content);
      rb_yield (substr);
    }
  return RUBY_Qnil;
}