Class | Ohcount::LocDeltaList
In: | lib/ohcount/loc_delta_list.rb
Parent: | Object

Tracks changes to lines of code, comments, and blanks for multiple languages

### Methods

+ == add_loc_delta blanks_added blanks_removed code_added code_removed comments_added comments_removed compact languages loc_delta net_blanks net_code net_comments net_total new

### Attributes

loc_deltas | [RW] |

### Public Class methods

new(loc_deltas=[])

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 6
                    def initialize(loc_deltas=[])
                            @loc_deltas = loc_deltas
                    end

### Public Instance methods

+(addend)

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 18
                    def +(addend)
                            case addend
                            when LocDelta
                                    add_loc_delta(addend)
                            else
                                    raise ArgumentError.new
                            end
                    end

==(b)

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 82
                    def ==(b)
                            return false unless b
                            return false unless languages == b.languages

                            self.languages.each do |l|
                                    return false unless self.loc_delta(l) == b.loc_delta(l)
                            end
                            true
                    end

add_loc_delta(addend)

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 27
                    def add_loc_delta(addend)
                            existing = loc_delta(addend.language)
                            if existing
                                    existing += addend
                            else
                                    @loc_deltas << addend
                            end
                            self
                    end

blanks_added()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 53
                    def blanks_added
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.blanks_added }
                    end

blanks_removed()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 57
                    def blanks_removed
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.blanks_removed }
                    end

code_added()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 37
                    def code_added
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.code_added }
                    end

code_removed()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 41
                    def code_removed
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.code_removed }
                    end

comments_added()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 45
                    def comments_added
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.comments_added }
                    end

comments_removed()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 49
                    def comments_removed
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.comments_removed }
                    end

compact()

Returns a new LocDeltaList excluding all languages that have no changes

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 78
                    def compact
                            LocDeltaList.new(@loc_deltas.reject { |delta| !delta.changed? })
                    end

languages()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 14
                    def languages
                            @loc_deltas.collect { |loc_delta| loc_delta.language }
                    end

loc_delta(language)

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 10
                    def loc_delta(language)
                            @loc_deltas.find { |loc_delta| loc_delta.language == language }
                    end

net_blanks()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 69
                    def net_blanks
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.net_blanks }
                    end

net_code()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 61
                    def net_code
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.net_code }
                    end

net_comments()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 65
                    def net_comments
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.net_comments }
                    end

net_total()

[Source]

    # File lib/ohcount/loc_delta_list.rb, line 73
                    def net_total
                            @loc_deltas.inject(0) { |sum, delta| sum + delta.net_total }
                    end

[Validate]