Class: Lingvo::Console::Command

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

Class Method Summary collapse

Class Method Details

.file_not_foundObject



100
101
102
# File 'lib/lingvo/console/command.rb', line 100

def file_not_found
  puts "\nFile not found!"
end

.guiObject



88
89
90
# File 'lib/lingvo/console/command.rb', line 88

def gui
  GUI::Simple.run
end

.helpObject



92
93
94
# File 'lib/lingvo/console/command.rb', line 92

def help
  puts HELP
end

.notifyObject



84
85
86
# File 'lib/lingvo/console/command.rb', line 84

def notify
  GUI::Notify.run
end

.parse(path) ⇒ Object



62
63
64
65
66
# File 'lib/lingvo/console/command.rb', line 62

def parse(path)
  return file_not_found unless File.exists? path
  Parsers::Lingualeo.new(path) { |word| Models::English.create word }
  size
end

.rand(count) ⇒ Object



73
74
75
76
77
78
# File 'lib/lingvo/console/command.rb', line 73

def rand(count)
  return words_not_found unless Models::English.any?
  Models::English.rand((count || 1).to_i).each do |word|
    printf "%-20s  %-20s  %s\n", word.eng, word.transcr, word.ru
  end
end

.sizeObject



80
81
82
# File 'lib/lingvo/console/command.rb', line 80

def size
  puts "\nYou have #{Models::English.count} words"
end

.versionObject



96
97
98
# File 'lib/lingvo/console/command.rb', line 96

def version
  puts "\n#{VERSION}"
end

.words_counter(from, to) ⇒ Object



68
69
70
71
# File 'lib/lingvo/console/command.rb', line 68

def words_counter(from, to)
  return file_not_found unless File.exists? from
  Parsers::WordsCounter.new from, to
end

.words_not_foundObject



104
105
106
# File 'lib/lingvo/console/command.rb', line 104

def words_not_found
  puts "\nYou don't have any words"
end