class TxTranslate::CLI

Public Class Methods

source_root() click to toggle source
# File lib/tx_translate/cli.rb, line 9
def self.source_root
  File.expand_path('../..', __dir__)
end

Public Instance Methods

config() click to toggle source
# 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) click to toggle source
# File lib/tx_translate/cli.rb, line 46
def md(filename)
  TxTranslate::MdProcess.run(filename)
end
sbv(filename) click to toggle source
# File lib/tx_translate/cli.rb, line 36
def sbv(filename)
  TxTranslate::SbvProcess.run(filename)
end
srt(filename) click to toggle source
# File lib/tx_translate/cli.rb, line 41
def srt(filename)
  TxTranslate::SrtProcess.run(filename)
end
word(word, _number = 10) click to toggle source
# 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

Private Instance Methods

display_name(name) click to toggle source
# File lib/tx_translate/cli.rb, line 52
def display_name(name)
  puts name
end