Class: AastraXmlApi::PhoneDirectory

Inherits:
Phone
  • Object
show all
Defined in:
lib/aastra_xml_api/phone_directory.rb

Constant Summary

Constants inherited from Phone

AastraXmlApi::Phone::HIGHASCII

Instance Method Summary collapse

Methods inherited from Phone

#addIcon, #addSoftkey, #convert_high_ascii, #escape, #getRefreshTimeout, #getRefreshURL, #initialize, #setAllowAnswer, #setBeep, #setCancelAction, #setDestroyOnExit, #setLockIn, #setRefresh, #setTimeout, #setTitle, #setTitleWrap

Constructor Details

This class inherits a constructor from AastraXmlApi::Phone

Instance Method Details

#addEntry(name, telephone) ⇒ Object

Add directory entry with a name to be displayed and a telephone number to dial.



62
63
64
# File 'lib/aastra_xml_api/phone_directory.rb', line 62

def addEntry(name, telephone)
  @entries += [PhoneDirectoryEntry.new(name, telephone)]
end

#natsortByNameObject

Sort array of names using natural sort order. i.e. Bob2 comes before Bob10.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/aastra_xml_api/phone_directory.rb', line 68

def natsortByName
  tmparray = []
  linklist = {}
  for i in 0..@entries.size-1
    tmparray += [@entries[i].getName]
    linklist[@entries[i].getName] = i
  end
  tmparray.extend(ArrayExtension)
  tmparray.natsort!
  newentries = []
  tmparray.each do |name|
    newentries += [@entries[linklist[name]]]
  end
  @entries = newentries
end

#renderObject

Create XML text output.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/aastra_xml_api/phone_directory.rb', line 85

def render
  out = "<AastraIPPhoneDirectory"
  if not @previous.nil? then
    previous = escape(@previous)
    out += " previous=\"#{previous}\""
  end
  if not @next.nil? then
    nextval = escape(@next)
    out += " next=\"#{nextval}\""
  end
  out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
  if not @cancelAction.nil? then
    cancelAction = escape(@cancelAction)
    out += " cancelAction=\"#{cancelAction}\""
  end
  out += " Beep=\"yes\"" if @beep == "yes"
  out += " LockIn=\"yes\"" if @lockin == "yes"
  out += " Timeout=\"#{@timeout}\"" if @timeout != 0
  out += ">\n"
  if not @title.nil? then
    title = escape(title)
    out += "<Title"
    out += " wrap=\"yes\"" if @title_wrap == "yes"
    out += ">#{title}</Title>\n"
  end
  index = 0
  @entries.each do |entry|
    out += entry.render if index < 30
    index += 1
  end
  @softkeys.each do |softkey|
    out += softkey.render
  end
  out += "</AastraIPPhoneDirectory>\n"
  return out
end

#setNext(nextval) ⇒ Object

Set the URI to load the next page of the directory.



51
52
53
# File 'lib/aastra_xml_api/phone_directory.rb', line 51

def setNext(nextval)
  @next = nextval
end

#setPrevious(previous) ⇒ Object

Set the URI to load the previous page of the directory.



56
57
58
# File 'lib/aastra_xml_api/phone_directory.rb', line 56

def setPrevious(previous)
  @previous = previous
end