Class: Response
- Inherits:
-
Object
- Object
- Response
- Defined in:
- lib/trail_marker/response.rb
Overview
Holds the TestRail response to easily access fields and give an easy user selector. TODO: Clean this UP!
Instance Method Summary collapse
- #get_id(key, value) ⇒ Object
- #get_value(key) ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #list_projects ⇒ Object
-
#picker(key) ⇒ Object
Returns ID of item selected via user key enter.
- #update(response) ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 |
# File 'lib/trail_marker/response.rb', line 10 def initialize(response) @response_type = response.class.name @json_data = "" @raw_data = response end |
Instance Method Details
#get_id(key, value) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/trail_marker/response.rb', line 35 def get_id(key, value) retval = nil case @response_type when "Array" retval = parse_array_kv(@raw_data, key, value, 'id') when "Hash" retval = @raw_data['id'] end return retval end |
#get_value(key) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trail_marker/response.rb', line 24 def get_value(key) retval = nil case @response_type when "Array" retval = parse_array(@raw_data, key) when "Hash" retval = parse_hash(@raw_data, key) end return retval end |
#list_projects ⇒ Object
20 21 22 |
# File 'lib/trail_marker/response.rb', line 20 def list_projects() end |
#picker(key) ⇒ Object
Returns ID of item selected via user key enter
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/trail_marker/response.rb', line 48 def picker(key) min_val = 1 max_val = 1 valarr = get_value(key) puts "Options Available: " valarr.each_with_index do |one_select, index| dis_index = index + 1 puts "#{dis_index}) #{one_select}" max_val = dis_index end puts "q) TO QUIT" print "Enter number of your selection: " user_choice = pick_filter(min_val, max_val, true) puts "You SELECTED #{valarr[user_choice - 1]}" puts "" return valarr[user_choice - 1] end |
#update(response) ⇒ Object
16 17 18 |
# File 'lib/trail_marker/response.rb', line 16 def update(response) initialize(response) end |