Class: Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Voicemail
- Inherits:
-
AsteriskConfigGenerator
- Object
- AsteriskConfigGenerator
- Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Voicemail
- Defined in:
- lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb
Defined Under Namespace
Classes: ContextDefinition, EmailDefinition, RecordingDefinition
Constant Summary collapse
- DEFAULT_GENERAL_SECTION =
{ :format => :wav }
- STATIC_ZONEMESSAGES_CONTEXT =
Don’t worry. These will be overridable soon.
%{ [zonemessages] eastern=America/New_York|'vm-received' Q 'digits/at' IMp central=America/Chicago|'vm-received' Q 'digits/at' IMp central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours' military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p' european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM }.unindent
Constants inherited from AsteriskConfigGenerator
AsteriskConfigGenerator::SECTION_TITLE
Instance Attribute Summary collapse
-
#context_definitions ⇒ Object
readonly
Returns the value of attribute context_definitions.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
- #context(name) ⇒ Object
- #emails ⇒ Object
- #execute_on_pin_change(command) ⇒ Object
- #greeting_maximum(seconds) ⇒ Object
-
#initialize ⇒ Voicemail
constructor
A new instance of Voicemail.
- #recordings {|@recordings| ... } ⇒ Object
- #to_s ⇒ Object
Methods inherited from AsteriskConfigGenerator
create_sanitary_hash_from, #to_sanitary_hash, warning_message
Constructor Details
#initialize ⇒ Voicemail
Returns a new instance of Voicemail.
24 25 26 27 28 29 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 24 def initialize @properties = DEFAULT_GENERAL_SECTION.clone @mailboxes = {} @context_definitions = [] super end |
Instance Attribute Details
#context_definitions ⇒ Object (readonly)
Returns the value of attribute context_definitions.
23 24 25 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 23 def context_definitions @context_definitions end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
23 24 25 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 23 def properties @properties end |
Instance Method Details
#context(name) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 31 def context(name) raise ArgumentError, "Name cannot be 'general'!" if name.to_s.downcase == 'general' raise ArgumentError, "A name can only be characters, numbers, and underscores!" if name.to_s !~ /^[\w_]+$/ returning ContextDefinition.new(name) do |context_definition| yield context_definition context_definitions << context_definition end end |
#emails ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 55 def emails @emails ||= EmailDefinition.new if block_given? yield @emails else @emails end end |
#execute_on_pin_change(command) ⇒ Object
45 46 47 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 45 def execute_on_pin_change(command) string "externpass" => command end |
#greeting_maximum(seconds) ⇒ Object
41 42 43 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 41 def greeting_maximum(seconds) int "maxgreet" => seconds end |
#recordings {|@recordings| ... } ⇒ Object
49 50 51 52 53 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 49 def recordings @recordings ||= RecordingDefinition.new yield @recordings if block_given? @recordings end |
#to_s ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb', line 64 def to_s email_properties = @emails ? @emails.properties : {} AsteriskConfigGenerator. + "[general]\n" + properties.merge(email_properties).map { |(key,value)| "#{key}=#{value}" }.sort.join("\n") + "\n\n" + STATIC_ZONEMESSAGES_CONTEXT + context_definitions.map(&:to_s).join("\n\n") end |