Class: Rundown::Processors::Phone
- Inherits:
-
Rundown::Processor
- Object
- Rundown::Processor
- Rundown::Processors::Phone
- Defined in:
- lib/rundown/processors/phone.rb
Constant Summary
Constants inherited from Rundown::Processor
Rundown::Processor::PUNCTUATION
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from Rundown::Processor
Instance Method Summary collapse
- #format(number) ⇒ Object
-
#initialize(words, formatter = Phony) ⇒ Phone
constructor
A new instance of Phone.
- #process ⇒ Object
Methods inherited from Rundown::Processor
Constructor Details
#initialize(words, formatter = Phony) ⇒ Phone
Returns a new instance of Phone.
6 7 8 9 |
# File 'lib/rundown/processors/phone.rb', line 6 def initialize(words, formatter=Phony) @text = words @formatter = formatter end |
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
4 5 6 |
# File 'lib/rundown/processors/phone.rb', line 4 def formatter @formatter end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/rundown/processors/phone.rb', line 4 def text @text end |
Instance Method Details
#format(number) ⇒ Object
11 12 13 |
# File 'lib/rundown/processors/phone.rb', line 11 def format(number) number.start_with?('0') ? number : formatter.formatted(number) end |
#process ⇒ Object
15 16 17 |
# File 'lib/rundown/processors/phone.rb', line 15 def process remove_punctuation(text).scan(/\d{7,13}/).map {|number| format(number) } end |