Module: YiffSpace::Images::Avatar
- Defined in:
- lib/yiffspace/images/avatar.rb,
lib/yiffspace/images/avatar/base.rb,
lib/yiffspace/images/avatar/discord.rb,
lib/yiffspace/images/avatar/gravatar.rb
Defined Under Namespace
Classes: Base, Discord, Gravatar
Class Method Summary
collapse
Class Method Details
.default_for(id) ⇒ Object
8
9
10
11
|
# File 'lib/yiffspace/images/avatar.rb', line 8
def default_for(id)
type = YiffSpace.config.images.default_avatar_type
get_for(id, type)
end
|
.find_type(type) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/yiffspace/images/avatar.rb', line 20
def find_type(type)
constants.map { |c| [c, const_get(c)] }.find do |_const, value|
next unless value < Base
value.try(:type)&.to_sym == type.to_sym
end&.second
end
|
.get_for(id, type) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/yiffspace/images/avatar.rb', line 13
def get_for(id, type)
klass = find_type(type)
raise(StandardError, "No avatar class for type: #{type}") if klass.nil?
klass.new(id)
end
|