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.


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

def initialize(commit)
  @commit = commit
  calculate_stat
end

Instance Attribute Details

#commitObject (readonly)

Returns the value of attribute commit


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

def commit
  @commit
end

#deletionsObject (readonly)

Returns the value of attribute deletions


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

def deletions
  @deletions
end

#insertionsObject (readonly)

Returns the value of attribute insertions


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

def insertions
  @insertions
end

Instance Method Details

#changed_linesObject


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

def changed_lines
  insertions + deletions
end

#escape_characters_in_string(string) ⇒ Object


20
21
22
23
# File 'lib/git_stats/git_data/comment_stat.rb', line 20

def escape_characters_in_string(string)
	pattern = /(\'|\"|\.|\*|\/|\-|\\)/
	string.gsub(pattern){|match|"\\"  + match}
end

#to_sObject


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

def to_s
  "#{self.class} #@commit"
end