Class: Gista::Options
- Inherits:
-
Object
- Object
- Gista::Options
- Defined in:
- lib/gista/options.rb
Overview
Parse options given on the command line into an options hash suitable for a
GistRequest
object.
This provides the default options:
- Gists are private by default
- When reading from
STDIN
, the file is titled 'untitled'
When any options are left after parsing all the flags, they are treated as
filenames. They will be added to the options as files in the Gist. When no
arguments are left, input is read from STDIN
and its contents will be
added to the options hash as a single file.
This also provides the --help
and --version
options for the
command-line client.
Instance Attribute Summary collapse
-
#args ⇒ Array
readonly
Command line options, flags and filenames.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #options ⇒ Hash
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
25 26 27 28 29 |
# File 'lib/gista/options.rb', line 25 def initialize(args) @args = args @options = { public: false } @stdin_filename = 'untitled' end |
Instance Attribute Details
#args ⇒ Array (readonly)
Command line options, flags and filenames
23 24 25 |
# File 'lib/gista/options.rb', line 23 def args @args end |
Instance Method Details
#options ⇒ Hash
32 33 34 35 36 |
# File 'lib/gista/options.rb', line 32 def parse_files @options end |