Module: YiffSpace::Images::Banner
- Defined in:
- lib/yiffspace/images/banner.rb,
lib/yiffspace/images/banner/base.rb,
lib/yiffspace/images/banner/discord.rb
Defined Under Namespace
Class Method Summary collapse
- .default_for(id) ⇒ Object
- .find_type(type) ⇒ Object
- .find_type!(type) ⇒ Object
- .get_for(id, type) ⇒ Object
Class Method Details
.default_for(id) ⇒ Object
8 9 10 11 |
# File 'lib/yiffspace/images/banner.rb', line 8 def default_for(id) type = YiffSpace.config.images. get_for(id, type) end |
.find_type(type) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/yiffspace/images/banner.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 |
.find_type!(type) ⇒ Object
28 29 30 |
# File 'lib/yiffspace/images/banner.rb', line 28 def find_type!(type) find_type(type) || raise(StandardError, "No banner class for type: #{type}") end |
.get_for(id, type) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/yiffspace/images/banner.rb', line 13 def get_for(id, type) klass = find_type(type) raise(StandardError, "No banner class for type: #{type}") if klass.nil? klass.new(id) end |