Class: Smogon::Type::Base
- Inherits:
-
Object
- Object
- Smogon::Type::Base
show all
- Defined in:
- lib/smogon/types/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(response) ⇒ Base
Returns a new instance of Base.
23
24
25
26
27
|
# File 'lib/smogon/types/base.rb', line 23
def initialize(response)
attributes.each do |attr|
public_send("#{attr}=", response[attr])
end
end
|
Instance Method Details
#to_h ⇒ Object
29
30
31
32
33
|
# File 'lib/smogon/types/base.rb', line 29
def to_h
attributes.zip(
attributes.map { |attr| public_send(attr) }
).to_h
end
|
#to_s ⇒ Object
35
36
37
38
39
|
# File 'lib/smogon/types/base.rb', line 35
def to_s
attributes.map do |attr|
"#{attr.capitalize}: #{public_send(attr)}"
end.join("\n")
end
|
#url ⇒ Object
41
42
43
|
# File 'lib/smogon/types/base.rb', line 41
def url
"http://www.smogon.com/dex/#{::Smogon::API::METAGAME}/#{self.class::TYPE}/#{name}"
end
|