Sha256: a96d8ff8dbb76c100f3ca8574c39fcb9e42269f3f72016acc8af463e3f374a48
Contents?: true
Size: 1.85 KB
Versions: 3
Compression:
Stored size: 1.85 KB
Contents
module CiteProc module Ruby class Renderer def citation_mode? state.mode == 'citation' end def bibliography_mode? state.mode == 'bibliography' end def sort_mode? state.mode == 'key' end def substitution_mode? !state.substitute.nil? end def style return unless state.node && !state.node.root? && state.node.root.is_a?(CSL::Style) state.node.root end class State include Observable attr_reader :history, :node, :item, :authors, :substitute def initialize @history, @authors = History.new(self, 3), [] end def store!(item, node) @item, @node = item, node ensure changed end def store_authors!(authors) @authors << authors ensure changed end def clear!(result = nil) memories = conserve(result) @item, @node, @substitute, @authors, @names = nil, nil, nil, [], nil ensure changed notify_observers :clear!, memories.delete(:mode), memories end def mode node && node.nodename end def substitute!(names) @substitute = names end def clear_substitute!(backup = nil) @substitute = backup end def previous_authors past = history.recall(mode) return unless past && !past.empty? past[:authors] end def rendered_names? @names end def rendered_names! @names = true end def conserve(result = nil) { :mode => mode, :item => item, :authors => authors, :result => result } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
citeproc-ruby-1.0.2 | lib/citeproc/ruby/renderer/state.rb |
citeproc-ruby-1.0.1 | lib/citeproc/ruby/renderer/state.rb |
citeproc-ruby-1.0.0 | lib/citeproc/ruby/renderer/state.rb |