Created
October 23, 2011 11:00
-
-
Save jagmitg/1307246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CinemasController < ApplicationController | |
def index | |
@links = CinemaSite.get_cinema_links | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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