Class: Ppl::Command::Post

Inherits:
Application::Command show all
Defined in:
lib/ppl/command/post.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

#address_book_format=(value) ⇒ Object (writeonly)

Sets the attribute address_book_format

Parameters:

  • value

    the value to set the attribute address_book_format to.



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

def address_book_format=(value)
  @address_book_format = value
end

#address_service=(value) ⇒ Object (writeonly)

Sets the attribute address_service

Parameters:

  • value

    the value to set the attribute address_service to.



6
7
8
# File 'lib/ppl/command/post.rb', line 6

def address_service=(value)
  @address_service = value
end

#contact_format=(value) ⇒ Object (writeonly)

Sets the attribute contact_format

Parameters:

  • value

    the value to set the attribute contact_format to.



7
8
9
# File 'lib/ppl/command/post.rb', line 7

def contact_format=(value)
  @contact_format = value
end

#postal_address_format=(value) ⇒ Object (writeonly)

Sets the attribute postal_address_format

Parameters:

  • value

    the value to set the attribute postal_address_format to.



9
10
11
# File 'lib/ppl/command/post.rb', line 9

def postal_address_format=(value)
  @postal_address_format = value
end

Instance Method Details

#execute(input, output) ⇒ Object



49
50
51
52
# File 'lib/ppl/command/post.rb', line 49

def execute(input, output)
  action = determine_action(input)
  send(action, input, output)
end

#options(parser, options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ppl/command/post.rb', line 11

def options(parser, options)
  parser.banner = "usage: ppl post <contact> [address]"

  parser.on("-s", "--street <street-address>") do |street|
    options[:street] = street
  end
  parser.on("-z", "--postal-code <postal-code>") do |postal_code|
    options[:postal_code] = postal_code
  end
  parser.on("-p", "--po-box <po-box>") do |po_box|
    options[:po_box] = po_box
  end
  parser.on("-l", "--locality <locality>") do |locality|
    options[:locality] = locality
  end
  parser.on("-r", "--region <region>") do |region|
    options[:region] = region
  end
  parser.on("-c", "--country <country>") do |country|
    options[:country] = country
  end

  parser.on("-d", "--delete") do
    options[:delete] = true
  end
  parser.on("-m", "--move <new-id>") do |new_id|
    options[:new_id] = new_id
  end

  parser.on("-p", "--preferred", "mark address as preferred") do
    options[:preferred] = true
  end
  parser.on("-P", "--not-preferred", "mark address as not preferred") do
    options[:preferred] = false
  end

end