class Sinatra::Base

def user_agent(pattern)

Will set params[:agent].
Condition for matching user agent. Parameter should be Regexp.
def user_agent(pattern)
  condition do
    if request.user_agent.to_s =~ pattern
      @params[:agent] = $~[1..-1]
      true
    else
      false
    end
  end
end