Class: GitReviewer::DiffLine

Inherits:
Object
  • Object
show all
Defined in:
lib/gitreviewer/analyze/diff_tree.rb

Constant Summary collapse

UNCHANGE =

未变化

0
DELETE =

删除行

1
ADD =

新增行

2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_line, target_line, operation) ⇒ DiffLine



126
127
128
129
130
# File 'lib/gitreviewer/analyze/diff_tree.rb', line 126

def initialize(source_line, target_line, operation)
  @source_line = source_line
  @target_line = target_line
  @operation = operation
end

Instance Attribute Details

#operationObject

Returns the value of attribute operation.



124
125
126
# File 'lib/gitreviewer/analyze/diff_tree.rb', line 124

def operation
  @operation
end

#source_lineObject

对于 UNCHANGE 操作,sLine 有值,tLine 有值对于 DELETE 操作,sLine 有值,tLine 无值对于 ADD 操作,sLine 无值,tLine 有值



122
123
124
# File 'lib/gitreviewer/analyze/diff_tree.rb', line 122

def source_line
  @source_line
end

#target_lineObject

目标行, BlameLine



123
124
125
# File 'lib/gitreviewer/analyze/diff_tree.rb', line 123

def target_line
  @target_line
end

Instance Method Details

#format_userObject



144
145
146
147
148
149
150
151
152
# File 'lib/gitreviewer/analyze/diff_tree.rb', line 144

def format_user
  if operation == DiffLine::DELETE
    return source_line.user
  elsif operation == DiffLine::ADD
    return target_line.user
  else
    return source_line.user
  end
end

#is_unchangeObject



132
133
134
# File 'lib/gitreviewer/analyze/diff_tree.rb', line 132

def is_unchange
  operation == UNCHANGE
end

#s_line_numberObject



136
137
138
# File 'lib/gitreviewer/analyze/diff_tree.rb', line 136

def s_line_number
  source_line.line
end

#t_line_numberObject



140
141
142
# File 'lib/gitreviewer/analyze/diff_tree.rb', line 140

def t_line_number
  target_line.line
end