Class: Sphinxcrawl::Stream

Inherits:
Object
  • Object
show all
Includes:
REXML
Defined in:
lib/sphinxcrawl/stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pages) ⇒ Stream

Returns a new instance of Stream.



9
10
11
12
# File 'lib/sphinxcrawl/stream.rb', line 9

def initialize(pages)
  @pages = Array(pages)
  @count = 0
end

Instance Attribute Details

#pages ⇒ Object (readonly)

Returns the value of attribute pages.



7
8
9
# File 'lib/sphinxcrawl/stream.rb', line 7

def pages
  @pages
end

Instance Method Details

#empty? ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/sphinxcrawl/stream.rb', line 14

def empty?
  pages.length == 0
end

#field_names ⇒ Object



22
23
24
# File 'lib/sphinxcrawl/stream.rb', line 22

def field_names
  @field_names ||= pages.map(&:field_names).flatten.uniq
end

#number_of_pages ⇒ Object



18
19
20
# File 'lib/sphinxcrawl/stream.rb', line 18

def number_of_pages
  pages.length
end

#to_xml ⇒ Object



26
27
28
29
30
# File 'lib/sphinxcrawl/stream.rb', line 26

def to_xml
  add_fields
  add_documents
  ''.tap { |xml| document.write(xml) }
end