Class: Smartdict::Commands::TranslateCommand
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Smartdict::Commands::TranslateCommand
- Includes:
- HasFormatList
- Defined in:
- lib/smartdict/commands/translate_command.rb
Constant Summary
Constants inherited from AbstractCommand
Instance Method Summary collapse
Methods included from HasFormatList
Methods inherited from AbstractCommand
arguments, default, #extract_arguments_and_options, help_message, help_syntax_message, help_usage_message, inherited, #initialize, options, prog_name, run, #set_arguments!, #set_arguments_and_options!, set_description, set_name, #set_options!, set_summary, set_syntax, set_usage
Constructor Details
This class inherits a constructor from Smartdict::Commands::AbstractCommand
Instance Method Details
#execute ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/smartdict/commands/translate_command.rb', line 22 def execute translator_opts = { :from_lang => @options[:from], :to_lang => @options[:to], :log => true } translator_opts[:driver] = @options[:driver] if @options[:driver] translator = Smartdict::Translator.new(translator_opts) translation = translator.translate(@arguments[:word]) puts format.format_translation(translation) end |
#format ⇒ Object
35 36 37 38 39 |
# File 'lib/smartdict/commands/translate_command.rb', line 35 def format format = Smartdict::FormatManager.find(@options[:format]) raise Smartdict::Error.new("Wrong format: #{@options[:format]}") unless format format end |