Class: Legislature

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

Constant Summary collapse

ACTUAL_LEGISLATURE =
"GA"
BASE_URL =
"http://www.parlamento.euskadi.net"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = ACTUAL_LEGISLATURE) ⇒ Legislature

Returns a new instance of Legislature.



7
8
9
10
# File 'lib/legebiltzarra/legislature.rb', line 7

def initialize(id=ACTUAL_LEGISLATURE)
  @id = id                   
  @url = "#{BASE_URL}/comparla/c_comparla_alf_L#{self.id}.html"
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/legebiltzarra/legislature.rb', line 5

def id
  @id
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/legebiltzarra/legislature.rb', line 5

def url
  @url
end

Instance Method Details

#documentObject



17
18
19
# File 'lib/legebiltzarra/legislature.rb', line 17

def document
   @document ||= Nokogiri::HTML(open(self.url))
end

#parliamentariansObject



12
13
14
# File 'lib/legebiltzarra/legislature.rb', line 12

def parliamentarians
  document.search('td[@class="miembro_persona"]/a/@href').map { |p| Parliamentarian.new(p.content.match(/\/fichas\/c_(.*).html/)[1]) } rescue []
end