Class: Git::Diff::DiffFile

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

Overview

The changes for a single file within a diff

Constant Summary collapse

NIL_BLOB_REGEXP =
/\A0{4,40}\z/ 

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, hash) ⇒ DiffFile

Returns a new instance of DiffFile.

 79 80 81 82 83 84 85 86 87 88
# File 'lib/git/diff.rb', line 79 def initialize(base, hash) @base = base @patch = hash[:patch] @path = hash[:path] @mode = hash[:mode] @src = hash[:src] @dst = hash[:dst] @type = hash[:type] @binary = hash[:binary] end 

Instance Attribute Details

#dst

Returns the value of attribute dst.

 74 75 76
# File 'lib/git/diff.rb', line 74 def dst @dst end 

#mode

Returns the value of attribute mode.

 74 75 76
# File 'lib/git/diff.rb', line 74 def mode @mode end 

#patch

Returns the value of attribute patch.

 74 75 76
# File 'lib/git/diff.rb', line 74 def patch @patch end 

#path

Returns the value of attribute path.

 74 75 76
# File 'lib/git/diff.rb', line 74 def path @path end 

#src

Returns the value of attribute src.

 74 75 76
# File 'lib/git/diff.rb', line 74 def src @src end 

#type

Returns the value of attribute type.

 74 75 76
# File 'lib/git/diff.rb', line 74 def type @type end 

Instance Method Details

#binary?Boolean

Returns:

  • (Boolean)
 90 91 92
# File 'lib/git/diff.rb', line 90 def binary? !!@binary end 

#blob(type = :dst)

 94 95 96 97 98 99 100
# File 'lib/git/diff.rb', line 94 def blob(type = :dst) if type == :src && !NIL_BLOB_REGEXP.match(@src) @base.object(@src) elsif !NIL_BLOB_REGEXP.match(@dst) @base.object(@dst) end end