Class: AerospikeNative::Condition

Inherits:
Object
  • Object
show all
Defined in:
ext/aerospike_native/condition.c

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vBinName, vIndexType, vDataType, vMin, vMax) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'ext/aerospike_native/condition.c', line 14

VALUE condition_initialize(VALUE vSelf, VALUE vBinName, VALUE vIndexType, VALUE vDataType, VALUE vMin, VALUE vMax)
{
    int index_type = 0, data_type = 0;
    Check_Type(vBinName, T_STRING);
    Check_Type(vIndexType, T_FIXNUM);
    Check_Type(vDataType, T_FIXNUM);

    index_type = NUM2INT(vIndexType);
    data_type = NUM2INT(vDataType);

    switch(index_type) {
    case INDEX_NUMERIC:
        Check_Type(vMin, T_FIXNUM);
        switch(TYPE(vMax)) {
        case T_NIL:
        case T_FIXNUM:
            break;
        default:
            rb_raise(rb_eTypeError, "wrong argument type for max value (expected Fixnum or Nil)");
        }
        break;
    case INDEX_STRING:
        Check_Type(vMin, T_STRING);
        switch(TYPE(vMax)) {
        case T_NIL:
        case T_STRING:
            break;
        default:
            rb_raise(rb_eTypeError, "wrong argument type for max value (expected String or Nil)");
        }
        break;
    default:
        rb_raise(rb_eArgError, "Incorrect index type");
    }

    switch(data_type) {
    case CONDITION_TYPE_DEFAULT:
    case CONDITION_TYPE_LIST:
    case CONDITION_TYPE_MAPKEYS:
    case CONDITION_TYPE_MAPVALUES:
        break;
    default:
        rb_raise(rb_eArgError, "Incorrect data type");
    }

    rb_iv_set(vSelf, "@bin_name", vBinName);
    rb_iv_set(vSelf, "@index_type", vIndexType);
    rb_iv_set(vSelf, "@data_type", vDataType);
    rb_iv_set(vSelf, "@min", vMin);
    rb_iv_set(vSelf, "@max", vMax);

    return vSelf;
}

Instance Attribute Details

#bin_nameObject (readonly)

#data_typeObject (readonly)

#index_typeObject (readonly)

#maxObject (readonly)

#minObject (readonly)

Class Method Details

.equal(vBinName, vVal) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'ext/aerospike_native/condition.c', line 68

VALUE condition_equal(VALUE vSelf, VALUE vBinName, VALUE vVal)
{
    VALUE vArgs[5];
    int index_type;

    Check_Type(vBinName, T_STRING);

    switch(TYPE(vVal)) {
    case T_FIXNUM:
        index_type = INDEX_NUMERIC;
        break;
    case T_STRING:
        index_type = INDEX_STRING;
        break;
    default:
        rb_raise(rb_eTypeError, "wrong argument type for value (expected Fixnum or String)");
    }

    vArgs[0] = vBinName;
    vArgs[1] = INT2FIX(index_type);
    vArgs[2] = INT2FIX(CONDITION_TYPE_DEFAULT);
    vArgs[3] = vVal;
    vArgs[4] = Qnil;
    return rb_class_new_instance(5, vArgs, vSelf);
}

.range(vBinName, vMin, vMax) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'ext/aerospike_native/condition.c', line 94

VALUE condition_range(VALUE vSelf, VALUE vBinName, VALUE vMin, VALUE vMax)
{
    VALUE vArgs[5];

    Check_Type(vBinName, T_STRING);
    Check_Type(vMin, T_FIXNUM);
    Check_Type(vMax, T_FIXNUM);

    vArgs[0] = vBinName;
    vArgs[1] = INT2FIX(INDEX_NUMERIC);
    vArgs[2] = INT2FIX(CONDITION_TYPE_DEFAULT);
    vArgs[3] = vMin;
    vArgs[4] = vMax;
    return rb_class_new_instance(5, vArgs, vSelf);
}