Class: Batali::Unit

Inherits:
Grimoire::Unit
  • Object
show all
Defined in:
lib/batali/unit.rb

Overview

Customized Unit

Instance Method Summary collapse

Instance Method Details

#diff(u) ⇒ String

Returns difference output.

Returns:

  • (String)

    difference output



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/batali/unit.rb', line 21

def diff(u)
  Smash.new.tap do |_diff|
    [:name, :version].each do |k|
      unless(self.send(k) == u.send(k))
        _diff[k] = [self.send(k), u.send(k)]
      end
    end
    if(source)
      _diff.merge!(source.diff(u.source))
    end
  end
end

#diff?(u) ⇒ TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


11
12
13
# File 'lib/batali/unit.rb', line 11

def diff?(u)
  !same?(u)
end

#same?(u) ⇒ TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


16
17
18
# File 'lib/batali/unit.rb', line 16

def same?(u)
  diff(u).empty?
end