Class: NT54::Parser::Visitors::WaitForAreaCodeOrMobilePrefixCompletion

Inherits:
NT54::Parser::Visitor show all
Defined in:
lib/nt54/parser/visitors/wait_for_area_code_or_mobile_prefix_completion.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
# File 'lib/nt54/parser/visitors/wait_for_area_code_or_mobile_prefix_completion.rb', line 5

def accept(keypress)
  super
  if keypress == "1"
    @number.area_code = "11"
    :area_code_completed
  elsif keypress == "5"
    @number.mobile = true
    :mobile_prefix_completed
  elsif keypress == "0" || keypress == "2"
    @number.special_sequence = "1#{keypress}"
    :special_number_started
  else raise "Invalid number #{keypress}"
  end
end