Module: UniverseCompiler::Utils::ArrayUtils
- Defined in:
- lib/universe_compiler/utils/array_utils.rb
Instance Method Summary collapse
- #contains_all_of?(*choices) ⇒ Boolean
- #contains_at_least_one_of?(*choices) ⇒ Boolean
- #contains_only_one_of?(*choices) ⇒ Boolean
- #raises_or_logs(msg, raise_exception = false, logger_level = :error) ⇒ Object
Instance Method Details
#contains_all_of?(*choices) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/universe_compiler/utils/array_utils.rb', line 19 def contains_all_of?(*choices) used = used_choices *choices return true, used if used.size == choices.size return false, used end |
#contains_at_least_one_of?(*choices) ⇒ Boolean
13 14 15 16 17 |
# File 'lib/universe_compiler/utils/array_utils.rb', line 13 def contains_at_least_one_of?(*choices) used = used_choices *choices return true, used unless used.empty? return false, used end |
#contains_only_one_of?(*choices) ⇒ Boolean
7 8 9 10 11 |
# File 'lib/universe_compiler/utils/array_utils.rb', line 7 def contains_only_one_of?(*choices) used = used_choices *choices return true, used if used.size == 1 return false, used end |
#raises_or_logs(msg, raise_exception = false, logger_level = :error) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/universe_compiler/utils/array_utils.rb', line 25 def raises_or_logs(msg, raise_exception=false, logger_level=:error) if raise_exception then raise UniverseCompiler::Error, msg else UniverseCompiler.logger.send logger_level, msg return false end end |