Class: CSstats::Players
- Inherits:
-
Object
show all
- Defined in:
- lib/csstats/players.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client) ⇒ Players
Returns a new instance of Players.
7
8
9
|
# File 'lib/csstats/players.rb', line 7
def initialize(client)
@client = client
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
39
40
41
42
43
|
# File 'lib/csstats/players.rb', line 39
def method_missing(method_name, *args, &block)
return super unless respond_to?(method_name)
players.send(method_name, *args, &block)
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5
6
7
|
# File 'lib/csstats/players.rb', line 5
def client
@client
end
|
Instance Method Details
#all ⇒ Object
11
12
13
|
# File 'lib/csstats/players.rb', line 11
def all
players
end
|
#find(id) ⇒ Object
15
16
17
|
# File 'lib/csstats/players.rb', line 15
def find(id)
players[id - 1]
end
|
#find_by(attributes = {}) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/csstats/players.rb', line 19
def find_by(attributes = {})
players.find do |player|
attributes.all? do |column, value|
player.send(column) == value
end
end
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
45
46
47
|
# File 'lib/csstats/players.rb', line 45
def respond_to_missing?(method_name, include_private = false)
players.respond_to?(method_name, include_private)
end
|
#where(attributes = {}) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/csstats/players.rb', line 27
def where(attributes = {})
players.select do |player|
attributes.all? do |column, value|
player.send(column) == value
end
end
end
|