Class: BibTeX::Value

Inherits:
Object show all
Defined in:
lib/relaton_bib/renderer/bibtex_builder.rb

Instance Method Summary collapse

Instance Method Details

#to_s(options = {}) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/relaton_bib/renderer/bibtex_builder.rb', line 4

def to_s(options = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  if options.key?(:filter)
    opts = options.reject { |k,| k == :filter || (k == :quotes && (!atomic? || symbol?)) }
    return convert(options[:filter]).to_s(opts)
  end

  return value.to_s unless options.key?(:quotes) && atomic?

  q = Array(options[:quotes])
  [q[0], value, q[-1]].compact.join
end