Sha256: 4c0b1227786ed92cd87981755697b63e1a6a30fc6dcc7f9071b67d50e4e1595b
Contents?: true
Size: 1.94 KB
Versions: 3
Compression:
Stored size: 1.94 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), [] reset 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) reset ensure notify_observers :clear!, memories.delete(:mode), memories end def reset @item, @node, @substitute, @authors, @names = nil, nil, nil, [], nil self ensure changed 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-2.1.0 | lib/citeproc/ruby/renderer/state.rb |
citeproc-ruby-2.0.0 | lib/citeproc/ruby/renderer/state.rb |
citeproc-ruby-1.1.14 | lib/citeproc/ruby/renderer/state.rb |