Class: RST::RstCommand
- Inherits:
-
Object
- Object
- RST::RstCommand
- Defined in:
- lib/rst.rb
Overview
Interprets and runs options and commands. See [EXAMPLES.md](../file.examples.html)
Constant Summary collapse
- DEFAULT_OPTIONS =
Default options are always present, even if the user will not provide them. They can be overwritten, though.
{ name: 'unnamed', from: 'today', to: 'today', show_empty: false }
PUBLIC INTERFACE collapse
-
#command ⇒ Object
readonly
the first argument of ARGV is the command.
-
#options ⇒ Object
readonly
the hash stores options parsed in mehtod parse_options.
PUBLIC INTERFACE collapse
-
#initialize(args) ⇒ RstCommand
constructor
Initialize the Command-runner with arguments and parse them.
-
#run ⇒ String
Call ‘run_options’ and ‘run_command’, reject empty returns and join output with CR.
Constructor Details
#initialize(args) ⇒ RstCommand
Initialize the Command-runner with arguments and parse them.
47 48 49 50 51 52 53 54 |
# File 'lib/rst.rb', line 47 def initialize(args) @options = {} load_defaults (args) _command = args.shift @command = _command if _command @files = args end |
Instance Attribute Details
#command ⇒ Object (readonly)
the first argument of ARGV is the command. It’s extracted in run_command
41 42 43 |
# File 'lib/rst.rb', line 41 def command @command end |
#options ⇒ Object (readonly)
the hash stores options parsed in mehtod parse_options.
37 38 39 |
# File 'lib/rst.rb', line 37 def @options end |
Instance Method Details
#run ⇒ String
Call ‘run_options’ and ‘run_command’, reject empty returns and join
output with CR
59 60 61 |
# File 'lib/rst.rb', line 59 def run [, run_command].compact.reject{|l| l.strip == '' }.join("\n") end |