class CSL::Style::Name
Attributes
Public Class Methods
Source
# File lib/csl/style/names.rb, line 58 def initialize(attributes = {}) super(attributes) children[:'name-part'] = [] yield self if block_given? end
CSL::Node::new
Public Instance Methods
Source
# File lib/csl/style/names.rb, line 179 def all_names_as_sort_order! attributes[:'name-as-sort-order'] = 'all' self end
Source
# File lib/csl/style/names.rb, line 170 def all_names_as_sort_order? !!(attributes[:'name-as-sort-order'].to_s =~ /^all$/i) end
Source
# File lib/csl/style/names.rb, line 337 def connector c = attributes[:and] c == 'symbol' ? '&' : c end
Source
# File lib/csl/style/names.rb, line 342 def connector=(c) attributes[:and] = c end
Source
# File lib/csl/style/names.rb, line 65 def count? attribute?(:form) && attributes[:form] == 'count' end
Source
# File lib/csl/style/names.rb, line 147 def delimiter attributes[:delimiter] || ', ' end
@return [String] the delimiter between names
Source
# File lib/csl/style/names.rb, line 207 def delimiter_always_precedes_et_al! attributes[:'delimiter-precedes-et-al'] = 'always' self end
Set the :‘delimiter-precedes-et-al’ attribute to ‘always’. @return [self] self
Source
# File lib/csl/style/names.rb, line 201 def delimiter_always_precedes_et_al? !!(attributes[:'delimiter-precedes-et-al'].to_s =~ /^always$/i) end
@return [Boolean] whether or not the delimmiter should
always be inserted before et-al
Source
# File lib/csl/style/names.rb, line 285 def delimiter_always_precedes_last! attributes[:'delimiter-precedes-last'] = 'always' self end
Set the :‘delimiter-precedes-last’ attribute to ‘always’. @return [self] self
Source
# File lib/csl/style/names.rb, line 279 def delimiter_always_precedes_last? !!(attributes[:'delimiter-precedes-last'].to_s =~ /^always$/i) end
@return [Boolean] whether or not the should always be inserted between
the penultimate and the last name
Source
# File lib/csl/style/names.rb, line 238 def delimiter_contextually_precedes_et_al! attributes[:'delimiter-precedes-et-al'] = 'contextual' self end
Set the :‘delimiter-precedes-et-al’ attribute to ‘contextual’ @return [self] self
Source
# File lib/csl/style/names.rb, line 231 def delimiter_contextually_precedes_et_al? return true unless attribute?[:'delimiter-precedes-et-al'] !!(attributes[:'delimiter-precedes-et-al'].to_s =~ /^contextual/i) end
@return [Boolean] whether or not the delimtier should
be inserted between before et-al depending on the number of names rendered
Source
# File lib/csl/style/names.rb, line 315 def delimiter_contextually_precedes_last! attributes[:'delimiter-precedes-last'] = 'contextual' self end
Set the :‘delimiter-precedes-last’ attribute to ‘contextual’ @return [self] self
Source
# File lib/csl/style/names.rb, line 308 def delimiter_contextually_precedes_last? return true unless attribute?(:'delimiter-precedes-last') !!(attributes[:'delimiter-precedes-last'].to_s =~ /^contextual/i) end
@return [Boolean] whether or not the should be inserted between the
penultimate and the last name depending on the number of names
Source
# File lib/csl/style/names.rb, line 223 def delimiter_never_precedes_et_al! attributes[:'delimiter-precedes-et-al'] = 'never' self end
Set the :‘delimiter-precedes-et-al’ attribute to ‘never’ @return [self] self
Source
# File lib/csl/style/names.rb, line 217 def delimiter_never_precedes_et_al? !!(attributes[:'delimiter-precedes-et-al'].to_s =~ /^never$/i) end
@return [Boolean] whether or not the delimiter should
never be inserted before et-al
Source
# File lib/csl/style/names.rb, line 301 def delimiter_never_precedes_last! attributes[:'delimiter-precedes-last'] = 'never' self end
Set the :‘delimiter-precedes-last’ attribute to ‘never’ @return [self] self
Source
# File lib/csl/style/names.rb, line 295 def delimiter_never_precedes_last? !!(attributes[:'delimiter-precedes-last'].to_s =~ /^never$/i) end
@return [Boolean] whether or not the should never be inserted between
the penultimate and the last name
Source
# File lib/csl/style/names.rb, line 184 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
Source
# File lib/csl/style/names.rb, line 247 def delimiter_precedes_et_al_after_inverted_name! attributes[:'delimiter-precedes-et-al'] = 'after-inverted-name' self end
Source
# File lib/csl/style/names.rb, line 243 def delimiter_precedes_et_al_after_inverted_name? !!(attributes[:'delimiter-precedes-et-al'].to_s =~ /^after-inverted-name/i) end
Source
# File lib/csl/style/names.rb, line 255 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
@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
Source
# File lib/csl/style/names.rb, line 324 def delimiter_precedes_last_after_inverted_name! attributes[:'delimiter-precedes-last'] = 'after-inverted-name' self end
Source
# File lib/csl/style/names.rb, line 320 def delimiter_precedes_last_after_inverted_name? !!(attributes[:'delimiter-precedes-last'].to_s =~ /^after-inverted-name/i) end
Source
# File lib/csl/style/names.rb, line 329 def ellipsis? attributes[:'et-al-use-last'].to_s =~ /^true$/ end
Source
# File lib/csl/style/names.rb, line 78 def et_al @et_al || parent && parent.et_al end
Source
# File lib/csl/style/names.rb, line 174 def first_name_as_sort_order! attributes[:'name-as-sort-order'] = 'first' self end
Source
# File lib/csl/style/names.rb, line 166 def first_name_as_sort_order? !!(attributes[:'name-as-sort-order'].to_s =~ /^first$/i) end
Source
# File lib/csl/style/names.rb, line 73 def initialize_without_hyphen? !root? && root.respond_to?(:initialize_without_hyphen?) && root.initialize_without_hyphen? end
Source
# File lib/csl/style/names.rb, line 160 def name_as_sort_order attributes[:'name-as-sort-order'].to_s end
Source
# File lib/csl/style/names.rb, line 151 def name_as_sort_order? attribute?(:'name-as-sort-order') end
Source
# File lib/csl/style/names.rb, line 155 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
Source
# File lib/csl/style/names.rb, line 69 def name_options attributes_for :form, :initialize, :'initialize-with', :'sort-separator' end
Source
# File lib/csl/style/names.rb, line 142 def sort_separator attributes[:'sort-separator'] || ', ' end
@return [String] the delimiter between family and given names
in sort order
Source
# File lib/csl/style/names.rb, line 98 def truncate(names, subsequent = false) count = truncate_at(subsequent) count = names.length if count.nil? names.take count.to_i end
@param [Enumerable] names @return [Array] the truncated list of names
Source
# File lib/csl/style/names.rb, line 88 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
@param names [#to_i, Enumerable] the list of names (or its length) @return [Boolean] whether or not the list should be truncated
Source
# File lib/csl/style/names.rb, line 112 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
Source
# File lib/csl/style/names.rb, line 120 def truncate_at!(at) attributes[:'et-al-use-first'] = at.to_i self end
Source
# File lib/csl/style/names.rb, line 130 def truncate_subsequent_at!(at) attributes[:'et-al-subsequent-use-first'] = at.to_i self end
Source
# File lib/csl/style/names.rb, line 135 def truncate_subsequent_when!(pos) attributes[:'et-al-subsequent-min'] = pos.to_i self end
Source
# File lib/csl/style/names.rb, line 104 def truncate_when(subsequent = false) if subsequent && attribute?(:'et-al-subsequent-min') attributes[:'et-al-subsequent-min'] else attributes[:'et-al-min'] end end
Source
# File lib/csl/style/names.rb, line 125 def truncate_when!(pos) attributes[:'et-al-min'] = pos.to_i self end