Class: Gitrb::Blob

Inherits:
GitObject show all
Defined in:
lib/gitrb/blob.rb

Overview

This class stores the raw string data of a blob

Instance Attribute Summary collapse

Attributes inherited from GitObject

#id, #repository

Instance Method Summary collapse

Methods inherited from GitObject

#==, factory, #git_object, inherited

Constructor Details

#initialize(options = {}) ⇒ Blob

Initialize a Blob



9
10
11
12
13
14
# File 'lib/gitrb/blob.rb', line 9

def initialize(options = {})
  super(options)
  @data = options[:data]
  @mode = options[:mode] || 0100644
  @modified = true if !id
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/gitrb/blob.rb', line 6

def data
  @data
end

#modeObject

Returns the value of attribute mode.



6
7
8
# File 'lib/gitrb/blob.rb', line 6

def mode
  @mode
end

Instance Method Details

#dumpObject



46
47
48
# File 'lib/gitrb/blob.rb', line 46

def dump
  @data
end

#id=(id) ⇒ Object

Set new repository (modified flag is reset)



37
38
39
40
# File 'lib/gitrb/blob.rb', line 37

def id=(id)
  @modified = false
  super
end

#modified?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/gitrb/blob.rb', line 16

def modified?
  @modified
end

#saveObject

Save the data to the git object repository



51
52
53
54
55
# File 'lib/gitrb/blob.rb', line 51

def save
  raise 'Blob is empty' if !data
  repository.put(self) if modified?
  id
end

#typeObject



42
43
44
# File 'lib/gitrb/blob.rb', line 42

def type
  :blob
end