Class: TxTranslate::CLI
- Inherits:
-
Thor
- Object
- Thor
- TxTranslate::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/tx_translate/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #md(filename) ⇒ Object
- #sbv(filename) ⇒ Object
- #srt(filename) ⇒ Object
- #word(word, _number = 10) ⇒ Object
Class Method Details
.source_root ⇒ Object
9 10 11 |
# File 'lib/tx_translate/cli.rb', line 9 def self.source_root File.('../..', __dir__) end |
Instance Method Details
#config ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/tx_translate/cli.rb', line 14 def config # 初回起動時に設定ファイルを作成 config_path = Dir.home + '/.tx_translate' if Dir.exist?(config_path) puts "Your current name is [#{TxTranslate.config[:name]}]." else template 'templates/settings.yml.tt', "#{config_path}/settings.yml" end end |
#md(filename) ⇒ Object
46 47 48 |
# File 'lib/tx_translate/cli.rb', line 46 def md(filename) TxTranslate::MdProcess.run(filename) end |
#sbv(filename) ⇒ Object
36 37 38 |
# File 'lib/tx_translate/cli.rb', line 36 def sbv(filename) TxTranslate::SbvProcess.run(filename) end |
#srt(filename) ⇒ Object
41 42 43 |
# File 'lib/tx_translate/cli.rb', line 41 def srt(filename) TxTranslate::SrtProcess.run(filename) end |
#word(word, _number = 10) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/tx_translate/cli.rb', line 25 def word(word, _number = 10) if ARGV.length < 2 puts TxTranslate::TencentFy.new(word).result else ARGV.delete_at(0) str = ARGV.join(' ') puts TxTranslate::TencentFy.new(str).result end end |