Class: Qiita::Arguments

Inherits:
Object
  • Object
show all
Defined in:
lib/qiita/arguments.rb

Instance Method Summary collapse

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_tokenObject



7
8
9
# File 'lib/qiita/arguments.rb', line 7

def access_token
  slop_options["access-token"] || ENV["QIITA_ACCESS_TOKEN"]
end

#argumentsObject



11
12
13
# File 'lib/qiita/arguments.rb', line 11

def arguments
  parsed_argv_data[:arguments]
end

#colorObject



15
16
17
# File 'lib/qiita/arguments.rb', line 15

def color
  slop_options["color"]
end

#error_messageObject



19
20
21
# File 'lib/qiita/arguments.rb', line 19

def error_message
  slop_options.to_s
end

#headersObject



23
24
25
# File 'lib/qiita/arguments.rb', line 23

def headers
  parsed_argv_data[:headers]
end

#hostObject



27
28
29
# File 'lib/qiita/arguments.rb', line 27

def host
  slop_options["host"]
end

#method_nameObject



35
36
37
# File 'lib/qiita/arguments.rb', line 35

def method_name
  @argv[0]
end

#paramsObject



39
40
41
# File 'lib/qiita/arguments.rb', line 39

def params
  params_from_stdin.merge(parsed_argv_data[:params])
end

#show_bodyObject



43
44
45
# File 'lib/qiita/arguments.rb', line 43

def show_body
  !slop_options["no-body"]
end

#show_headerObject



47
48
49
# File 'lib/qiita/arguments.rb', line 47

def show_header
  slop_options["header"]
end

#sslObject



31
32
33
# File 'lib/qiita/arguments.rb', line 31

def ssl
  !slop_options["no-ssl-verification"]
end

#teamObject



51
52
53
# File 'lib/qiita/arguments.rb', line 51

def team
  slop_options["team"]
end

#valid?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/qiita/arguments.rb', line 55

def valid?
  has_valid_slop_options? && has_valid_method_name? && has_valid_arguments? && !has_invalid_json_input?
end