Class: Black::Git::Diff

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/black/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, sha, sha_previous, diff_output, filename, status) ⇒ Diff

Returns a new instance of Diff.



102
103
104
105
106
107
108
109
# File 'lib/black/git.rb', line 102

def initialize(path, sha, sha_previous, diff_output, filename, status)
  @path = path
  @sha = sha
  @sha_previous = sha_previous
  @diff_output = diff_output
  @filename = filename
  @status = status
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



100
101
102
# File 'lib/black/git.rb', line 100

def filename
  @filename
end

#newerObject (readonly)

Returns the value of attribute newer.



100
101
102
# File 'lib/black/git.rb', line 100

def newer
  @newer
end

#olderObject (readonly)

Returns the value of attribute older.



100
101
102
# File 'lib/black/git.rb', line 100

def older
  @older
end

#statusObject (readonly)

Returns the value of attribute status.



100
101
102
# File 'lib/black/git.rb', line 100

def status
  @status
end

Instance Method Details

#diff_parsedObject



129
130
131
# File 'lib/black/git.rb', line 129

def diff_parsed
  Black::Diff::OutputParser.parse(@diff_output.enum_for(:lines))
end

#eachObject



111
112
113
114
115
116
117
118
119
# File 'lib/black/git.rb', line 111

def each
  if block_given?
    diff_parsed.each do |line|
      yield line
    end
  else
    diff_parsed.enum_for(:each) 
  end
end