Sha256: 5c00147e1217cb3392bcd905d7c26c71bba6f491e607900b6393465ed1c4bd06

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 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, end_time: programme.end_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, end_time: programme.end_time)
        reload_schedules
        programme_hash(programme).to_json
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_pvr-1.0.0 lib/simple_pvr/server/programmes_controller.rb
simple_pvr-0.0.4 lib/simple_pvr/server/programmes_controller.rb
simple_pvr-0.0.3 lib/simple_pvr/server/programmes_controller.rb