Class: CiteProc::Ruby::Renderer::ItemObserver
- Inherits:
-
Object
- Object
- CiteProc::Ruby::Renderer::ItemObserver
- Defined in:
- lib/citeproc/ruby/renderer/observer.rb
Instance Attribute Summary collapse
-
#history ⇒ Object
Returns the value of attribute history.
-
#item ⇒ Object
Returns the value of attribute item.
Instance Method Summary collapse
- #accessed ⇒ Object
- #clear! ⇒ Object
-
#initialize(item, history = {}) ⇒ ItemObserver
constructor
A new instance of ItemObserver.
- #skip? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
- #update(method, key, value) ⇒ Object
Constructor Details
#initialize(item, history = {}) ⇒ ItemObserver
Returns a new instance of ItemObserver.
9 10 11 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 9 def initialize(item, history = {}) @item, @history = item, history end |
Instance Attribute Details
#history ⇒ Object
Returns the value of attribute history.
7 8 9 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 7 def history @history end |
#item ⇒ Object
Returns the value of attribute item.
7 8 9 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 7 def item @item end |
Instance Method Details
#accessed ⇒ Object
33 34 35 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 33 def accessed history.select { |key, value| !value.nil? }.keys end |
#clear! ⇒ Object
37 38 39 40 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 37 def clear! history.clear self end |
#skip? ⇒ Boolean
27 28 29 30 31 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 27 def skip? !history.empty? && history.values.all? { |v| v.nil? || v.respond_to?(:empty?) && v.empty? } end |
#start ⇒ Object
13 14 15 16 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 13 def start item.add_observer(self) self end |
#stop ⇒ Object
18 19 20 21 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 18 def stop item.delete_observer(self) self end |
#update(method, key, value) ⇒ Object
23 24 25 |
# File 'lib/citeproc/ruby/renderer/observer.rb', line 23 def update(method, key, value) history[key] = value if method == :read end |