Class: Jtest::Commands::Find

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/jtest/commands/find.rb

Instance Method Summary collapse

Instance Method Details

#get_problemsObject



13
14
15
16
# File 'lib/jtest/commands/find.rb', line 13

def get_problems
  say_status :working, "Trying to find problems that match: #{name}", :yellow
  @problems = Problem.find(name)
end

#show_problemsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jtest/commands/find.rb', line 18

def show_problems
  coder = HTMLEntities.new
  @problems.each do |problem|
    say_status problem[0], coder.decode(problem[1]), :blue
  end

  if @problems.empty?
    say_status :not_found, "0 matches found :(", :red
  else
    say_status :found,
      "#{@problems.size} match#{'es' if @problems.size != 1} found!",
      :green
  end
end