Sha256: ac7ed2532ddc949dc374a4354a9255be4cac677907b06efe4d53fd8dadab16a8

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

module SimplePvr
  module Server
    class ProgrammesController < BaseController
      get '/title_search' do
        Model::Programme.titles_containing(params['query']).to_json
      end

      get '/search' do
        Model::Programme.with_title_containing(params['query']).map {|programme| programme_hash(programme) }.to_json
      end

      get '/:id' do |id|
        programme = Model::Programme.get(id)
        programme_hash(programme).to_json
      end

      post '/:id/record_on_any_channel' do |id|
        programme = Model::Programme.get(id.to_i)
        Model::Schedule.add_specification(title: programme.title)
        reload_schedules
        programme_hash(programme).to_json
      end

      post '/:id/record_on_this_channel' do |id|
        programme = Model::Programme.get(id.to_i)
        Model::Schedule.add_specification(title: programme.title, channel: programme.channel)
        reload_schedules
        programme_hash(programme).to_json
      end

      post '/:id/record_just_this_programme' do |id|
        programme = Model::Programme.get(id.to_i)
        Model::Schedule.add_specification(title: programme.title, channel: programme.channel, start_time: programme.start_time)
        reload_schedules
        programme_hash(programme).to_json
      end

      post '/:id/exclude' do |id|
        programme = Model::Programme.get(id.to_i)
        Model::Schedule.create(type: :exception, title: programme.title, channel: programme.channel, start_time: programme.start_time)
        reload_schedules
        programme_hash(programme).to_json
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_pvr-0.0.2 lib/simple_pvr/server/programmes_controller.rb
simple_pvr-0.0.1 lib/simple_pvr/server/programmes_controller.rb