Sha256: 10480055b44bbe8460e09796f27252a8a5ea297955eb244adffdc85dca067165

Contents?: true

Size: 825 Bytes

Versions: 17

Compression:

Stored size: 825 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? { |v|
            v.nil? || v.respond_to?(:empty?) && v.empty?
          }
        end

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

        def clear!
          history.clear
          self
        end
      end

    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
citeproc-ruby-2.1.0 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-2.0.0 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.14 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.13 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.12 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.11 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.10 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.8 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.7 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.6 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.5 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.4 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.3 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.2 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.1 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.1.0 lib/citeproc/ruby/renderer/observer.rb
citeproc-ruby-1.0.6 lib/citeproc/ruby/renderer/observer.rb