class CSL::Style::Name

Attributes

name[RW]

Public Class Methods

new(attributes = {}) { |self| ... } click to toggle source
Calls superclass method CSL::Node.new
# 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

all_names_as_sort_order!() click to toggle source
# File lib/csl/style/names.rb, line 178
def all_names_as_sort_order!
  attributes[:'name-as-sort-order'] = 'all'
  self
end
all_names_as_sort_order?() click to toggle source
# File lib/csl/style/names.rb, line 169
def all_names_as_sort_order?
  !!(attributes[:'name-as-sort-order'].to_s =~ /^all$/i)
end
connector() click to toggle source
# File lib/csl/style/names.rb, line 336
def connector
  c = attributes[:and]
  c == 'symbol' ? '&' : c
end
connector=(c) click to toggle source
# File lib/csl/style/names.rb, line 341
def connector=(c)
  attributes[:and] = c
end
count?() click to toggle source
# File lib/csl/style/names.rb, line 64
def count?
  attribute?(:form) && attributes[:form] == 'count'
end
delimiter() click to toggle source

@return [String] the delimiter between names

# File lib/csl/style/names.rb, line 146
def delimiter
  attributes[:delimiter] || ', '
end
delimiter_always_precedes_et_al!() click to toggle source

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
Also aliased as: delimiter_precedes_et_al!
delimiter_always_precedes_et_al?() click to toggle source

@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
delimiter_always_precedes_last!() click to toggle source

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
Also aliased as: delimiter_precedes_last!
delimiter_always_precedes_last?() click to toggle source

@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
delimiter_contextually_precedes_et_al!() click to toggle source

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
delimiter_contextually_precedes_et_al?() click to toggle source

@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
delimiter_contextually_precedes_last!() click to toggle source

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
delimiter_contextually_precedes_last?() click to toggle source

@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
delimiter_never_precedes_et_al!() click to toggle source

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
delimiter_never_precedes_et_al?() click to toggle source

@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
delimiter_never_precedes_last!() click to toggle source

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
delimiter_never_precedes_last?() click to toggle source

@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
delimiter_precedes_et_al!()
delimiter_precedes_et_al?(names) click to toggle source
# 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
delimiter_precedes_et_al_after_inverted_name!() click to toggle source
# 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
delimiter_precedes_et_al_after_inverted_name?() click to toggle source
# 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
delimiter_precedes_last!()
delimiter_precedes_last?(names) click to toggle source

@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
delimiter_precedes_last_after_inverted_name!() click to toggle source
# File lib/csl/style/names.rb, line 323
def delimiter_precedes_last_after_inverted_name!
  attributes[:'delimiter-precedes-last'] = 'after-inverted-name'
  self
end
delimiter_precedes_last_after_inverted_name?() click to toggle source
# 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
ellipsis() click to toggle source
# File lib/csl/style/names.rb, line 332
def ellipsis
  "#{delimiter}… "
end
ellipsis?() click to toggle source
# File lib/csl/style/names.rb, line 328
def ellipsis?
  attributes[:'et-al-use-last'].to_s =~ /^true$/
end
et_al() click to toggle source
# File lib/csl/style/names.rb, line 77
def et_al
  @et_al || parent && parent.et_al
end
et_al=(et_al) click to toggle source
# File lib/csl/style/names.rb, line 81
def et_al=(et_al)
  @et_al = et_al
end
first_name_as_sort_order!() click to toggle source
# File lib/csl/style/names.rb, line 173
def first_name_as_sort_order!
  attributes[:'name-as-sort-order'] = 'first'
  self
end
first_name_as_sort_order?() click to toggle source
# File lib/csl/style/names.rb, line 165
def first_name_as_sort_order?
  !!(attributes[:'name-as-sort-order'].to_s =~ /^first$/i)
end
initialize_without_hyphen?() click to toggle source
# File lib/csl/style/names.rb, line 72
def initialize_without_hyphen?
  !root? && root.respond_to?(:initialize_without_hyphen?) &&
    root.initialize_without_hyphen?
end
name_as_sort_order() click to toggle source
# File lib/csl/style/names.rb, line 159
def name_as_sort_order
  attributes[:'name-as-sort-order'].to_s
end
Also aliased as: sort_order
name_as_sort_order?() click to toggle source
# File lib/csl/style/names.rb, line 150
def name_as_sort_order?
  attribute?(:'name-as-sort-order')
end
name_as_sort_order_at?(position) click to toggle source
# 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
name_options() click to toggle source
# File lib/csl/style/names.rb, line 68
def name_options
  attributes_for :form, :initialize, :'initialize-with', :'sort-separator'
end
sort_order()
Alias for: name_as_sort_order
sort_separator() click to toggle source

@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
truncate(names, subsequent = false) click to toggle source

@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
truncate?(names, subsequent = false) click to toggle source

@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
truncate_at(subsequent = false) click to toggle source
# 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
truncate_at!(at) click to toggle source
# File lib/csl/style/names.rb, line 119
def truncate_at!(at)
  attributes[:'et-al-use-first'] = at.to_i
  self
end
truncate_subsequent_at!(at) click to toggle source
# File lib/csl/style/names.rb, line 129
def truncate_subsequent_at!(at)
  attributes[:'et-al-subsequent-use-first'] = at.to_i
  self
end
truncate_subsequent_when!(pos) click to toggle source
# File lib/csl/style/names.rb, line 134
def truncate_subsequent_when!(pos)
  attributes[:'et-al-subsequent-min'] = pos.to_i
  self
end
truncate_when(subsequent = false) click to toggle source
# 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
truncate_when!(pos) click to toggle source
# File lib/csl/style/names.rb, line 124
def truncate_when!(pos)
  attributes[:'et-al-min'] = pos.to_i
  self
end