class RubyDiff::Diffs

Public Class Methods

new() click to toggle source
# File lib/rubydiff/kernel.rb, line 22
def initialize
        @diffs = []
        @sub   = {}
end

Public Instance Methods

add(diff) click to toggle source
# File lib/rubydiff/kernel.rb, line 27
def add(diff)
        @diffs << diff
end
add_all(diffs) click to toggle source
# File lib/rubydiff/kernel.rb, line 31
def add_all(diffs)
        @diffs.concat(diffs.diffs)
        diffs.subs.each do |s|
                @sub[s] = diffs.sub(s)
        end
end
add_sub(subname,diffs) click to toggle source
# File lib/rubydiff/kernel.rb, line 38
def add_sub(subname,diffs)
        @sub[subname]=diffs unless diffs.empty?
end
diffs(type=nil) click to toggle source
# File lib/rubydiff/kernel.rb, line 58
def diffs(type=nil)
        if type
                @diffs.select {|d| d.type==type}
        else
                @diffs
        end
end
empty?() click to toggle source
# File lib/rubydiff/kernel.rb, line 50
def empty?
        @sub.empty? && @diffs.empty?
end
inspect() click to toggle source
# File lib/rubydiff/kernel.rb, line 66
def inspect
        to_s
end
pretty_to_s(ntabs=0) click to toggle source
# File lib/rubydiff/kernel.rb, line 74
def pretty_to_s(ntabs=0)
        tab = "  "
        s = ""
        space = tab*ntabs
        @diffs.each {|d| s+="#{space}#{d}\n"}
        @sub.each do |k,subdiff|
                s+="#{space}#{k} ->\n"
                s+=subdiff.pretty_to_s(ntabs+1)
        end
        s
end
size() click to toggle source
# File lib/rubydiff/kernel.rb, line 54
def size
        @sub.size + @diffs.size
end
sub(key) click to toggle source
# File lib/rubydiff/kernel.rb, line 46
def sub(key)
        @sub[key]
end
subs() click to toggle source
# File lib/rubydiff/kernel.rb, line 42
def subs
        @sub.keys
end
to_s() click to toggle source
# File lib/rubydiff/kernel.rb, line 70
def to_s
        "main diffs: #{@diffs}, sub diffs: #{@sub}"
end