概要
multiple_of?
詳細
multiple_of? について
multiple_of?
数値が引数の数値の倍数であるか判定する
サンプル
# encoding: utf-8 require 'active_support/core_ext/integer/multiple' require 'tbpgr_utils' bulk_puts_eval binding, <<-EOS 1.multiple_of? 1 2.multiple_of? 1 2.multiple_of? 2 3.multiple_of? 2 4.multiple_of? 2 EOS __END__ ・下記はTbpgrUtils gemの機能 bulk_puts_eval https://rubygems.org/gems/tbpgr_utils https://github.com/tbpgr/tbpgr_utils
出力
1.multiple_of? 1 # => true 2.multiple_of? 1 # => true 2.multiple_of? 2 # => true 3.multiple_of? 2 # => false 4.multiple_of? 2 # => true