92
93
94
95
96
97
98
|
# File 'lib/unm.rb', line 92
def self.find(search_term, field = 'uid', exact: false)
page = HTTParty.post(BaseUrl, body: { search_other_name: field, search_other_value: search_term })
results = Nokogiri::HTML.parse(page).css('tr').drop(1).map do |row|
Hash[[:name, :title, :contact].zip(row.css('td').map { |cell| cell.children.map(&:text).reject(&:empty?) })]
end
exact ? results.find { |result| result[:contact].any? { |email| email.split('@').first == search_term } } : results
end
|