Class: Ppl::Command::Scrape

Inherits:
Application::Command show all
Defined in:
lib/ppl/command/scrape.rb

Instance Attribute Summary collapse

Attributes inherited from Application::Command

#storage

Instance Method Summary collapse

Methods inherited from Application::Command

add_property

Instance Attribute Details

#email_scraper=(value) ⇒ Object (writeonly)

Sets the attribute email_scraper

Parameters:

  • value

    the value to set the attribute email_scraper to.



8
9
10
# File 'lib/ppl/command/scrape.rb', line 8

def email_scraper=(value)
  @email_scraper = value
end

Instance Method Details

#execute(input, output) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/ppl/command/scrape.rb', line 20

def execute(input, output)
  contacts = scrape_email(input)
  contacts.each do |contact|
    if store_contact?(contact, input)
      @storage.save_contact(contact)
    end
  end
  return true
end

#options(parser, options) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/ppl/command/scrape.rb', line 10

def options(parser, options)
  parser.banner = "usage: ppl scrape [<options>]"
  parser.on("-q", "--quiet", "Add contacts to the address book without prompting") do |i|
    options[:quiet] = i
  end
  parser.on("-s", "--sender", "Scrape the sender's contact details") do |i|
    options[:sender] = i
  end
end