Class: ChronicPingController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/chronic_ping_controller.rb

Instance Method Summary collapse

Instance Method Details

#parseObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/chronic_ping_controller.rb', line 2

def parse
  unless params[:q].blank?
    begin
      format = ChronicPing.config.formats[params[:f] || :default] || params[:f]
      response = Chronic.parse(params[:q]).strftime(format)

      render :json => { status: :success, response: response }
    rescue
      render :json => { status: :error, response: "" }
    end
  else
    render :json => { status: :incomplete_query, response: "" }
  end
end