Sha256: 504de2300c324293565bd15f3209fc1ea9f7d961cffb6f6771ea49d1e67a72c5
Contents?: true
Size: 786 Bytes
Versions: 3
Compression:
Stored size: 786 Bytes
Contents
# frozen_string_literal: true class Coursemology::Polyglot::Language # 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. def self.find_by(type:) class_ = concrete_languages.find { |language| language.name == type } class_.new if class_ end # 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. def self.find_by!(type:) language = find_by(type: type) fail ArgumentError, "Cannot find the language #{type}" unless language language end end
Version data entries
3 entries across 3 versions & 1 rubygems