Class: Dcc::Diff::Change

Inherits:
Struct
  • Object
show all
Defined in:
lib/dcc/diff/change.rb

Overview

A single structural change between two DCC object trees.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#afterObject

Returns the value of attribute after

Returns:

  • (Object)

    the current value of after



6
7
8
# File 'lib/dcc/diff/change.rb', line 6

def after
  @after
end

#beforeObject

Returns the value of attribute before

Returns:

  • (Object)

    the current value of before



6
7
8
# File 'lib/dcc/diff/change.rb', line 6

def before
  @before
end

#kindObject

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



6
7
8
# File 'lib/dcc/diff/change.rb', line 6

def kind
  @kind
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



6
7
8
# File 'lib/dcc/diff/change.rb', line 6

def path
  @path
end

Instance Method Details

#added?Boolean

Returns:

  • (Boolean)


7
# File 'lib/dcc/diff/change.rb', line 7

def added? = kind == :add

#changed?Boolean

Returns:

  • (Boolean)


9
# File 'lib/dcc/diff/change.rb', line 9

def changed? = kind == :change

#removed?Boolean

Returns:

  • (Boolean)


8
# File 'lib/dcc/diff/change.rb', line 8

def removed? = kind == :remove

#to_sObject



11
12
13
14
15
16
17
18
# File 'lib/dcc/diff/change.rb', line 11

def to_s
  case kind
  when :add    then "+ #{path}: #{after}"
  when :remove then "- #{path}: #{before}"
  when :change then "~ #{path}: #{before} -> #{after}"
  else path
  end
end