Module: CiteProc::Abbreviate

Included in:
Processor
Defined in:
lib/citeproc/abbreviate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#namespaceObject

Returns the value of attribute namespace.



4
5
6
# File 'lib/citeproc/abbreviate.rb', line 4

def namespace
  @namespace
end

Instance Method Details

#abbreviate(namespace = :default, context, word) ⇒ Object Also known as: abbrev

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/citeproc/abbreviate.rb', line 22

def abbreviate(*arguments)
	raise ArgumentError, "wrong number of arguments (#{arguments.length} for 2..3)" unless
      (2..3).include?(arguments.length)

	arguments.unshift(namespace || :default) if arguments.length < 3

    arguments[0] = arguments[0].to_sym
    arguments[1] = arguments[1].to_sym

	abbreviations.deep_fetch(*arguments)
end

#abbreviationsObject



6
7
8
# File 'lib/citeproc/abbreviate.rb', line 6

def abbreviations
	@abbreviations ||= { :default => {} }
end

#abbreviations=(abbreviations) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/citeproc/abbreviate.rb', line 10

def abbreviations=(abbreviations)
	@abbreviations = case abbreviations
		when ::String
			::JSON.parse(abbreviations, :symbolize_names => true)
		when ::Hash
			abbreviations.deep_copy.symbolize_keys
		else
			raise ArgumentError, "failed to set abbreviations from #{abbreviations.inspect}"
		end
end