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']} | |
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]} | |
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]} | |
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 Cinemas < ActiveRecord::Migration | |
def up | |
add_column :postcode, :string, :telephone, :integer | |
def down | |
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 Cinemas < ActiveRecord::Migration | |
def up | |
add_column :cinemas, :postcode, :string | |
add_column :cinemas, :telephone, :integer | |
def down | |
remove_column :cinemas, :telephone | |
remove_column :cinemas, :postcode | |
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
<cinemas> | |
<cinema name=" " phone=" " address=" " postcode=" " root=" " url="/cinemas/1" id="1"> | |
<films> | |
<film title="" rating="PG" release="24/10/2011"> | |
<shows> | |
<show date="Sun 30 Oct" time="10:40" videoType="digital"/><show date="Sun 30 Oct" time="13:10" videoType="digital"/> | |
</shows> | |
</film> | |
</films> | |
</cinema> |
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 CinemaFilms | |
def self.get_film_links | |
doc = Nokogiri::XML(open('http://Whatever.com/ruby/all-performances.xml')) | |
doc.xpath('//film[@title]').map do |i| | |
{title: i[:title], rating: i[:rating], release: i[:release], length: i[:length], poster: i[:poster], director: i[:director], synopsis: i[:synopsis], cast: i[:cast] } |
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 CinemaFilms | |
belongs_to :cinemas | |
def self.get_film_links | |
doc = Nokogiri::XML(open('http://jagmit.co.uk/ruby/all-performances.xml')) | |
doc.xpath('//film[@title]').map do |i| | |
{title: i[:title], rating: i[:rating], release: i[:release], length: i[:length], poster: i[:poster], director: i[:director], synopsis: i[:synopsis], cast: i[:cast] } |
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
<h1 style="text-transform:uppercase;text-align:center;border-bottom:2px solid black;padding-bottom:10px;">Cinema listings for Cineworld</h1> | |
<table> | |
<tr> | |
<th style="text-decoration:underline;">ID</th> | |
<th style="padding-right:50px;"></th> | |
<th style="text-decoration:underline;">Name</th> | |
<th style="padding-right:50px;"></th> | |
<th style="text-decoration:underline;">Address</th> | |
<th style="padding-right:50px;"></th> |
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 FilmsController < ApplicationController | |
# GET /films | |
# GET /films.json | |
def index | |
@cinema = Cinema.find(:cinema_id) | |
@films = @cinema.films | |
respond_to do |format| | |
format.html # index.html.erb |