Class: Usamin::Value
- Inherits:
-
Object
- Object
- Usamin::Value
- Defined in:
- ext/usamin/usamin.cpp
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Returns whether the value is equals to the other value.
-
#===(other) ⇒ Boolean
Returns whether the value is equals to the other value.
-
#array? ⇒ Boolean
Returns whether the value is array.
- #eql?(other) ⇒ Boolean
-
#eval ⇒ Object
Convert to Ruby data structures.
-
#eval_r ⇒ Object
Convert to Ruby data structures recursively.
-
#frozen? ⇒ Boolean
Always true.
- #hash ⇒ Integer
-
#hash? ⇒ Boolean
Returns whether the value is object.
-
#object? ⇒ Boolean
Returns whether the value is object.
-
#root ⇒ UsaminValue
Returns root object.
Instance Method Details
#==(other) ⇒ Boolean
Returns whether the value is equals to the other value.
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'ext/usamin/usamin.cpp', line 627
static VALUE w_value_equal(const VALUE self, const VALUE other) {
if (self == other)
return Qtrue;
UsaminValue *value_self = get_value(self);
check_value(value_self);
if (rb_obj_is_kind_of(other, rb_cUsaminValue)) {
UsaminValue *value_other = get_value(other);
check_value(value_other);
return value_self->value->operator==(*value_other->value) ? Qtrue : Qfalse;
} else if (value_self->value->IsArray() && RB_TYPE_P(other, T_ARRAY)) {
if (value_self->value->Size() != RARRAY_LEN(other))
return Qfalse;
return rb_equal(other, eval_array(*value_self->value, value_self->root_document));
} else if (value_self->value->IsObject() && RB_TYPE_P(other, T_HASH)) {
if (value_self->value->MemberCount() != RHASH_SIZE(other))
return Qfalse;
return rb_equal(other, eval_object(*value_self->value, value_self->root_document));
}
return Qfalse;
}
|
#===(other) ⇒ Boolean
Returns whether the value is equals to the other value.
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'ext/usamin/usamin.cpp', line 627
static VALUE w_value_equal(const VALUE self, const VALUE other) {
if (self == other)
return Qtrue;
UsaminValue *value_self = get_value(self);
check_value(value_self);
if (rb_obj_is_kind_of(other, rb_cUsaminValue)) {
UsaminValue *value_other = get_value(other);
check_value(value_other);
return value_self->value->operator==(*value_other->value) ? Qtrue : Qfalse;
} else if (value_self->value->IsArray() && RB_TYPE_P(other, T_ARRAY)) {
if (value_self->value->Size() != RARRAY_LEN(other))
return Qfalse;
return rb_equal(other, eval_array(*value_self->value, value_self->root_document));
} else if (value_self->value->IsObject() && RB_TYPE_P(other, T_HASH)) {
if (value_self->value->MemberCount() != RHASH_SIZE(other))
return Qfalse;
return rb_equal(other, eval_object(*value_self->value, value_self->root_document));
}
return Qfalse;
}
|
#array? ⇒ Boolean
Returns whether the value is array.
651 652 653 654 655 |
# File 'ext/usamin/usamin.cpp', line 651
static VALUE w_value_isarray(const VALUE self) {
UsaminValue *value = get_value(self);
check_value(value);
return value->value->IsArray() ? Qtrue : Qfalse;
}
|
#eql?(other) ⇒ Boolean
696 697 698 699 700 701 702 703 704 705 706 |
# File 'ext/usamin/usamin.cpp', line 696
static VALUE w_value_eql(const VALUE self, const VALUE other) {
if (self == other)
return Qtrue;
if (!rb_obj_is_kind_of(other, rb_cUsaminValue))
return Qfalse;
UsaminValue *value_self = get_value(self);
UsaminValue *value_other = get_value(other);
check_value(value_self);
check_value(value_other);
return eql_value(*value_self->value, *value_other->value) ? Qtrue : Qfalse;
}
|
#eval ⇒ Object
Convert to Ruby data structures.
671 672 673 674 675 676 677 678 679 680 |
# File 'ext/usamin/usamin.cpp', line 671
static VALUE w_value_eval(const VALUE self) {
UsaminValue *value = get_value(self);
check_value(value);
if (value->value->IsObject())
return eval_object(*(value->value), value->root_document);
else if (value->value->IsArray())
return eval_array(*(value->value), value->root_document);
else
return Qnil;
}
|
#eval_r ⇒ Object
Convert to Ruby data structures recursively.
687 688 689 690 691 |
# File 'ext/usamin/usamin.cpp', line 687
static VALUE w_value_eval_r(const VALUE self) {
UsaminValue *value = get_value(self);
check_value(value);
return eval_r(*(value->value));
}
|
#frozen? ⇒ Boolean
Always true.
711 712 713 |
# File 'ext/usamin/usamin.cpp', line 711 static VALUE w_value_isfrozen(const VALUE self) { return Qtrue; } |
#hash ⇒ Integer
718 719 720 721 722 |
# File 'ext/usamin/usamin.cpp', line 718
static VALUE w_value_hash(const VALUE self) {
UsaminValue *value = get_value(self);
check_value(value);
return ST2FIX(hash_value(*value->value));
}
|
#hash? ⇒ Boolean
Returns whether the value is object.
660 661 662 663 664 |
# File 'ext/usamin/usamin.cpp', line 660
static VALUE w_value_isobject(const VALUE self) {
UsaminValue *value = get_value(self);
check_value(value);
return value->value->IsObject() ? Qtrue : Qfalse;
}
|
#object? ⇒ Boolean
Returns whether the value is object.
660 661 662 663 664 |
# File 'ext/usamin/usamin.cpp', line 660
static VALUE w_value_isobject(const VALUE self) {
UsaminValue *value = get_value(self);
check_value(value);
return value->value->IsObject() ? Qtrue : Qfalse;
}
|
#root ⇒ UsaminValue
Returns root object.
729 730 731 732 733 |
# File 'ext/usamin/usamin.cpp', line 729
static VALUE w_value_root(const VALUE self) {
UsaminValue *value = get_value(self);
check_value(value);
return value->root_document;
}
|