class CSL::Style::Label

Labels are used for printing the term matching the variable selected with the required variable attribute, which must be set to “locator, ”page“, or one of the number variables.

The term is only rendered if the selected variable is non-empty.

If the {Label} is the child of a {Names} node, the parent's variable is used instead of the local attribute.

Attributes

terms[R]

@!attribute [r] terms @return [Hash<String, String>] a cache for variable-term mapping

variables[R]

@!attribute [r] variables @return [Array<Symbol>] a list of valid label variable values

formatting[R]

Public Instance Methods

always_pluralize?() click to toggle source
# File lib/csl/style/label.rb, line 59
def always_pluralize?
  attribute?(:plural) && attributes[:plural] =~ /^always$/i
end
has_variable?() click to toggle source
# File lib/csl/style/label.rb, line 38
def has_variable?
  attribute?(:variable)
end
name_label?()
Alias for: names_label?
names_label?() click to toggle source

@return [Boolean] whether or not the {Label} is inside a {Names} node

# File lib/csl/style/label.rb, line 68
def names_label?
  parent.is_a?(Names)
end
Also aliased as: name_label?
never_pluralize?() click to toggle source
# File lib/csl/style/label.rb, line 63
def never_pluralize?
  attribute?(:plural) && attributes[:plural] =~ /^never$/i
end
term() click to toggle source

@return [String] the term name for the label's variable

# File lib/csl/style/label.rb, line 74
def term
  Label.terms[variable.to_s]
end
variable() click to toggle source

The value of the node's variable attribute. If the {Label} is the child of a {Names} node, returns the parent's variable attribute instead.

@return [String, nil] the value of the node's variable attribute

# File lib/csl/style/label.rb, line 47
def variable
  attributes[:variable]
end