Class: CSL::Style::Label
Overview
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.
Class Attribute Summary collapse
-
.terms ⇒ Hash<String, String>
readonly
A cache for variable-term mapping.
-
.variables ⇒ Array<Symbol>
readonly
A list of valid label variable values.
Attributes inherited from Node
Attributes included from Treelike
Instance Method Summary collapse
- #always_pluralize? ⇒ Boolean
- #has_variable? ⇒ Boolean
- #names_label? ⇒ Boolean (also: #name_label?)
- #never_pluralize? ⇒ Boolean
-
#term ⇒ String
The term name for the label’s variable.
-
#variable ⇒ String?
The value of the node’s variable attribute.
Methods inherited from Node
#<=>, #attribute?, #attributes?, #attributes_for, constantize, create, create_attributes, #custom_attributes, #deep_copy, #default_attribute?, #default_attributes, default_attributes, #each, #exact_match?, #format_page_ranges?, #formatting_options, #has_attributes?, #has_default_attributes?, #has_language?, hide_default_attributes!, hide_default_attributes?, #initialize, #initialize_copy, #inspect, match?, #match?, matches?, #merge!, #page_range_format, parse, parse!, #quotes?, #reverse_merge!, #save_to, show_default_attributes!, #strip_periods?, #tags, #textnode?, types
Methods included from Extensions::Nesting
Methods included from PrettyPrinter
Methods included from Treelike
#<<, #add_child, #add_children, #ancestors, #closest, #delete_child, #delete_children, #depth, #descendants, #each_ancestor, #each_child, #each_descendant, #each_sibling, #empty?, #find_child, #find_children, #has_children?, #root, #root?, #siblings, #unlink
Constructor Details
This class inherits a constructor from CSL::Node
Class Attribute Details
.terms ⇒ Hash<String, String> (readonly)
Returns a cache for variable-term mapping.
35 36 37 |
# File 'lib/csl/style/label.rb', line 35 def terms @terms end |
.variables ⇒ Array<Symbol> (readonly)
Returns a list of valid label variable values.
31 32 33 |
# File 'lib/csl/style/label.rb', line 31 def variables @variables end |
Instance Method Details
#always_pluralize? ⇒ Boolean
59 60 61 |
# File 'lib/csl/style/label.rb', line 59 def always_pluralize? attribute?(:plural) && attributes[:plural] =~ /^always$/i end |
#has_variable? ⇒ Boolean
38 39 40 |
# File 'lib/csl/style/label.rb', line 38 def has_variable? attribute?(:variable) end |
#names_label? ⇒ Boolean Also known as: name_label?
Returns whether or not the CSL::Style::Label is inside a Names node.
68 69 70 |
# File 'lib/csl/style/label.rb', line 68 def names_label? parent.is_a?(Names) end |
#never_pluralize? ⇒ Boolean
63 64 65 |
# File 'lib/csl/style/label.rb', line 63 def never_pluralize? attribute?(:plural) && attributes[:plural] =~ /^never$/i end |
#term ⇒ String
Returns the term name for the label’s variable.
74 75 76 |
# File 'lib/csl/style/label.rb', line 74 def term Label.terms[variable.to_s] end |
#variable ⇒ String?
The value of the node’s variable attribute. If the CSL::Style::Label is the child of a Names node, returns the parent’s variable attribute instead.
47 48 49 |
# File 'lib/csl/style/label.rb', line 47 def variable attributes[:variable] end |