Class: NT54::Parser::Visitors::WaitForLocalPrefix

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

def accept(keypress)
  super
  combo = [@number.area_code.length, @number.local_prefix.length]
  if combo == [2,4] || combo == [3,3] || combo == [4,2] || combo == [0, 4]
    @number.local_number << keypress
    return :local_prefix_completed
  else
    @number.local_prefix << keypress
    nil
  end
end