Class: EtherpadLite::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/etherpad-lite/models/diff.rb

Overview

Represents a diff between two Pad revisions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pad, start_rev, end_rev = nil) ⇒ Diff

If end_rev is not specified, the latest revision will be used



14
15
16
17
18
19
# File 'lib/etherpad-lite/models/diff.rb', line 14

def initialize(pad, start_rev, end_rev=nil)
  @instance = pad.instance
  @pad = pad
  @start_rev = start_rev
  @end_rev = end_rev || pad.revision_numbers.last
end

Instance Attribute Details

#end_revObject

Diff end revision



11
12
13
# File 'lib/etherpad-lite/models/diff.rb', line 11

def end_rev
  @end_rev
end

#instanceObject

The EtherpadLite::Instance object



5
6
7
# File 'lib/etherpad-lite/models/diff.rb', line 5

def instance
  @instance
end

#padObject

The EtherpadLite::Pad object



7
8
9
# File 'lib/etherpad-lite/models/diff.rb', line 7

def pad
  @pad
end

#start_revObject

Diff start revision



9
10
11
# File 'lib/etherpad-lite/models/diff.rb', line 9

def start_rev
  @start_rev
end

Instance Method Details

#author_idsObject

Returns the IDs of the authors who were involved in the diff



27
28
29
# File 'lib/etherpad-lite/models/diff.rb', line 27

def author_ids
  diff[:authors]
end

#authorsObject

Returns Authors who were involved in the diff



32
33
34
# File 'lib/etherpad-lite/models/diff.rb', line 32

def authors
  @authors ||= author_ids.map { |id| Author.new(instance, id) }
end

#htmlObject

Returns the diff as html



22
23
24
# File 'lib/etherpad-lite/models/diff.rb', line 22

def html
  diff[:html]
end