Class: Gitlab::Git::RawDiffChange

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/git/raw_diff_change.rb

Overview

This class behaves like a struct with fields :blob_id, :blob_size, :operation, :old_path, :new_path All those fields are (binary) strings or integers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_change) ⇒ RawDiffChange

Returns a new instance of RawDiffChange.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gitlab/git/raw_diff_change.rb', line 10

def initialize(raw_change)
  if raw_change.is_a?(Gitaly::GetRawChangesResponse::RawChange)
    @blob_id = raw_change.blob_id
    @blob_size = raw_change.size
    @old_path = raw_change.old_path_bytes.presence
    @new_path = raw_change.new_path_bytes.presence
    @operation = raw_change.operation&.downcase || :unknown
  else
    parse(raw_change)
  end
end

Instance Attribute Details

#blob_idObject (readonly)

Returns the value of attribute blob_id.



8
9
10
# File 'lib/gitlab/git/raw_diff_change.rb', line 8

def blob_id
  @blob_id
end

#blob_sizeObject (readonly)

Returns the value of attribute blob_size.



8
9
10
# File 'lib/gitlab/git/raw_diff_change.rb', line 8

def blob_size
  @blob_size
end

#new_pathObject (readonly)

Returns the value of attribute new_path.



8
9
10
# File 'lib/gitlab/git/raw_diff_change.rb', line 8

def new_path
  @new_path
end

#old_pathObject (readonly)

Returns the value of attribute old_path.



8
9
10
# File 'lib/gitlab/git/raw_diff_change.rb', line 8

def old_path
  @old_path
end

#operationObject (readonly)

Returns the value of attribute operation.



8
9
10
# File 'lib/gitlab/git/raw_diff_change.rb', line 8

def operation
  @operation
end