Class: Pericope::CLI
- Inherits:
-
Object
- Object
- Pericope::CLI
- Defined in:
- lib/pericope/cli.rb
Constant Summary collapse
- ALLOWED_COMMANDS =
%w{help normalize parse usage}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.run(command, *args) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/pericope/cli.rb', line 9 def self.run(command, *args) if ALLOWED_COMMANDS.member?(command) command = command.gsub(/-/, '_').to_sym CLI.new(*args).send(command) else CLI.new(*args).usage end end |
Instance Method Details
#help ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pericope/cli.rb', line 20 def help print <<-HELP Glossary pericope A Bible reference (e.g. Romans 3:6-11) verse ID An integer that uniquely identifies a Bible verse HELP end |
#normalize ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/pericope/cli.rb', line 33 def normalize begin pericope = Pericope.new(input) print pericope.to_s rescue print $!.to_s end end |
#parse ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/pericope/cli.rb', line 44 def parse begin pericope = Pericope.new(input) print pericope.to_a.join("\n") rescue print $!.to_s end end |
#usage ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pericope/cli.rb', line 55 def usage print <<-USAGE Usage pericope [Command] [Input] Commands help Prints more information about pericope normalize Accepts a pericope and returns a properly-formatted pericope parse Accepts a pericope and returns a list of verse IDs usage Prints this message USAGE end |