Class: AsteriskManager::Channel
- Inherits:
-
Object
- Object
- AsteriskManager::Channel
- Defined in:
- lib/asterisk-manager/channel.rb
Instance Attribute Summary collapse
-
#application_data ⇒ Object
Returns the value of attribute application_data.
-
#application_name ⇒ Object
Returns the value of attribute application_name.
-
#caller_id_name ⇒ Object
Returns the value of attribute caller_id_name.
-
#caller_id_number ⇒ Object
Returns the value of attribute caller_id_number.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#sip_id ⇒ Object
Returns the value of attribute sip_id.
-
#state ⇒ Object
Returns the value of attribute state.
-
#unique_id ⇒ Object
Returns the value of attribute unique_id.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other_channel) ⇒ Object
- #application ⇒ Object
- #caller_id ⇒ Object
- #duration ⇒ Object
-
#initialize(arguments = {}) ⇒ Channel
constructor
A new instance of Channel.
- #seconds ⇒ Object
Constructor Details
#initialize(arguments = {}) ⇒ Channel
Returns a new instance of Channel.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/asterisk-manager/channel.rb', line 12 def initialize(arguments = {}) self.unique_id = arguments[:unique_id] self.sip_id = arguments[:sip_id] self.state = arguments[:state] self.caller_id_number = arguments[:caller_id_number] self.caller_id_name = arguments[:caller_id_name] self.application_name = arguments[:application_name] self.application_data = arguments[:application_data] self.created_at = Time.now end |
Instance Attribute Details
#application_data ⇒ Object
Returns the value of attribute application_data.
3 4 5 |
# File 'lib/asterisk-manager/channel.rb', line 3 def application_data @application_data end |
#application_name ⇒ Object
Returns the value of attribute application_name.
3 4 5 |
# File 'lib/asterisk-manager/channel.rb', line 3 def application_name @application_name end |
#caller_id_name ⇒ Object
Returns the value of attribute caller_id_name.
3 4 5 |
# File 'lib/asterisk-manager/channel.rb', line 3 def caller_id_name @caller_id_name end |
#caller_id_number ⇒ Object
Returns the value of attribute caller_id_number.
3 4 5 |
# File 'lib/asterisk-manager/channel.rb', line 3 def caller_id_number @caller_id_number end |
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/asterisk-manager/channel.rb', line 3 def created_at @created_at end |
#sip_id ⇒ Object
Returns the value of attribute sip_id.
3 4 5 |
# File 'lib/asterisk-manager/channel.rb', line 3 def sip_id @sip_id end |
#state ⇒ Object
Returns the value of attribute state.
3 4 5 |
# File 'lib/asterisk-manager/channel.rb', line 3 def state @state end |
#unique_id ⇒ Object
Returns the value of attribute unique_id.
3 4 5 |
# File 'lib/asterisk-manager/channel.rb', line 3 def unique_id @unique_id end |
Class Method Details
.channels ⇒ Object
47 48 49 |
# File 'lib/asterisk-manager/channel.rb', line 47 def self.channels @channels ||= {} end |
.for_unique_id(unique_id) ⇒ Object
51 52 53 |
# File 'lib/asterisk-manager/channel.rb', line 51 def self.for_unique_id(unique_id) channels[unique_id] ||= new(unique_id: unique_id) end |
Instance Method Details
#<=>(other_channel) ⇒ Object
43 44 45 |
# File 'lib/asterisk-manager/channel.rb', line 43 def <=>(other_channel) unique_id.to_f <=> other_channel.unique_id.to_f end |
#application ⇒ Object
23 24 25 |
# File 'lib/asterisk-manager/channel.rb', line 23 def application "#{application_name}(#{application_data})" if application_name.to_s.size > 0 end |
#caller_id ⇒ Object
27 28 29 |
# File 'lib/asterisk-manager/channel.rb', line 27 def caller_id "#{caller_id_number} #{caller_id_name}".strip end |
#duration ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/asterisk-manager/channel.rb', line 35 def duration x = seconds.round hours = x / 3600 minutes = (x - hours * 3600) / 60 seconds = (x - hours * 3600 - minutes * 60) "#{hours}:#{'%02d' % minutes}:#{'%02d' % seconds}" end |
#seconds ⇒ Object
31 32 33 |
# File 'lib/asterisk-manager/channel.rb', line 31 def seconds Time.now - created_at end |