lib/ppl/command/mutt.rb in ppl-1.8.0 vs lib/ppl/command/mutt.rb in ppl-1.9.0
- old
+ new
@@ -16,11 +16,11 @@
def execute(input, output)
query = require_query(input)
matches = mutt_search(query)
output.line(describe_result(matches))
- matches.count > 0
+ matches.contacts.length > 0
end
private
@@ -33,39 +33,39 @@
def mutt_search(query)
@address_book = @storage.load_address_book
matches = Ppl::Entity::AddressBook.new
- @address_book.each do |contact|
+ @address_book.contacts.each do |contact|
next if contact.email_addresses.empty?
matching_emails = contact.email_addresses.select do |email_address|
email_address.include? query
end
if matching_emails.length > 0
- matches.add_contact(contact)
+ matches.contacts.push(contact)
elsif !contact.name.nil? && contact.name.include?(query)
- matches.add_contact(contact)
+ matches.contacts.push(contact)
end
end
matches
end
def describe_result(matches)
- if matches.count > 0
+ if matches.contacts.length > 0
describe_matches(matches)
else
"No matches"
end
end
def describe_matches(matches)
summary = sprintf(
"Searching address book... %d entries... %d matching:",
- @address_book.count,
- matches.count
+ @address_book.contacts.length,
+ matches.contacts.length
)
results = @format.process(matches)
[summary, results].join("\n").strip
end