Ruby API to the restful UK legislation XML service hosted at: www.legislation.gov.uk/

Warning: API under development

The legislation-uk API is in early development so it may change slightly over time. It should be in working order, so please give it a test spin!

The source code is hosted at github. Feel free to fork the code if you have something to contribute:

github.com/robmckinnon/legislation-uk

Install as a Gem

Should be up at rubyforge, so to install:

sudo gem install legislation-uk

To use

Can be used from command line if you run irb:

> irb

require 'rubygems'
require 'legislation_uk'

legislation = Legislation::UK.find('Channel Tunnel Rail Link Act 1996')

legislation.title
#=> "Channel Tunnel Rail Link Act 1996"

legislation.legislation_uri
#=> "http://www.legislation.gov.uk/ukpga/1996/61"

legislation.opsi_uri
#=> "http://www.opsi.gov.uk/acts/acts1996/ukpga_19960061_en_1"

legislation.statutelaw_uri
#=> "http://www.statutelaw.gov.uk/documents/1996/61/ukpga/c61"

legislation.parts.size
#=> 3

legislation.parts.collect(&:number)
#=> ["Part I", "Part II", "Part III"]

legislation.parts.collect(&:title)
#=> ["The Channel Tunnel Rail Link", "The A2 and M2 Improvement Works",
#    "Miscellaneous and General"]

section = legislation.sections.first

section.title
#=> "Construction and maintenance of scheduled works"

section.number
#=> "1"

section.legislation_uri
#=> "http://www.legislation.gov.uk/ukpga/1996/61/section/1"

section.opsi_uri
#=> "http://www.opsi.gov.uk/acts/acts1996/ukpga_19960061_en_2#pt1-pb1-l1g1"