class Coursemology::Polyglot::Language
Public Class Methods
find_by(type:)
click to toggle source
Finds the language class with the specified name.
@param [String] type The name of the class. @return [nil] If the type is not defined. @return [Class] If the type was found.
# File lib/coursemology/polyglot/extensions/language.rb, line 8 def self.find_by(type:) class_ = concrete_languages.find { |language| language.name == type } class_.new if class_ end
find_by!(type:)
click to toggle source
Finds the language class with the specified name.
@param [String] type The name of the class. @return [Class] If the type was found. @raise [ArgumentError] When the type was not found.
# File lib/coursemology/polyglot/extensions/language.rb, line 18 def self.find_by!(type:) language = find_by(type: type) fail ArgumentError, "Cannot find the language #{type}" unless language language end