Class: SearchYJ::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/searchyj/cli.rb

Instance Method Summary collapse

Instance Method Details

#detect(term) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/searchyj/cli.rb', line 30

def detect(term)
  opt    = symbolized_options
  key    = opt.delete(:key)
  regexp = Regexp.new(opt.delete(:regexp))

  puts JSON.dump(
      SearchYJ.detect(term, regexp, key, opt)
  )
end

#list(term) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/searchyj/cli.rb', line 47

def list(term)
  opt  = symbolized_options
  size = opt.delete(:size)

  puts JSON.dump(
      SearchYJ.list(term, size, opt)
  )
end

#rank(term) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/searchyj/cli.rb', line 64

def rank(term)
  opt  = symbolized_options
  rank = opt.delete(:rank)

  puts JSON.dump(
      SearchYJ.rank(term, rank, opt)
  )
end