Class: Hiptest::AnnotationsCounter

Inherits:
Object
  • Object
show all
Defined in:
lib/hiptest-publisher/gherkin_adder.rb

Instance Method Summary collapse

Constructor Details

#initializeAnnotationsCounter

Returns a new instance of AnnotationsCounter.



145
146
147
# File 'lib/hiptest-publisher/gherkin_adder.rb', line 145

def initialize
  @counts_by_actionword = Hash.new {|counts, actionword| counts[actionword] = Hash.new(0) }
end

Instance Method Details

#actionwordsObject



149
150
151
# File 'lib/hiptest-publisher/gherkin_adder.rb', line 149

def actionwords
  @counts_by_actionword.keys
end

#increment(actionword, annotation) ⇒ Object



153
154
155
156
# File 'lib/hiptest-publisher/gherkin_adder.rb', line 153

def increment(actionword, annotation)
  counts = @counts_by_actionword[actionword]
  counts[annotation] += 1 if annotation
end

#most_used_annotation(actionword) ⇒ Object



158
159
160
161
# File 'lib/hiptest-publisher/gherkin_adder.rb', line 158

def most_used_annotation(actionword)
  max = @counts_by_actionword[actionword].values.max
  @counts_by_actionword[actionword].key(max)
end