Sha256: ddd192f62b3d243f04ae52364788c0cb64124634e10d4caa4e29384e91356048

Contents?: true

Size: 809 Bytes

Versions: 13

Compression:

Stored size: 809 Bytes

Contents

module CiteProc
	module Abbreviate

		attr_accessor :namespace

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

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

		# @overload abbreviate(namespace = :default, context, word)
		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
			@abbreviations.deep_fetch(*arguments)
		end

		alias abbrev abbreviate

	end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
citeproc-1.0.0.pre12 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre11 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre10 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre9 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre8 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre7 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre6 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre5 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre4 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre3 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre2 lib/citeproc/abbreviate.rb
citeproc-1.0.0.pre1 lib/citeproc/abbreviate.rb
citeproc-0.0.9 lib/citeproc/abbreviate.rb