Class: OvirtSDK4::HttpResponse

Inherits:
Data
  • Object
show all
Defined in:
ext/ovirtsdk4c/ov_http_response.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'ext/ovirtsdk4c/ov_http_response.c', line 161

static VALUE ov_http_response_initialize(int argc, VALUE* argv, VALUE self) {
    VALUE opts;

    /* Check the number of arguments: */
    if (argc > 1) {
      rb_raise(ov_error_class, "Expected at most one argument, 'opts', but received %d", argc);
    }
    opts = argc > 0? argv[0]: Qnil;
    if (NIL_P(opts)) {
        opts = rb_hash_new();
    }
    else {
        Check_Type(opts, T_HASH);
    }

    /* Get the values of the options: */
    ov_http_response_set_body(self, rb_hash_aref(opts, BODY_SYMBOL));
    ov_http_response_set_headers(self, rb_hash_aref(opts, HEADERS_SYMBOL));
    ov_http_response_set_code(self, rb_hash_aref(opts, CODE_SYMBOL));
    ov_http_response_set_message(self, rb_hash_aref(opts, MESSAGE_SYMBOL));

    return self;
}

Instance Method Details

#bodyObject

Define the methods:



74
75
76
77
78
79
# File 'ext/ovirtsdk4c/ov_http_response.c', line 74

static VALUE ov_http_response_get_body(VALUE self) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    return ptr->body;
}

#body=(value) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'ext/ovirtsdk4c/ov_http_response.c', line 81

static VALUE ov_http_response_set_body(VALUE self, VALUE value) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_STRING);
    }
    ptr->body = value;
    return Qnil;
}

#codeObject



92
93
94
95
96
97
# File 'ext/ovirtsdk4c/ov_http_response.c', line 92

static VALUE ov_http_response_get_code(VALUE self) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    return ptr->code;
}

#code=(value) ⇒ Object



99
100
101
102
103
104
105
106
107
108
# File 'ext/ovirtsdk4c/ov_http_response.c', line 99

static VALUE ov_http_response_set_code(VALUE self, VALUE value) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_FIXNUM);
    }
    ptr->code = value;
    return Qnil;
}

#headersObject



110
111
112
113
114
115
# File 'ext/ovirtsdk4c/ov_http_response.c', line 110

static VALUE ov_http_response_get_headers(VALUE self) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    return ptr->headers;
}

#headers=(value) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'ext/ovirtsdk4c/ov_http_response.c', line 117

static VALUE ov_http_response_set_headers(VALUE self, VALUE value) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    if (NIL_P(value)) {
        ptr->headers = rb_hash_new();
    }
    else {
        Check_Type(value, T_HASH);
        ptr->headers = value;
    }
    return Qnil;
}

#inspectObject



149
150
151
152
153
154
155
156
157
158
159
# File 'ext/ovirtsdk4c/ov_http_response.c', line 149

static VALUE ov_http_response_inspect(VALUE self) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    return rb_sprintf(
        "#<%"PRIsVALUE":%"PRIsVALUE" %"PRIsVALUE">",
        ov_http_response_class,
        ptr->code,
        ptr->message
    );
}

#messageObject



131
132
133
134
135
136
# File 'ext/ovirtsdk4c/ov_http_response.c', line 131

static VALUE ov_http_response_get_message(VALUE self) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    return ptr->message;
}

#message=(value) ⇒ Object



138
139
140
141
142
143
144
145
146
147
# File 'ext/ovirtsdk4c/ov_http_response.c', line 138

static VALUE ov_http_response_set_message(VALUE self, VALUE value) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_STRING);
    }
    ptr->message = value;
    return Qnil;
}

#to_sObject



149
150
151
152
153
154
155
156
157
158
159
# File 'ext/ovirtsdk4c/ov_http_response.c', line 149

static VALUE ov_http_response_inspect(VALUE self) {
    ov_http_response_object* ptr;

    ov_http_response_ptr(self, ptr);
    return rb_sprintf(
        "#<%"PRIsVALUE":%"PRIsVALUE" %"PRIsVALUE">",
        ov_http_response_class,
        ptr->code,
        ptr->message
    );
}