Class: Qiita::Arguments
- Inherits:
-
Object
- Object
- Qiita::Arguments
- Defined in:
- lib/qiita/arguments.rb
Instance Method Summary collapse
- #access_token ⇒ Object
- #arguments ⇒ Object
- #color ⇒ Object
- #error_message ⇒ Object
- #headers ⇒ Object
- #host ⇒ Object
-
#initialize(argv) ⇒ Arguments
constructor
A new instance of Arguments.
- #method_name ⇒ Object
- #params ⇒ Object
- #show_body ⇒ Object
- #show_header ⇒ Object
- #ssl ⇒ Object
- #team ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(argv) ⇒ Arguments
Returns a new instance of Arguments.
3 4 5 |
# File 'lib/qiita/arguments.rb', line 3 def initialize(argv) @argv = argv end |
Instance Method Details
#access_token ⇒ Object
7 8 9 |
# File 'lib/qiita/arguments.rb', line 7 def access_token ["access-token"] || ENV["QIITA_ACCESS_TOKEN"] end |
#arguments ⇒ Object
11 12 13 |
# File 'lib/qiita/arguments.rb', line 11 def arguments parsed_argv_data[:arguments] end |
#color ⇒ Object
15 16 17 |
# File 'lib/qiita/arguments.rb', line 15 def color ["color"] end |
#error_message ⇒ Object
19 20 21 |
# File 'lib/qiita/arguments.rb', line 19 def .to_s end |
#headers ⇒ Object
23 24 25 |
# File 'lib/qiita/arguments.rb', line 23 def headers parsed_argv_data[:headers] end |
#host ⇒ Object
27 28 29 |
# File 'lib/qiita/arguments.rb', line 27 def host ["host"] end |
#method_name ⇒ Object
35 36 37 |
# File 'lib/qiita/arguments.rb', line 35 def method_name @argv[0] end |
#params ⇒ Object
39 40 41 |
# File 'lib/qiita/arguments.rb', line 39 def params params_from_stdin.merge(parsed_argv_data[:params]) end |
#show_body ⇒ Object
43 44 45 |
# File 'lib/qiita/arguments.rb', line 43 def show_body !["no-body"] end |
#show_header ⇒ Object
47 48 49 |
# File 'lib/qiita/arguments.rb', line 47 def show_header ["header"] end |
#ssl ⇒ Object
31 32 33 |
# File 'lib/qiita/arguments.rb', line 31 def ssl !["no-ssl-verification"] end |
#team ⇒ Object
51 52 53 |
# File 'lib/qiita/arguments.rb', line 51 def team ["team"] end |
#valid? ⇒ Boolean
55 56 57 |
# File 'lib/qiita/arguments.rb', line 55 def valid? && has_valid_method_name? && has_valid_arguments? && !has_invalid_json_input? end |