Class: Sitemap::Store
- Inherits:
-
Object
- Object
- Sitemap::Store
- Defined in:
- lib/sitemap/store.rb
Instance Attribute Summary collapse
-
#before_reset_callback ⇒ Object
Returns the value of attribute before_reset_callback.
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#max_entries ⇒ Object
Returns the value of attribute max_entries.
-
#reset_count ⇒ Object
Returns the value of attribute reset_count.
Instance Method Summary collapse
- #<<(entry) ⇒ Object
- #before_reset(&block) ⇒ Object
-
#initialize(options = {}) ⇒ Store
constructor
A new instance of Store.
- #reset! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Store
Returns a new instance of Store.
7 8 9 10 11 |
# File 'lib/sitemap/store.rb', line 7 def initialize( = {}) self.entries = [] self.reset_count = 0 self.max_entries = [:max_entries] end |
Instance Attribute Details
#before_reset_callback ⇒ Object
Returns the value of attribute before_reset_callback.
5 6 7 |
# File 'lib/sitemap/store.rb', line 5 def before_reset_callback @before_reset_callback end |
#entries ⇒ Object
Returns the value of attribute entries.
5 6 7 |
# File 'lib/sitemap/store.rb', line 5 def entries @entries end |
#max_entries ⇒ Object
Returns the value of attribute max_entries.
5 6 7 |
# File 'lib/sitemap/store.rb', line 5 def max_entries @max_entries end |
#reset_count ⇒ Object
Returns the value of attribute reset_count.
5 6 7 |
# File 'lib/sitemap/store.rb', line 5 def reset_count @reset_count end |
Instance Method Details
#<<(entry) ⇒ Object
13 14 15 16 |
# File 'lib/sitemap/store.rb', line 13 def << entry reset! if entries.length >= max_entries self.entries << entry end |
#before_reset(&block) ⇒ Object
24 25 26 |
# File 'lib/sitemap/store.rb', line 24 def before_reset(&block) self.before_reset_callback = block end |
#reset! ⇒ Object
18 19 20 21 22 |
# File 'lib/sitemap/store.rb', line 18 def reset! before_reset_callback.call(entries) if before_reset_callback self.entries = [] self.reset_count += 1 end |