Class: Avaya::CallList

Inherits:
Object
  • Object
show all
Defined in:
lib/avaya/call_list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCallList

Returns a new instance of CallList.



11
12
13
14
15
16
17
18
19
20
# File 'lib/avaya/call_list.rb', line 11

def initialize

  @ras   = []
  @pots  = []
  @sip   = []
  @q93   = []
  @calls = []
  @raw   = Avaya::TFTP.read(:call_list)

end

Instance Attribute Details

#callsObject (readonly)

Returns the value of attribute calls.



3
4
5
# File 'lib/avaya/call_list.rb', line 3

def calls
  @calls
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/avaya/call_list.rb', line 3

def name
  @name
end

#potsObject (readonly)

Returns the value of attribute pots.



3
4
5
# File 'lib/avaya/call_list.rb', line 3

def pots
  @pots
end

#q93Object (readonly)

Returns the value of attribute q93.



3
4
5
# File 'lib/avaya/call_list.rb', line 3

def q93
  @q93
end

#rasObject (readonly)

Returns the value of attribute ras.



3
4
5
# File 'lib/avaya/call_list.rb', line 3

def ras
  @ras
end

#rawObject (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/avaya/call_list.rb', line 3

def raw
  @raw
end

#sipObject (readonly)

Returns the value of attribute sip.



3
4
5
# File 'lib/avaya/call_list.rb', line 3

def sip
  @sip
end

Class Method Details

.getObject



22
23
24
25
26
# File 'lib/avaya/call_list.rb', line 22

def self.get
  call_list = self.new
  call_list.get
  call_list
end

Instance Method Details

#call_line(line) ⇒ Object



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
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/avaya/call_list.rb', line 91

def call_line(line)
  matches = line =~ /CALL: ([0-9.]*) State=([0-9]*) Cut=([0-9]*) Music=([(0-9.)]*) Aend="([\S\s]*)" \(([0-9.]*)\) Bend="([\S\s]*)" \[([\S\s]*)\] \(([0-9.]*)\) CalledNum=([\S\s]*) \(([\S\s]*)\) CallingNum=([\S\s]*) \(([\S\s]*)\) Internal=([0-9]*) Time=([0-9]*) AState=([0-9]*)/
  call_id             = $1
  state               = $2
  cut                 = $3
  music               = $4
  a_end               = $5
  a_end_value         = $6
  b_end               = $7
  b_end_desc          = $8
  b_end_value         = $9
  called_number       = $10
  called_number_desc  = $11
  calling_number      = $12
  calling_number_desc = $13
  internal            = $14
  time                = $15
  astate              = $16



  call_det= {
      call_id:          call_id,
      state:            state,
      cut:              cut,
      music:            music,
      a_end:            a_end,
      a_end_value:      a_end_value,
      b_end:            b_end,
      b_end_value:      b_end_value,
      b_end_desc:       b_end_desc,
      called_num:       called_number,
      called_num_desc:  called_number_desc,
      calling_num:      calling_number,
      calling_num_desc: calling_number_desc,
      internal:         internal,
      time:             time,
      astate:           astate
  }

  @calls << call_det

end

#getObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/avaya/call_list.rb', line 28

def get

  #items = @all_calls.collect { |row| row.gsub(/Line /, 'Line_').split(' ') }
  @raw.each do |call|

    if call.start_with?("NAME: ")
      @name = call.gsub!('NAME: ', '').gsub!('"', '')
    elsif call.start_with? "POTS:"
      pots_line(call)
    elsif call.start_with? "RAS:"
      ras_line(call)
    elsif call.start_with? "SIPLine:"
      sip_line(call)
    elsif call.start_with? "Q931Line:"
      q93_line(call)

    elsif call.start_with? "CALL:"
      call_line(call)
    end

  end

end

#pots_line(line) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/avaya/call_list.rb', line 52

def pots_line(line)
  pots_det = {
      id:    line.match(/^POTS: [0-9]*/).to_s.gsub!(/POTS: /, ''),
      count: line.match(/Chans=[0-9]*/).to_s.gsub!(/Chans=/, '')
  }
  @pots << pots_det
end

#q93_line(line) ⇒ Object



80
81
82
83
84
85
86
87
88
89
# File 'lib/avaya/call_list.rb', line 80

def q93_line(line)

  q93_det = {
      id:      line.match(/^Q931Line: [0-9]*/).to_s.gsub!(/Q931Line: /, ''),
      count:   line.match(/Chans=[0-9]*/).to_s.gsub!(/Chans=/, ''),
      used:    line.match(/Used=[0-9]*/).to_s.gsub!(/Used=/, ''),
      version: line.match(/Version=.*/).to_s.gsub!(/Version=/, '')
  }
  @q93 << q93_det
end

#ras_line(line) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/avaya/call_list.rb', line 60

def ras_line(line)
  ras_det = {
      id:    line.match(/^RAS: [0-9]*/).to_s.gsub!(/RAS: /, ''),
      count: line.match(/Chans=[0-9]*/).to_s.gsub!(/Chans=/, '')
  }
  @ras << ras_det

end

#sip_line(line) ⇒ Object



69
70
71
72
73
74
75
76
77
78
# File 'lib/avaya/call_list.rb', line 69

def sip_line(line)

  sip_det = {
      id:      line.match(/^SIPLine: [0-9]*/).to_s.gsub!(/SIPLine: /, ''),
      count:   line.match(/Chans=[0-9]*/).to_s.gsub!(/Chans=/, ''),
      used:    line.match(/Used=[0-9]*/).to_s.gsub!(/Used=/, ''),
      version: line.match(/Version=.*/).to_s.gsub!(/Version=/, '')
  }
  @sip << sip_det
end