Module: Notesgrip::DocCollection

Included in:
NotesDocumentCollection, NotesView
Defined in:
lib/notesgrip/DocCollection.rb

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/notesgrip/DocCollection.rb', line 13

def [](index)
  if index >= 0
    raw_doc = @raw_object.GetNthDocument( index + 1)  # GetNthDocument(1) is the first doc
  else
    docs_number = self.Count()
    raw_index = docs_number - index.abs
    return nil if raw_index < 0
    raw_doc = @raw_object.GetNthDocument( raw_index + 1)
  end
  raw_doc ? NotesDocument.new(raw_doc) : nil
end

#each_documentObject Also known as: each



3
4
5
6
7
8
9
10
# File 'lib/notesgrip/DocCollection.rb', line 3

def each_document
  raw_doc = @raw_object.GetFirstDocument
  while raw_doc
    next_doc = @raw_object.GetNextDocument(raw_doc)
    yield NotesDocument.new(raw_doc)
    raw_doc = next_doc
  end
end

#GetFirstDocumentObject



25
26
27
# File 'lib/notesgrip/DocCollection.rb', line 25

def GetFirstDocument
  self[0]
end

#GetLastDocumentObject



28
29
30
31
# File 'lib/notesgrip/DocCollection.rb', line 28

def GetLastDocument
  raw_doc = @raw_object.GetLastDocument
  raw_doc ? NotesDocument.new(raw_doc) : nil
end

#GetNextDocument(document) ⇒ Object



41
42
43
44
45
# File 'lib/notesgrip/DocCollection.rb', line 41

def GetNextDocument(document)
  raw_doc = toRaw(document)
  raw_nextDoc = @raw_object.GetNextDocument(raw_doc)
  raw_nextDoc ? NotesDocument.new(raw_nextDoc) : nil
end

#GetNthDocument(index) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/notesgrip/DocCollection.rb', line 33

def GetNthDocument(index)
  if index >= 1
    self[index-1]
  else
    nil
  end
end

#GetPrevDocument(document) ⇒ Object



47
48
49
50
51
# File 'lib/notesgrip/DocCollection.rb', line 47

def GetPrevDocument( document )
  raw_doc = toRaw(document)
  raw_prevDoc = @raw_object.GetPrevDocument(raw_doc)
  raw_prevDoc ? NotesDocument.new(raw_prevDoc) : nil
end