Sha256: 50f8d7df103628b62952519decf3328b636b8268778d0a63749505fcb36c24a1

Contents?: true

Size: 758 Bytes

Versions: 6

Compression:

Stored size: 758 Bytes

Contents

module CiteProc
  module Ruby

    class Renderer

      class ItemObserver
        attr_accessor :history, :item

        def initialize(item, history = {})
          @item, @history = item, history
        end

        def start
          item.add_observer(self)
          self
        end

        def stop
          item.delete_observer(self)
          self
        end

        def update(method, key, value)
          history[key] = value if method == :read
        end

        def skip?
          !history.empty? && history.values.all?(&:nil?)
        end

        def accessed
          history.select { |key, value| !value.nil? }.keys
        end

        def clear!
          history.clear
          self
        end
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
citeproc-ruby-1.0.5 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.0.4 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.0.3 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.0.2 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.0.1 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.0.0 lib/citeproc/ruby/renderer/observer.rb