Class: NT54::Parser::Visitors::Dialtone

Inherits:
NT54::Parser::Visitor show all
Defined in:
lib/nt54/parser/visitors/dialtone.rb

Instance Attribute Summary

Attributes inherited from NT54::Parser::Visitor

#number

Instance Method Summary collapse

Methods inherited from NT54::Parser::Visitor

#initialize, #to_sym

Constructor Details

This class inherits a constructor from NT54::Parser::Visitor

Instance Method Details

#accept(keypress) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nt54/parser/visitors/dialtone.rb', line 5

def accept(keypress)
  super
  case keypress
  when "+"
    :country_code_indicated
  when "1"
    :mobile_prefix_or_area_code_started
  when "0"
    :area_code_indicated
  when ("4".."8")
    @number.local_prefix << keypress
    :local_prefix_started
  when("9")
    @number.special_sequence << keypress
    :special_number_started
  else raise "Don't know how to handle #{keypress}"
  end
end