Class: MassiveSitemap::Writer::Base
- Inherits:
-
Object
- Object
- MassiveSitemap::Writer::Base
- Defined in:
- lib/massive_sitemap/writer/base.rb
Constant Summary collapse
- OPTS =
{}
Instance Method Summary collapse
-
#close! ⇒ Object
close writer (e.g store file).
- #current ⇒ Object
- #each(&block) ⇒ Object
-
#init!(options = {}) ⇒ Object
init writer: try to open stream (e.g. file).
-
#inited? ⇒ Boolean
keep status of stream.
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
-
#print(string) ⇒ Object
write to stream.
-
#set(options) ⇒ Object
API to which a builder talks to.
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 |
# File 'lib/massive_sitemap/writer/base.rb', line 12 def initialize( = {}) @options = self.class::OPTS.merge() @stream = nil end |
Instance Method Details
#close! ⇒ Object
close writer (e.g store file)
35 36 37 38 39 40 |
# File 'lib/massive_sitemap/writer/base.rb', line 35 def close! if inited? close_stream(@stream) @stream = nil end end |
#current ⇒ Object
56 57 58 |
# File 'lib/massive_sitemap/writer/base.rb', line 56 def current stream_id end |
#each(&block) ⇒ Object
52 53 54 |
# File 'lib/massive_sitemap/writer/base.rb', line 52 def each(&block) stream_ids.each(&block) end |
#init!(options = {}) ⇒ Object
init writer: try to open stream (e.g. file)
27 28 29 30 31 32 |
# File 'lib/massive_sitemap/writer/base.rb', line 27 def init!( = {}) set() if init? @stream = open_stream end end |
#inited? ⇒ Boolean
keep status of stream
43 44 45 |
# File 'lib/massive_sitemap/writer/base.rb', line 43 def inited? @stream end |
#print(string) ⇒ Object
write to stream
48 49 50 |
# File 'lib/massive_sitemap/writer/base.rb', line 48 def print(string) @stream.print(string) if inited? end |
#set(options) ⇒ Object
API to which a builder talks to
update wirter options, e.g. filename or overwrite behavior
21 22 23 24 |
# File 'lib/massive_sitemap/writer/base.rb', line 21 def set() @options.merge!() self end |