Class: WahlrechtDe::Survey

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSurvey

Returns a new instance of Survey.



10
11
12
13
14
# File 'lib/survey.rb', line 10

def initialize
	doc = Nokogiri::HTML(open("http://www.wahlrecht.de/umfragen/index.htm"))
	@rows = doc.xpath("//table/tbody/tr")
	@datalines = []
end

Instance Attribute Details

#rowsObject (readonly)

Returns the value of attribute rows.



8
9
10
# File 'lib/survey.rb', line 8

def rows
  @rows
end

Instance Method Details

#parse(index) ⇒ Object



16
17
18
19
# File 'lib/survey.rb', line 16

def parse index
	row = @rows[index]
	@datalines.push Dataline.new row
end

#to_sObject



21
22
23
24
25
# File 'lib/survey.rb', line 21

def to_s
	@datalines.each do |dataline|
		puts dataline
	end
end