Class: Tika::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/tika/command.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, *args) ⇒ Command

Returns a new instance of Command.



16
17
18
19
20
# File 'lib/tika/command.rb', line 16

def initialize(app, *args)
  @app = app
  @file = args.shift
  @options = args.pop || {}
end

Class Attribute Details

.optionsObject

Returns the value of attribute options.



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

def options
  @options
end

.result_classObject

Returns the value of attribute result_class.



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

def result_class
  @result_class
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



14
15
16
# File 'lib/tika/command.rb', line 14

def app
  @app
end

#fileObject (readonly)

Returns the value of attribute file.



14
15
16
# File 'lib/tika/command.rb', line 14

def file
  @file
end

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/tika/command.rb', line 14

def options
  @options
end

Class Method Details

.execute(app, *args) ⇒ Object



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

def execute(app, *args)
  new(app, *args).execute
end

Instance Method Details

#command_lineObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/tika/command.rb', line 26

def command_line
  cmd = app.command_line + self.class.options
  if options[:password]
    cmd << "-p#{options[:password]}"
  end
  if file
    cmd << file
  end
  cmd
end

#executeObject



37
38
39
40
# File 'lib/tika/command.rb', line 37

def execute
  raw_result = Open3.capture3(*command_line)
  result_class.new(*raw_result)
end

#result_classObject



22
23
24
# File 'lib/tika/command.rb', line 22

def result_class
  self.class.result_class
end