Class: GsaFeeds::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gsa_feeds/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, datasource = 'web', feedtype = 'incremental', timeout = false) ⇒ Base

Returns a new instance of Base.



2
3
4
5
6
7
8
# File 'lib/gsa_feeds/base.rb', line 2

def initialize(hostname, datasource = 'web', feedtype = 'incremental', timeout = false)
  @hostname = hostname
  @timeout = timeout || GsaFeeds::TIMEOUT
  @records = []
  @datasource = datasource
  @feedtype = feedtype
end

Instance Attribute Details

#datasourceObject

Returns the value of attribute datasource.



9
10
11
# File 'lib/gsa_feeds/base.rb', line 9

def datasource
  @datasource
end

#feedtypeObject

Returns the value of attribute feedtype.



9
10
11
# File 'lib/gsa_feeds/base.rb', line 9

def feedtype
  @feedtype
end

#hostnameObject

Returns the value of attribute hostname.



9
10
11
# File 'lib/gsa_feeds/base.rb', line 9

def hostname
  @hostname
end

#recordsObject Also known as: to_a

Returns the value of attribute records.



9
10
11
# File 'lib/gsa_feeds/base.rb', line 9

def records
  @records
end

#timeoutObject

Returns the value of attribute timeout.



9
10
11
# File 'lib/gsa_feeds/base.rb', line 9

def timeout
  @timeout
end

Instance Method Details

#add_record(record) ⇒ Object



16
17
18
# File 'lib/gsa_feeds/base.rb', line 16

def add_record(record)
  @records << record
end

#build_record(url, options = {}, metadata = nil, content = nil) ⇒ Object



20
21
22
# File 'lib/gsa_feeds/base.rb', line 20

def build_record(url, options = {},  = nil, content = nil)
  @records << GsaFeeds::Record.new(url, options, , content)
end

#clear!Object



12
13
14
# File 'lib/gsa_feeds/base.rb', line 12

def clear!
  @records = []
end

#commit!Object



24
25
26
27
28
# File 'lib/gsa_feeds/base.rb', line 24

def commit!
  push_records(@records)
  clear!
  true
end

#to_xmlObject



30
31
32
# File 'lib/gsa_feeds/base.rb', line 30

def to_xml
  build_xml(@records)
end