Class: PhoneNumbers

Inherits:
Array
  • Object
show all
Defined in:
lib/order_information.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from(source) ⇒ Object



86
87
88
89
90
91
92
93
94
95
# File 'lib/order_information.rb', line 86

def self.from(source)
  doc = Nokogiri::HTML(source)
  numbers = doc.css("select[name=telSeq] > option").map { |option| PhoneNumber.new(option) }

  if numbers.empty?
    raise "Couldn't find any saved phone numbers in the information input page"
  end

  PhoneNumbers.new(numbers)
end

Instance Method Details

#find_number(number) ⇒ Object



97
98
99
# File 'lib/order_information.rb', line 97

def find_number(number)
  detect { |phone_number| phone_number.number == number }
end

#selection_listObject



101
102
103
# File 'lib/order_information.rb', line 101

def selection_list
  map(&:list_item)
end