Class: ShareToGplus::Executable

Inherits:
Object
  • Object
show all
Defined in:
lib/share_to_gplus/executable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExecutable

Returns a new instance of Executable.



12
13
14
# File 'lib/share_to_gplus/executable.rb', line 12

def initialize
  @options = {}
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/share_to_gplus/executable.rb', line 5

def options
  @options
end

Class Method Details

.invoke(args) ⇒ Object



7
8
9
10
# File 'lib/share_to_gplus/executable.rb', line 7

def self.invoke(args)
  executable = new
  executable.invoke if executable.parse_arguments(args)
end

Instance Method Details

#invokeObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/share_to_gplus/executable.rb', line 30

def invoke
  share_this = ShareToGplus::It.new do |config|
    config. = @options[:login]
    config.password = @options[:password]
    config.text = @options[:text]
    config.url = @options[:url]
    config.category = @options[:category]
    config.link = @options[:link]
    config.javascript_driver = @options[:javascript_driver] if @options[:javascript_driver]
  end
  share_this.execute
end

#parse_arguments(args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/share_to_gplus/executable.rb', line 16

def parse_arguments(args)
  OptionParser.new do |opts|
    opts.banner = 'Usage: sharetogplus [options]'

    on_service_arguments(opts)
    on_mandatory_arguments(opts)
    on_content_arguments(opts)
  end.parse!(args)

  raise 'No arguments specified!' if @options.empty?

  true
end