class CSL::Style::Name
Attributes
Public Class Methods
# File lib/csl/style/names.rb, line 57 def initialize(attributes = {}) super(attributes) children[:'name-part'] = [] yield self if block_given? end
Public Instance Methods
# File lib/csl/style/names.rb, line 178 def all_names_as_sort_order! attributes[:'name-as-sort-order'] = 'all' self end
# File lib/csl/style/names.rb, line 169 def all_names_as_sort_order? !!(attributes[:'name-as-sort-order'].to_s =~ /^all$/i) end
# File lib/csl/style/names.rb, line 336 def connector c = attributes[:and] c == 'symbol' ? '&' : c end
# File lib/csl/style/names.rb, line 341 def connector=(c) attributes[:and] = c end
# File lib/csl/style/names.rb, line 64 def count? attribute?(:form) && attributes[:form] == 'count' end
@return [String] the delimiter between names
# File lib/csl/style/names.rb, line 146 def delimiter attributes[:delimiter] || ', ' end
Set the :'delimiter-precedes-et-al' attribute to 'always'. @return [self] self
# File lib/csl/style/names.rb, line 206 def delimiter_always_precedes_et_al! attributes[:'delimiter-precedes-et-al'] = 'always' self end
@return [Boolean] whether or not the delimmiter should
always be inserted before et-al
# File lib/csl/style/names.rb, line 200 def delimiter_always_precedes_et_al? !!(attributes[:'delimiter-precedes-et-al'].to_s =~ /^always$/i) end
Set the :'delimiter-precedes-last' attribute to 'always'. @return [self] self
# File lib/csl/style/names.rb, line 284 def delimiter_always_precedes_last! attributes[:'delimiter-precedes-last'] = 'always' self end
@return [Boolean] whether or not the should always be inserted between
the penultimate and the last name
# File lib/csl/style/names.rb, line 278 def delimiter_always_precedes_last? !!(attributes[:'delimiter-precedes-last'].to_s =~ /^always$/i) end
Set the :'delimiter-precedes-et-al' attribute to 'contextual' @return [self] self
# File lib/csl/style/names.rb, line 237 def delimiter_contextually_precedes_et_al! attributes[:'delimiter-precedes-et-al'] = 'contextual' self end
@return [Boolean] whether or not the delimtier should
be inserted between before et-al depending on the number of names rendered
# File lib/csl/style/names.rb, line 230 def delimiter_contextually_precedes_et_al? return true unless attribute?[:'delimiter-precedes-et-al'] !!(attributes[:'delimiter-precedes-et-al'].to_s =~ /^contextual/i) end
Set the :'delimiter-precedes-last' attribute to 'contextual' @return [self] self
# File lib/csl/style/names.rb, line 314 def delimiter_contextually_precedes_last! attributes[:'delimiter-precedes-last'] = 'contextual' self end
@return [Boolean] whether or not the should be inserted between the
penultimate and the last name depending on the number of names
# File lib/csl/style/names.rb, line 307 def delimiter_contextually_precedes_last? return true unless attribute?(:'delimiter-precedes-last') !!(attributes[:'delimiter-precedes-last'].to_s =~ /^contextual/i) end
Set the :'delimiter-precedes-et-al' attribute to 'never' @return [self] self
# File lib/csl/style/names.rb, line 222 def delimiter_never_precedes_et_al! attributes[:'delimiter-precedes-et-al'] = 'never' self end
@return [Boolean] whether or not the delimiter should
never be inserted before et-al
# File lib/csl/style/names.rb, line 216 def delimiter_never_precedes_et_al? !!(attributes[:'delimiter-precedes-et-al'].to_s =~ /^never$/i) end
Set the :'delimiter-precedes-last' attribute to 'never' @return [self] self
# File lib/csl/style/names.rb, line 300 def delimiter_never_precedes_last! attributes[:'delimiter-precedes-last'] = 'never' self end
@return [Boolean] whether or not the should never be inserted between
the penultimate and the last name
# File lib/csl/style/names.rb, line 294 def delimiter_never_precedes_last? !!(attributes[:'delimiter-precedes-last'].to_s =~ /^never$/i) end
# File lib/csl/style/names.rb, line 183 def delimiter_precedes_et_al?(names) names = names.length if names.respond_to?(:length) case when delimiter_never_precedes_et_al? false when delimiter_always_precedes_et_al? true when delimiter_precedes_et_al_after_inverted_name? name_as_sort_order_at?(names.to_i) else names.to_i > 1 end end
# File lib/csl/style/names.rb, line 246 def delimiter_precedes_et_al_after_inverted_name! attributes[:'delimiter-precedes-et-al'] = 'after-inverted-name' self end
# File lib/csl/style/names.rb, line 242 def delimiter_precedes_et_al_after_inverted_name? !!(attributes[:'delimiter-precedes-et-al'].to_s =~ /^after-inverted-name/i) end
@param names [#to_i, Enumerable] the list of names (or its length) @return [Boolean] whether or not the delimiter will be inserted between
the penultimate and the last name
# File lib/csl/style/names.rb, line 254 def delimiter_precedes_last?(names) names = names.length if names.respond_to?(:length) case when !attribute?(:and) true when delimiter_never_precedes_last? false when delimiter_always_precedes_last? true when delimiter_precedes_last_after_inverted_name? if name_as_sort_order? all_names_as_sort_order? || names.to_i == 2 else false end else names.to_i > 2 end end
# File lib/csl/style/names.rb, line 323 def delimiter_precedes_last_after_inverted_name! attributes[:'delimiter-precedes-last'] = 'after-inverted-name' self end
# File lib/csl/style/names.rb, line 319 def delimiter_precedes_last_after_inverted_name? !!(attributes[:'delimiter-precedes-last'].to_s =~ /^after-inverted-name/i) end
# File lib/csl/style/names.rb, line 332 def ellipsis "#{delimiter}… " end
# File lib/csl/style/names.rb, line 328 def ellipsis? attributes[:'et-al-use-last'].to_s =~ /^true$/ end
# File lib/csl/style/names.rb, line 77 def et_al @et_al || parent && parent.et_al end
# File lib/csl/style/names.rb, line 81 def et_al=(et_al) @et_al = et_al end
# File lib/csl/style/names.rb, line 173 def first_name_as_sort_order! attributes[:'name-as-sort-order'] = 'first' self end
# File lib/csl/style/names.rb, line 165 def first_name_as_sort_order? !!(attributes[:'name-as-sort-order'].to_s =~ /^first$/i) end
# File lib/csl/style/names.rb, line 72 def initialize_without_hyphen? !root? && root.respond_to?(:initialize_without_hyphen?) && root.initialize_without_hyphen? end
# File lib/csl/style/names.rb, line 159 def name_as_sort_order attributes[:'name-as-sort-order'].to_s end
# File lib/csl/style/names.rb, line 150 def name_as_sort_order? attribute?(:'name-as-sort-order') end
# File lib/csl/style/names.rb, line 154 def name_as_sort_order_at?(position) return false unless name_as_sort_order? all_names_as_sort_order? || position == 1 && first_name_as_sort_order? end
# File lib/csl/style/names.rb, line 68 def name_options attributes_for :form, :initialize, :'initialize-with', :'sort-separator' end
@return [String] the delimiter between family and given names
in sort order
# File lib/csl/style/names.rb, line 141 def sort_separator attributes[:'sort-separator'] || ', ' end
@param [Enumerable] names @return [Array] the truncated list of names
# File lib/csl/style/names.rb, line 97 def truncate(names, subsequent = false) count = truncate_at(subsequent) count = names.length if count.nil? names.take count.to_i end
@param names [#to_i, Enumerable] the list of names (or its length) @return [Boolean] whether or not the list should be truncated
# File lib/csl/style/names.rb, line 87 def truncate?(names, subsequent = false) names = names.length if names.respond_to?(:length) limit = truncate_when(subsequent) count = truncate_at(subsequent) !count.nil? && !limit.nil? && names.to_i >= limit.to_i end
# File lib/csl/style/names.rb, line 111 def truncate_at(subsequent = false) if subsequent && attribute?(:'et-al-subsequent-use-first') attributes.fetch(:'et-al-subsequent-use-first') else attributes.fetch(:'et-al-use-first') end end
# File lib/csl/style/names.rb, line 119 def truncate_at!(at) attributes[:'et-al-use-first'] = at.to_i self end
# File lib/csl/style/names.rb, line 129 def truncate_subsequent_at!(at) attributes[:'et-al-subsequent-use-first'] = at.to_i self end
# File lib/csl/style/names.rb, line 134 def truncate_subsequent_when!(pos) attributes[:'et-al-subsequent-min'] = pos.to_i self end
# File lib/csl/style/names.rb, line 103 def truncate_when(subsequent = false) if subsequent && attribute?(:'et-al-subsequent-min') attributes[:'et-al-subsequent-min'] else attributes[:'et-al-min'] end end
# File lib/csl/style/names.rb, line 124 def truncate_when!(pos) attributes[:'et-al-min'] = pos.to_i self end