Skip to content

Instantly share code, notes, and snippets.

@jagmitg
Created October 23, 2011 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagmitg/1307246 to your computer and use it in GitHub Desktop.
Save jagmitg/1307246 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
class CinemaSite
def self.get_cinema_links
doc = Nokogiri::XML(open('http://jagmit.co.uk/ruby/cinemas.xml'))
doc.xpath('//cinema[@name]').map do |i|
{name: i['name'], url: i['url']}
end
end
end
class CinemasController < ApplicationController
def index
@links = CinemaSite.get_cinema_links
end
end
<ul>
<% @links.each do |l| %>
<li><%= link_to l['name'], l['url'] %></li>
<% end %>
<%= @links %>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment