Class: Coopy::Change

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/coopy/change.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(txt = nil) ⇒ Change

Returns a new instance of Change.



7
8
9
10
11
12
13
14
# File 'lib/lib/coopy/change.rb', line 7

def initialize(txt = nil)
  if txt != nil 
    @mode = ::Coopy::ChangeType.note_change
    @change = txt
  else 
    @mode = ::Coopy::ChangeType.no_change
  end
end

Instance Attribute Details

#changeObject

Returns the value of attribute change.



16
17
18
# File 'lib/lib/coopy/change.rb', line 16

def change
  @change
end

#localObject

Returns the value of attribute local.



18
19
20
# File 'lib/lib/coopy/change.rb', line 18

def local
  @local
end

#modeObject

Returns the value of attribute mode.



20
21
22
# File 'lib/lib/coopy/change.rb', line 20

def mode
  @mode
end

#parentObject

Returns the value of attribute parent.



17
18
19
# File 'lib/lib/coopy/change.rb', line 17

def parent
  @parent
end

#remoteObject

Returns the value of attribute remote.



19
20
21
# File 'lib/lib/coopy/change.rb', line 19

def remote
  @remote
end

Instance Method Details

#get_modeObject



22
23
24
# File 'lib/lib/coopy/change.rb', line 22

def get_mode 
  return "" + _hx_str(@mode.to_s)
end

#to_sObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lib/coopy/change.rb', line 26

def to_s 
  begin
    _g = @mode
    case(_g.index)
    when 0
      return "no change"
    when 2
      return "local change: " + _hx_str(@remote.to_s) + " -> " + _hx_str(@local.to_s)
    when 1
      return "remote change: " + _hx_str(@local.to_s) + " -> " + _hx_str(@remote.to_s)
    when 3
      return "conflicting change: " + _hx_str(@parent.to_s) + " -> " + _hx_str(@local.to_s) + " / " + _hx_str(@remote.to_s)
    when 4
      return "same change: " + _hx_str(@parent.to_s) + " -> " + _hx_str(@local.to_s) + " / " + _hx_str(@remote.to_s)
    when 5
      return @change
    end
  end
end