Class: Plamo::FormDataFile

Inherits:
Object
  • Object
show all
Defined in:
ext/plamo/plamo_form_data_file.c

Instance Method Summary collapse

Instance Method Details

#bodyObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'ext/plamo/plamo_form_data_file.c', line 43

static VALUE get_body(VALUE self) {
  PlamoFormDataFile *plamo_form_data_file;
  TypedData_Get_Struct(self, PlamoFormDataFile, &rb_plamo_form_data_file_type, plamo_form_data_file);
  const size_t size = plamo_form_data_file_get_body_size(plamo_form_data_file);
  const unsigned char *body = plamo_form_data_file_get_body(plamo_form_data_file);
  VALUE rb_array = rb_ary_new2(size);
  for (int i = 0; i < size; i++) {
    rb_ary_store(rb_array, i, CHR2FIX(*(body + i)));
  }
  OBJ_FREEZE(rb_array);
  return rb_array;
}

#content_typeObject



21
22
23
24
25
26
27
28
29
30
# File 'ext/plamo/plamo_form_data_file.c', line 21

static VALUE get_content_type(VALUE self) {
  PlamoFormDataFile *plamo_form_data_file;
  TypedData_Get_Struct(self, PlamoFormDataFile, &rb_plamo_form_data_file_type, plamo_form_data_file);
  const char *str = plamo_form_data_file_get_content_type(plamo_form_data_file);
  if (str != NULL) {
    return rb_str_new2(str);
  } else {
    return Qnil;
  }
}

#file_nameObject



32
33
34
35
36
37
38
39
40
41
# File 'ext/plamo/plamo_form_data_file.c', line 32

static VALUE get_file_name(VALUE self) {
  PlamoFormDataFile *plamo_form_data_file;
  TypedData_Get_Struct(self, PlamoFormDataFile, &rb_plamo_form_data_file_type, plamo_form_data_file);
  const char *str = plamo_form_data_file_get_file_name(plamo_form_data_file);
  if (str != NULL) {
    return rb_str_new2(str);
  } else {
    return Qnil;
  }
}

#sizeObject



56
57
58
59
60
# File 'ext/plamo/plamo_form_data_file.c', line 56

static VALUE get_body_size(VALUE self) {
  PlamoFormDataFile *plamo_form_data_file;
  TypedData_Get_Struct(self, PlamoFormDataFile, &rb_plamo_form_data_file_type, plamo_form_data_file);
  return SIZET2NUM(plamo_form_data_file_get_body_size(plamo_form_data_file));
}