Class: Legislature
- Inherits:
-
Object
- Object
- Legislature
- Defined in:
- lib/legebiltzarra/legislature.rb
Constant Summary collapse
- ACTUAL_LEGISLATURE =
"GA"
- BASE_URL =
"http://www.parlamento.euskadi.net"
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #document ⇒ Object
-
#initialize(id = ACTUAL_LEGISLATURE) ⇒ Legislature
constructor
A new instance of Legislature.
- #parliamentarians ⇒ Object
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
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/legebiltzarra/legislature.rb', line 5 def id @id end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/legebiltzarra/legislature.rb', line 5 def url @url end |
Instance Method Details
#document ⇒ Object
17 18 19 |
# File 'lib/legebiltzarra/legislature.rb', line 17 def document @document ||= Nokogiri::HTML(open(self.url)) end |
#parliamentarians ⇒ Object
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 |