lib/active_object/array.rb in active_object-2.2.5 vs lib/active_object/array.rb in active_object-2.3.0
- old
+ new
@@ -47,10 +47,11 @@
end
end
def groups(number)
return([]) if number <= 0
+
n, r = size.divmod(number)
collection = (0..(n - 1)).collect { |i| self[(i * number), number] }
r > 0 ? collection << self[-r, r] : collection
end
@@ -152,12 +153,12 @@
unless defined?(Rails)
def to_sentence(options={})
options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector)
default_connectors = {
- words_connector: ', ',
- two_words_connector: ' and ',
- last_word_connector: ', and '
+ words_connector: ', '.freeze,
+ two_words_connector: ' and '.freeze,
+ last_word_connector: ', and '.freeze
}
options = default_connectors.merge!(options)
case size
when 0
\ No newline at end of file