Class: LetItFall::CLI

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

Instance Method Summary collapse

Instance Method Details

#code(*code) ⇒ Object



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

def code(*code)
  if options[:range]
    st, ed = code.minmax
    code = Range.new(st.to_i(16), ed.to_i(16))
                .to_a.map { |i| i.to_s(16) }
  end
  run(code, options[:speed], options[:color], options[:matrix])
end

#goObject



35
36
37
38
# File 'lib/let_it_fall/cli.rb', line 35

def go
  code = LetItFall::CODESET.keys.sample
  run(code, options[:speed], options[:color], false, options[:interval])
end

#listObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/let_it_fall/cli.rb', line 56

def list
  puts "Commands:"
  puts "  let_it_fall MARK             # Let any of following MARKs fall"
  LetItFall::CODESET.keys.sort.each_with_index do |mark, i|
    print "\n    " if i%8==0
    print mark, " "
  end
  puts "\n\n"
  puts "  let_it_fall matrix [MARK]   # Let it matrix!"
  puts "  let_it_fall rand            # Let something fall randomly"
  puts "  let_it_fall go              # Let them Go!"
  puts "  let_it_fall code CODE       # Let specific character fall by unicode(s) ex. code 0x2660"
  puts "  let_it_fall help [COMMAND]  # Describe available commands or one specific command"
  puts "  let_it_fall version         # Show LetItFall version"
end

#matrix(mark = :latins) ⇒ Object



27
28
29
# File 'lib/let_it_fall/cli.rb', line 27

def matrix(mark=:latins)
  run(mark, options[:speed], options[:color], true)
end

#randObject



19
20
21
22
# File 'lib/let_it_fall/cli.rb', line 19

def rand
  code = LetItFall::CODESET.keys.sample
  run(code, options[:speed], options[:color], false)
end

#versionObject



76
77
78
# File 'lib/let_it_fall/cli.rb', line 76

def version
  puts "LetItFall #{LetItFall::VERSION} (c) 2014 kyoendo"
end