Class: Wagon::Ward

Inherits:
Page
  • Object
show all
Defined in:
lib/wagon/ward.rb

Instance Attribute Summary

Attributes inherited from Page

#connection, #source

Instance Method Summary collapse

Methods inherited from Page

#get, #initialize, #method_missing, #post

Constructor Details

This class inherits a constructor from Wagon::Page

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wagon::Page

Instance Method Details

#directoryObject



17
18
19
# File 'lib/wagon/ward.rb', line 17

def directory
  @directory ||= Directory.new(connection, directory_path, self)
end

#directory_pathObject



13
14
15
# File 'lib/wagon/ward.rb', line 13

def directory_path
  @directory_path ||= "/units/a/directory/photoprint/1,10357,605-1-7-#{ward_id},00.html"
end

#householdsObject



21
22
23
# File 'lib/wagon/ward.rb', line 21

def households
  directory.households
end

#membersObject



25
26
27
# File 'lib/wagon/ward.rb', line 25

def members
  households.collect(&:members).flatten()
end

#nameObject



5
6
7
# File 'lib/wagon/ward.rb', line 5

def name
  @name ||= self.at('a.channeltitle[href^="/units/home"]').inner_text.strip
end

#to_pdf(options) ⇒ Object



29
30
31
# File 'lib/wagon/ward.rb', line 29

def to_pdf(options)
  directory.to_pdf(options)
end

#ward_idObject



9
10
11
# File 'lib/wagon/ward.rb', line 9

def ward_id
  @ward_id ||= @url.sub(%r{^.+\-(\d+),\d+\.html$}, '\1')
end