class BibTeX::Names
Public Class Methods
Source
# File lib/bibtex/names.rb, line 35 def initialize(*arguments) @tokens = [] arguments.flatten.compact.each do |argument| add(argument) end end
Source
# File lib/bibtex/names.rb, line 28 def self.parse(string) new(NameParser.new.parse(string)) rescue StandardError => e BibTeX.log.info(e.message) nil end
Public Instance Methods
Source
# File lib/bibtex/names.rb, line 109 def <=>(other) other.respond_to?(:to_a) ? to_a <=> other.to_a : super end
Calls superclass method
Source
# File lib/bibtex/names.rb, line 88 def add(name) if name.is_a?(Name) @tokens << name elsif name.respond_to?(:to_s) @tokens += Names.parse(name.to_s) else raise ArgumentError, "failed to add #{name.inspect}: not a name." end self end
Source
# File lib/bibtex/names.rb, line 80 def to_citeproc(options = {}) map { |n| n.to_citeproc(options) } end
Source
# File lib/bibtex/names.rb, line 54 def to_s(options = {}) return value unless options.key?(:quotes) q = [options[:quotes]].flatten [q[0], value, q[-1]].compact.join end
Source
# File lib/bibtex/names.rb, line 50 def value(options = {}) @tokens.map { |n| n.to_s(options) }.join(' and ') end