Class: GitDiff::File
- Inherits:
-
Object
- Object
- GitDiff::File
- Defined in:
- lib/git_diff/file.rb
Instance Attribute Summary collapse
-
#a_blob ⇒ Object
readonly
Returns the value of attribute a_blob.
-
#a_path ⇒ Object
readonly
Returns the value of attribute a_path.
-
#b_blob ⇒ Object
readonly
Returns the value of attribute b_blob.
-
#b_mode ⇒ Object
readonly
Returns the value of attribute b_mode.
-
#b_path ⇒ Object
readonly
Returns the value of attribute b_path.
-
#binary ⇒ Object
readonly
Returns the value of attribute binary.
-
#hunks ⇒ Object
readonly
Returns the value of attribute hunks.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(string) ⇒ Object
-
#initialize(a_path: "/dev/null", b_path: "/dev/null") ⇒ File
constructor
A new instance of File.
- #stats ⇒ Object
Constructor Details
#initialize(a_path: "/dev/null", b_path: "/dev/null") ⇒ File
16 17 18 19 20 |
# File 'lib/git_diff/file.rb', line 16 def initialize(a_path: "/dev/null", b_path: "/dev/null") @hunks = [] @a_path = a_path @b_path = b_path end |
Instance Attribute Details
#a_blob ⇒ Object (readonly)
Returns the value of attribute a_blob.
5 6 7 |
# File 'lib/git_diff/file.rb', line 5 def a_blob @a_blob end |
#a_path ⇒ Object (readonly)
Returns the value of attribute a_path.
5 6 7 |
# File 'lib/git_diff/file.rb', line 5 def a_path @a_path end |
#b_blob ⇒ Object (readonly)
Returns the value of attribute b_blob.
5 6 7 |
# File 'lib/git_diff/file.rb', line 5 def b_blob @b_blob end |
#b_mode ⇒ Object (readonly)
Returns the value of attribute b_mode.
5 6 7 |
# File 'lib/git_diff/file.rb', line 5 def b_mode @b_mode end |
#b_path ⇒ Object (readonly)
Returns the value of attribute b_path.
5 6 7 |
# File 'lib/git_diff/file.rb', line 5 def b_path @b_path end |
#binary ⇒ Object (readonly)
Returns the value of attribute binary.
5 6 7 |
# File 'lib/git_diff/file.rb', line 5 def binary @binary end |
#hunks ⇒ Object (readonly)
Returns the value of attribute hunks.
5 6 7 |
# File 'lib/git_diff/file.rb', line 5 def hunks @hunks end |
Class Method Details
.from_string(string) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/git_diff/file.rb', line 7 def self.from_string(string) if path_info = %r{^diff --git(?: a/(\S+))?(?: b/(\S+))?}.match(string) File.new( a_path: path_info.captures[0] || "/dev/null", b_path: path_info.captures[1] || "/dev/null" ) end end |
Instance Method Details
#<<(string) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/git_diff/file.rb', line 22 def <<(string) return if (string) if (range_info = RangeInfo.from_string(string)) add_hunk Hunk.new(range_info) else append_to_current_hunk string end end |
#stats ⇒ Object
32 33 34 |
# File 'lib/git_diff/file.rb', line 32 def stats @stats ||= Stats.total(collector) end |