Class: GitStats::GitData::CommentStat

Inherits:
Object
  • Object
show all
Defined in:
lib/git_stats/git_data/comment_stat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commit) ⇒ CommentStat

Returns a new instance of CommentStat.



8
9
10
11
# File 'lib/git_stats/git_data/comment_stat.rb', line 8

def initialize(commit)
  @commit = commit
  calculate_stat
end

Instance Attribute Details

#commitObject (readonly)

Returns the value of attribute commit.



6
7
8
# File 'lib/git_stats/git_data/comment_stat.rb', line 6

def commit
  @commit
end

#deletionsObject (readonly)

Returns the value of attribute deletions.



6
7
8
# File 'lib/git_stats/git_data/comment_stat.rb', line 6

def deletions
  @deletions
end

#insertionsObject (readonly)

Returns the value of attribute insertions.



6
7
8
# File 'lib/git_stats/git_data/comment_stat.rb', line 6

def insertions
  @insertions
end

Instance Method Details

#changed_linesObject



13
14
15
# File 'lib/git_stats/git_data/comment_stat.rb', line 13

def changed_lines
  insertions + deletions
end

#escape_characters_in_string(string) ⇒ Object



17
18
19
20
# File 'lib/git_stats/git_data/comment_stat.rb', line 17

def escape_characters_in_string(string)
  pattern = %r{['".*/\\-]}
  string.gsub(pattern) { |match| "\\#{match}" }
end