Sha256: 9a252ea077b9b31dd56e8d4c72a75662401cafa6cc5ae667821c188a3dbfa5c4
Contents?: true
Size: 835 Bytes
Versions: 2
Compression:
Stored size: 835 Bytes
Contents
require 'multi_json' 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 # 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(namespace || :default) if arguments.length < 3 @abbreviations.deep_fetch(*arguments) end alias abbrev abbreviate end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
citeproc-0.0.8 | lib/citeproc/abbreviate.rb |
citeproc-0.0.6 | lib/citeproc/abbreviate.rb |