lib/active_object/array.rb in active_object-3.0.0 vs lib/active_object/array.rb in active_object-3.1.0
- old
+ new
@@ -29,11 +29,11 @@
end
def delete_values(*args)
result = []
args.each { |v| result << delete(v) }
- return(result)
+ result
end
def dig(key, *rest)
if value = (self[key] rescue nil)
if rest.empty?
@@ -98,11 +98,11 @@
def percentile(percentage)
size = self.size
if size > 1
- index = size * percentage / 100.0
+ index = (size * percentage) / 100.0
self.sort[index]
else
self.first
end
end
@@ -129,11 +129,11 @@
end
def split(number=nil)
if block_given?
inject([[]]) do |results, element|
- yield(element) ? results << [] : results.last << element
+ yield(element) ? (results << []) : (results.last << element)
results
end
else
results, arr = [[]], dup
until arr.empty?
@@ -160,11 +160,9 @@
def to(position)
position >= 0 ? first(position + 1) : self[0..position]
end
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 "
}