Class: Git::Diff::DiffFile
- Inherits:
-
Object
- Object
- Git::Diff::DiffFile
- 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
-
#dst
Returns the value of attribute dst.
-
#mode
Returns the value of attribute mode.
-
#patch
Returns the value of attribute patch.
-
#path
Returns the value of attribute path.
-
#src
Returns the value of attribute src.
-
#type
Returns the value of attribute type.
Instance Method Summary collapse
- #binary? ⇒ Boolean
- #blob(type = :dst)
-
#initialize(base, hash) ⇒ DiffFile
constructor
A new instance of DiffFile.
Constructor Details
#initialize(base, hash) ⇒ DiffFile
Returns a new instance of DiffFile.
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/git/diff.rb', line 109 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.
104 105 106 |
# File 'lib/git/diff.rb', line 104 def dst @dst end |
#mode
Returns the value of attribute mode.
104 105 106 |
# File 'lib/git/diff.rb', line 104 def mode @mode end |
#patch
Returns the value of attribute patch.
104 105 106 |
# File 'lib/git/diff.rb', line 104 def patch @patch end |
#path
Returns the value of attribute path.
104 105 106 |
# File 'lib/git/diff.rb', line 104 def path @path end |
#src
Returns the value of attribute src.
104 105 106 |
# File 'lib/git/diff.rb', line 104 def src @src end |
#type
Returns the value of attribute type.
104 105 106 |
# File 'lib/git/diff.rb', line 104 def type @type end |
Instance Method Details
#binary? ⇒ Boolean
120 121 122 |
# File 'lib/git/diff.rb', line 120 def binary? !!@binary end |
#blob(type = :dst)
124 125 126 127 128 129 130 |
# File 'lib/git/diff.rb', line 124 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 |