Class: BOTR::PlayerView

Inherits:
Object
  • Object
show all
Defined in:
lib/botr/players/player_view.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Authentication

#signature

Methods included from API

#api_call_class, #api_format, #api_key, #api_nonce, #api_protocol, #api_secret_key, #api_server, #api_timestamp, #api_url, #api_version, #progress_url, #upload_address, #upload_key, #upload_protocol, #upload_token, #upload_url

Methods included from HTTP

#client, #delete_request, #get_request, #post_request, #put_request

Constructor Details

#initialize(params = {}) ⇒ PlayerView

Returns a new instance of PlayerView.


78
79
80
81
82
83
84
# File 'lib/botr/players/player_view.rb', line 78

def initialize(params = {})
	params.each do |key, val|
		param = "@#{key.to_s}"
		next unless methods.include? key.to_sym
		instance_variable_set(param, val)
	end		
end

Class Attribute Details

.last_statusObject (readonly)

Returns the value of attribute last_status


7
8
9
# File 'lib/botr/players/player_view.rb', line 7

def last_status
  @last_status
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def date
  @date
end

#keyObject (readonly)

Returns the value of attribute key


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def key
  @key
end

#last_statusObject (readonly)

Returns the value of attribute last_status


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def last_status
  @last_status
end

#monthsObject (readonly)

Returns the value of attribute months


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def months
  @months
end

#nameObject (readonly)

Returns the value of attribute name


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def number
  @number
end

#timestampObject (readonly)

Returns the value of attribute timestamp


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def timestamp
  @timestamp
end

#viewsObject (readonly)

Returns the value of attribute views


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def views
  @views
end

#yearsObject (readonly)

Returns the value of attribute years


75
76
77
# File 'lib/botr/players/player_view.rb', line 75

def years
  @years
end

Class Method Details

.allObject


38
39
40
# File 'lib/botr/players/player_view.rb', line 38

def all
	list({})
end

.list(**options) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/botr/players/player_view.rb', line 25

def list(**options)
	json = get_request(options.merge(:method => 'list'))
	res = JSON.parse(json.body)
	
	if json.status == 200
		results = process_list_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return results
end

.show(key, **options) ⇒ Object Also known as: find


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/botr/players/player_view.rb', line 9

def show(key, **options)
	json = get_request(options.merge(:method => 'show',
					    			 :player_key => key))
	res = JSON.parse(json.body)

	if json.status == 200
		params = process_show_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return new(params)
end