lib/csl/style/names.rb in csl-1.4.4 vs lib/csl/style/names.rb in csl-1.4.5
- old
+ new
@@ -86,35 +86,35 @@
# @param names [#to_i, Enumerable] the list of names (or its length)
# @return [Boolean] whether or not the list should be truncated
def truncate?(names, subsequent = false)
names = names.length if names.respond_to?(:length)
limit = truncate_when(subsequent)
+ count = truncate_at(subsequent)
- !limit.zero? && names.to_i >= limit
+ !count.nil? && !limit.nil? && names.to_i >= limit.to_i
end
# @param [Enumerable] names
# @return [Array] the truncated list of names
def truncate(names, subsequent = false)
- limit = truncate_at(subsequent)
-
- return [] if limit.zero?
- names.take limit
+ count = truncate_at(subsequent)
+ count = names.length if count.nil?
+ names.take count.to_i
end
def truncate_when(subsequent = false)
if subsequent && attribute?(:'et-al-subsequent-min')
- attributes[:'et-al-subsequent-min'].to_i
+ attributes[:'et-al-subsequent-min']
else
- attributes[:'et-al-min'].to_i
+ attributes[:'et-al-min']
end
end
def truncate_at(subsequent = false)
if subsequent && attribute?(:'et-al-subsequent-use-first')
- attributes.fetch(:'et-al-subsequent-use-first', 1).to_i
+ attributes.fetch(:'et-al-subsequent-use-first')
else
- attributes.fetch(:'et-al-use-first', 1).to_i
+ attributes.fetch(:'et-al-use-first')
end
end
def truncate_at!(at)
attributes[:'et-al-use-first'] = at.to_i