Class: Rugged::OdbObject

Inherits:
Object
  • Object
show all
Defined in:
ext/rugged/rugged_repo.c

Instance Method Summary collapse

Instance Method Details

#dataObject

Return an ASCII buffer with the raw bytes that form the Git object.

odb_obj.data #=> "tree 87ebee8367f9cc5ac04858b3bd5610ca74f04df9\n"
             #=> "parent 68d041ee999cb07c6496fbdd4f384095de6ca9e1\n"
             #=> "author Vicent Martí <[email protected]> 1326863045 -0800\n"
             #=> ...

75
76
77
78
79
80
# File 'ext/rugged/rugged_repo.c', line 75

static VALUE rb_git_odbobj_data(VALUE self)
{
	git_odb_object *obj;
	Data_Get_Struct(self, git_odb_object, obj);
	return rb_str_new(git_odb_object_data(obj), git_odb_object_size(obj));
}

#sizeObject

Return the size in bytes of the Git object after decompression. This is also the size of the obj.data buffer.

odb_obj.size #=> 231

91
92
93
94
95
96
# File 'ext/rugged/rugged_repo.c', line 91

static VALUE rb_git_odbobj_size(VALUE self)
{
	git_odb_object *obj;
	Data_Get_Struct(self, git_odb_object, obj);
	return INT2FIX(git_odb_object_size(obj));
}

#oidObject

Return the Object ID (a 40 character SHA1 hash) for this raw object.

odb_obj.oid #=> "d8786bfc97485e8d7b19b21fb88c8ef1f199fc3f"

57
58
59
60
61
62
# File 'ext/rugged/rugged_repo.c', line 57

static VALUE rb_git_odbobj_oid(VALUE self)
{
	git_odb_object *obj;
	Data_Get_Struct(self, git_odb_object, obj);
	return rugged_create_oid(git_odb_object_id(obj));
}

#typeSymbol

Return a Ruby symbol representing the basic Git type of this object. Possible values are :tree, :blob, :commit and :tag.

odb_obj.type #=> :tag

Returns:

  • (Symbol)

107
108
109
110
111
112
# File 'ext/rugged/rugged_repo.c', line 107

static VALUE rb_git_odbobj_type(VALUE self)
{
	git_odb_object *obj;
	Data_Get_Struct(self, git_odb_object, obj);
	return rugged_otype_new(git_odb_object_type(obj));
}