# Responsible for accessing specific data in the output of the `sloccount` command class SLOCCount def initialize(sloccount_output) @sloccount_output = sloccount_output end def total total_regex = /^Total Physical Source Lines of Code.*= ([\d\,]+)/ # Numbers in sloccount are displayed with commas e.g. 1,791 @sloccount_output.match(total_regex)[1].delete(',').to_i end end # TODO: should be ZeroSLOCCount? More descriptive, but less obvious it's null object pattern class NullSLOCCount def total 0 end end