Sha256: 15dcb780a02ce57c0c597643c8a4bd639eb1e3c823098aec059ca627e75d3ab1
Contents?: true
Size: 868 Bytes
Versions: 3
Compression:
Stored size: 868 Bytes
Contents
require 'multi_json' module CiteProc module Abbreviate attr_reader :abbreviations attr_accessor :default_namespace 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 # call-seq: # 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(default_namespace || :default) if arguments.length < 3 @abbreviations.deep_fetch(*arguments) end alias abbrev abbreviate end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
citeproc-0.0.3 | lib/citeproc/abbreviate.rb |
citeproc-0.0.2 | lib/citeproc/abbreviate.rb |
citeproc-0.0.1 | lib/citeproc/abbreviate.rb |