query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
GET /users/1 GET /users/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end",
"def get \n render :json => User.find(params[:id])\n end",
"def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n # When a http GET request to '/users/1' is received, have it show,\n # in json format, user 1's information.\n @id = params[:id]\n @user = User.find(@id)\n render json: @user\n end",
"def user\n render :json=> User.find(params[:id])\n end",
"def fetch_one_user_data\n get_url(\"/api/v1/users/#{@filter}\")\n end",
"def show\n user = User.find(params[:id])\n render json: @user\nend",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n user = User.find(params[:id])\n\n render json: user\n end",
"def show\n render json: Users.find(params[\"id\"])\n end",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n user = User.select(:id, :username, :email).find(params[:id])\n render :json => user\n end",
"def show\n render json: User.find(params[\"id\"])\n end",
"def show\n @users = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users }\n end\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\nend",
"def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end",
"def show\n render json: User.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n render json:@user\n end",
"def show\n @user = User.find(params[:id])\n render json:@user\n end",
"def get_by_id\n \n # the user_id param comes from our route\n user = User.find(params[:user_id])\n \n if user\n render json: user, status: :ok\n else\n render json: { errors: 'User not found' }, status: :not_found\n end\n end",
"def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end",
"def get_user_details\n @user = User.find_by_id(params[:user_id])\n render json: @user\n end",
"def show\n render json: User.find(params[:id])\n end",
"def show\n user = User.find_by(id: params[:id])\n render json: user, status: :ok\n end",
"def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n end",
"def show\n @user = User.find(params[:id])\n render json: {user: @user}\n end",
"def list_users\n self.class.get('/users')\n end",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n user = User.friendly.find(params[:user_id]) \n render json: user\n end",
"def show\n render :json => User.find(params[:id])\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end",
"def index\n users = User.all\n json_response(users)\n end",
"def show\n @user = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM users \n WHERE username = '#{params[:username].downcase}' \n LIMIT 1\").first\n\n respond_to do |format|\n format.html\n format.json {render json: User.find(@user[0])}\n end\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response.first[1]\n end",
"def show\n @users = User.all\n json_response(@users)\n end",
"def index\n json_response(User.all) \n end",
"def get(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end",
"def index\n users = User.all\n render json: { users: users }, status: :ok\n end",
"def show\n # @user = User.first\n user = User.find(params[:id])\n render json: user\n end",
"def user(user_id, params = {})\n make_get_request(\"/users/#{user_id}\", params)\n end",
"def show_user_profile\n @user = User.find(username: params[:username])\n render json: @user\n end",
"def user(id = nil)\n id.to_i.zero? ? get('/user') : get(\"/users/#{id}\")\n end",
"def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, headers\n end",
"def user(user=nil)\n if user\n get(\"/users/#{user}\", {}, 3)\n else\n get(\"/user\", {}, 3)\n end\n end",
"def index\n \n @user = User.find(current_user.id) \n\n respond_to do |format|\n format.html { render action: \"show\" }\n format.json { render json: @user }\n end\n end",
"def show\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @user }\n end\n end",
"def get_user(user_id:)\n parse(JSON.parse(connection.get(\"users/#{user_id}\").body))\n end",
"def index\n user= User.all\n render json: {users:user}\n end",
"def index\r\n users = User.all\r\n render json: users\r\n end",
"def show\n # puts params[:id]\n render json: User.find(params[:id])\n end",
"def get_user_info\n id = params[\"id\"]\n error_list = []\n status = 1\n json_response = {}\n user = User.find_by(id: id)\n\n if user.nil?\n error_list.append(\"Error: The specified user doesn't exist.\")\n status = -1\n else\n json_response[\"user\"] = user.get_user_json_data\n end\n\n if status == -1\n json_response[\"errors\"] = error_list\n end\n\n json_response[\"status\"] = status\n\n # Format the json_response into proper JSON and respond with it\n json_response = json_response.to_json\n\n respond_to do |format|\n format.json { render json: json_response }\n end\n end",
"def show\n @user = User.find(params[:id])\n if @user\n render json: {\n user: @user\n }\n else\n render json: {\n status: 500,\n errors: ['user not found']\n }\n end\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def show\n @user = User.find(params[:id])\n render json: {\n username: @user.username,\n first_name: @user.first_name,\n last_name: @user.last_name,\n email: @user.email,\n phone_number: @user.phone_number,\n contacts: @user.contacts\n }, status: :ok\n end",
"def get_user(user_id)\n request(Route.new(:GET, '/users/%{user_id}', user_id: user_id))\n end",
"def show\n @user = User.find(params[:id])\n render 'api/v1/users/show'\n end",
"def index\n users = User.all\n\n render json: users, each_serializer: Api::V1::UsersSerializer\n end",
"def index\n users = User.all\n render json: users \n end",
"def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end",
"def index\n users = User.all \n render json: users \n end",
"def list\r\n users = User.all\r\n render json: users\r\n end",
"def json_show_user_profile_by_user_id\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.json { render json: @user.as_json(only:[:email,:username]) }\n end\n end",
"def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend",
"def show\n user = User.find_by(uid: params[:id])\n if user\n puts 'USER FOUND'\n render json: user\n else\n puts 'NO USER'\n render json: 'no user'.to_json\n end\n end",
"def show\n render json: UserService.get_user(params[:id]), includes: 'questions, answers'\n end",
"def index\n @users = User.all(limit: 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users.as_json(user: current_user) }\n end\n end",
"def index\n render :json => User.all, status: 200\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users, status: :ok\n end",
"def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n @users = User.all\n\n render json: @users\n end"
] |
[
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.72222257",
"0.72165024",
"0.72137505",
"0.72096044",
"0.71930283",
"0.7182953",
"0.7182144",
"0.7182144",
"0.7180289",
"0.71750754",
"0.7173851",
"0.71640617",
"0.71636444",
"0.71453786",
"0.7145053",
"0.7129776",
"0.71256554",
"0.71160513",
"0.7095665",
"0.70941204",
"0.70772994",
"0.7070785",
"0.7070607",
"0.7063351",
"0.70552826",
"0.7025071",
"0.7014598",
"0.70047677",
"0.6998373",
"0.69910055",
"0.6984177",
"0.6979766",
"0.6972448",
"0.6972228",
"0.6968384",
"0.69666255",
"0.6956339",
"0.69506294",
"0.6945614",
"0.6943135",
"0.69351804",
"0.6932212",
"0.6932212",
"0.6932212",
"0.6932212",
"0.6927094",
"0.69255126",
"0.6925136",
"0.6917375",
"0.6907744",
"0.68947464",
"0.6882589",
"0.6875701",
"0.68749416",
"0.68633634",
"0.6861618",
"0.6858055",
"0.6855495",
"0.68530583",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.6849599",
"0.6847195",
"0.6847074",
"0.6847074"
] |
0.0
|
-1
|
DELETE /users/1 DELETE /users/1.json
|
def destroy
redirect_back fallback_location: root_path unless current_user_admin?
@team.destroy
respond_to do |format|
format.html { redirect_back fallback_location: users_url, notice: 'User was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\"])\n end",
"def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = V1::User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n \"\"\"\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n \"\"\"\n end",
"def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n format.json { head :no_content }\n end",
"def destroy\n user = User.find(params[:id]) # from url, nothing to do with table\n user.destroy\n render json: user\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find_by_id_or_username params[:id]\n @user.destroy\n render api_delete @user\n end",
"def destroy\n @user = user.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def delete_user\n @user = User.find(params[:id])\n if @user.destroy\n render :json => @user\n else\n render :json => @user.errors.full_messages\n end\n end",
"def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.78750724",
"0.77518034",
"0.7713981",
"0.7610077",
"0.747295",
"0.74073994",
"0.74073994",
"0.7369968",
"0.7346072",
"0.7340465",
"0.7328618",
"0.7309635",
"0.73095363",
"0.7306841",
"0.7297868",
"0.72917855",
"0.7291585",
"0.7289111",
"0.7284347",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7245172",
"0.7242216",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177"
] |
0.0
|
-1
|
Key should be unique, or latest element with that key will override previous ones.
|
def hash_by(key = nil, method = nil, &block)
self.inject({}) do |h, element|
if key
h[element.send(key)] = if block_given?
yield(element)
elsif method
element.send(method)
else
element
end
else # key is block and value is element
h[yield(element)] = element
end
h
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_last_key_as_key\n LAST_VALUE_WINS.each {|key| @hash[key] = @hash[key].last}\n end",
"def keep(key=nil)\n if key\n @next[key] = @now[key]\n else\n @next.merge!(@now)\n end\n end",
"def key=(_); end",
"def key=(_); end",
"def unique_entries_by_(key) \n seen = Set.new()\n entries.select { |e|\n k = e.send(key)\n seen.add?(k)\n }.sort{|a, b| a.range.low <=> b.range.low }\n end",
"def key=(key); end",
"def insert(key)\n @keys << key\n swim(@keys.length - 1)\n end",
"def new_key(old_key)\n key_store[old_key] || old_key\n end",
"def [](key)\n if item = super\n return lru_touch(item)\n end\n end",
"def unique\n self['unique']\n end",
"def rekey_as_needed; end",
"def set_key\n last_key = Issue.find_by_sql('select max(issueId) as maxid from issue')[0].maxid\n self.issueId = last_key.to_i + 1\n end",
"def next_event_key\n flush_updates\n key, _ = queue.pop\n key\n end",
"def supports_unique_keys?\n false\n end",
"def last\n _id, entry = @redis.xrevrange(key, '+', '-', count: 1).first\n entry\n end",
"def updateKey; @key = getKey; self end",
"def last_id\n # hashs are ordered, so just return the latest entry\n @entries.keys.last\n end",
"def my_unique\n dict = Hash.new(false)\n self.each_with_index do |el, idx|\n self[idx] = nil if dict[el]\n dict[el] = true\n end\n self.compact!\n end",
"def reserve_key(key); end",
"def append_uniq!(weekly, key, element)\n weekly[key] = (weekly[key] << element).flatten.uniq\n end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def create_unique_key\n begin\n self.unique_key = UrlShort.generate_key\n rescue ActiveRecord::RecordNotUnique\n if (count +=1) < 5\n retry\n else\n raise\n end\n end\n end",
"def attr_dirty!(key)\n @dirty_attribute_keys ||= []\n @dirty_attribute_keys << key.to_sym\n @dirty_attribute_keys.uniq!\n end",
"def _key\n @_key || self.class.key.(self)\n end",
"def [] key\n @internal_hash[key].last\n end",
"def find_distinct_item(current_list, last_list, key)\n if current_list.size == last_list.size + 1\n unique_values = current_list.map { |item| item[key] } - last_list.map { |item| item[key] }\n if unique_values.size == 1\n unique_value = unique_values[0]\n return current_list.find { |item| item[key] == unique_value }\n end\n end\n return nil\n end",
"def stored_data_last_key\n stored_data.keys.sort.last || nil\n end",
"def key\n refresh_key unless key_valid?\n @key\n end",
"def save_to_most_recent_list\n # potentially, really slow dupe checking\n most_recent_identity = self.class.redis_most_recent_list_identity\n unless $redis.lrange(most_recent_identity, 0, $redis.llen(most_recent_identity)).include? identity\n $redis.lpush(most_recent_identity, identity)\n end\n end",
"def remove_element(arr, key)\n next_element = 0\n\n for i in 0..(arr.length - 1) \n if arr[i] != key\n arr[next_element] = arr[i]\n next_element += 1\n end\n\n end\n return next_element\nend",
"def last \n\t\tlast = @hash.last\n\t\t[last.key, last.value]\n\tend",
"def key(name)\n @unique_key = name\n end",
"def set_key\n last_key = User.find_by_sql('select max(userId) as maxid from user')[0].maxid\n self.userId = last_key.to_i + 1\n end",
"def unique_key? object\n _check = self.find(object.key)\n _unique = !_check || _check != object\n end",
"def last_id(key, id = nil)\n ids = $configure[:twitter][:last_ids] || {}\n current_id = ids[key]\n # Save last id if id is passed\n ids[key] = id if id\n $configure[:twitter][:last_ids] = ids;\n current_id\nend",
"def [](key)\n i = 1\n desired_index = index(key, size)\n while @items[desired_index].key != key\n desired_index += i**2\n i += 1\n end\n\n return @items[desired_index].value\n end",
"def unique_id\n # check all_data instead of data, as we have to not reuse deleted key\n ids = Set.new(all_data.map { |e| e[:key] })\n id = 1\n loop do\n return id.to_s unless ids.include?(id.to_s)\n id += 1\n end\n end",
"def [] key\n if @table[hash_index(key)]\n detected_item = @table[hash_index(key)].detect do |item|\n item.first == key\n end\n detected_item.last\n end\n end",
"def key=(new_key)\n @key = new_key\n end",
"def <=>(other)\n @Key <=> other.hash\n end",
"def [](key)\n super(key) or super(alternate_key(key))\n end",
"def add( key_file )\n @key_files.push( key_file ).uniq!\n self\n end",
"def has_key? key\n (self.class.order + @order).include? key\n end",
"def remove(key); end",
"def remove(key)\n\n end",
"def unique_key\n @unique_key ||= section.identifier\n end",
"def put(key, value)\n \txk = key % 10001 \n xk = (xk + 1) % 10001 while @arr[xk].first != nil && @arr[xk].first != key \n @arr[xk] = [key, value] \n end",
"def assign_key!\n key = \"\"\n #in case wasnt stripped before\n name = self.name.strip\n if name.length > 2\n key += name[0..2]\n else\n key += name\n end\n key += (self.team_id % 10).to_s\n key += rand(10).to_s\n\n #avoid duplicates\n while Player.exists?(key: key)\n key += rand(10).to_s\n end\n\n self.update_attribute(:key ,key)\n end",
"def update_map!(key)\n @map.set(key, @store.last)\n end",
"def [](key)\r\n assert_exists\r\n arr_rows = rows\r\n return arr_rows[key - 1]\r\n end",
"def duplicate(new_key_label)\n connection.zunionstore(new_key_label, [key_label]) if exists?\n end",
"def distinct(key)\n @collection.distinct(self, key)\n end",
"def autovivify( hash, key )\n\t\t\thash[ key ] = Hash.new( &Assemblage::DataUtilities.method(:autovivify) )\n\t\tend",
"def key\n self.keys.first\n end",
"def inc(key)\n \n end",
"def initialize\n @current_key = 0\n end",
"def id\n key = self.key\n key.first if key.size == 1\n end",
"def check_key2\n while @key2 == @key1\n @key2 = 1 + rand(6)\n end\n end",
"def incr(key); end",
"def incr(key); end",
"def delete(key)\n @succ.delete key\n end",
"def add_content_key content_key\n return unless content_key\n self.transaction do\n content_key = content_key.versions.latest if ContentKey === content_key\n raise ArgumentError, \"Expected ContentKey or ContentKey::Version\" unless ContentKey::Version === content_key\n\n save! unless self.id\n\n # Dont add if it's already been added.\n return if content_key_versions.find(:first, :conditions => [ 'content_key_id = ?', content_key ])\n\n connection.\n execute(\"DELETE FROM revision_list_content_keys \n WHERE revision_list_id = #{self.id}\n AND content_key_version_id IN\n (SELECT id FROM content_key_versions WHERE content_key_id = #{content_key.content_key.id})\"\n )\n revision_list_content_keys.create!(:content_key_version => content_key)\n\n # Invalidate association caches.\n revision_list_content_keys.reset\n content_key_versions.reset\n end\n self\n end",
"def set_unique_random_key(len = 16)\n begin\n chars = ('a'..'z').to_a + ('A'..'Z').to_a\n self.key = (0..(len-1)).collect { chars[Kernel.rand(chars.length)] }.join\n end while Key.find_by_key(self.key)\n end",
"def get_single_key(key)\n key = @size+key if key < 0\n r = @results[key]\n unless r.nil? && key < @size\n r\n else\n retrieve_for_index(key)\n @results[key]\n end\n end",
"def pop_last\n @driver_instance.pop_list_last(@key)\n end",
"def unique=(val)\n self['unique'] = val\n end",
"def key\n @keys.last or raise \"No key specified for collectible! (#{__FILE__}, #{__LINE__})\"\n end",
"def key\n # The counter is always 1 ahead.\n @counter - 1\n end",
"def append!(key, value); end",
"def append!(key, value); end",
"def random_key\n key_index.keys.sort_by{rand}.first\n end",
"def snapshot_key\n # no-op\n end",
"def latest_key\n key = Habit.get_progress_key_from(Date.today)\n initialize_progress_hash_from(key) if progress[key].nil?\n key\n end",
"def set_key\n self.key = SecureRandom.urlsafe_base64(KEY_LENGTH)\n self.set_key if Url.exists?(key: self.key)\n end",
"def decr(key); end",
"def decr(key); end",
"def lru_update(key)\n @lru.unshift(@lru.delete(key)|| key)\n end",
"def get(key)\n idx, bucket = find_bucket_and_index(key)\n idx ? bucket[idx].last : -1\n end",
"def delete(key)\n\t\t\t\t[self, self, false]\n\t\t\tend",
"def make_most_recent(el)\n el_idx = @cache.find_index(el)\n (el_idx + 1...count).each do |i|\n @cache[i - 1] = @cache[i]\n end\n @cache[count - 1] = el\n end",
"def set_retrieval_key\n base = rand(KEY_POOL_SIZE)\n first_digit = (base / (KEY_POOL_SIZE / 10)).to_i\n remainder = base % (KEY_POOL_SIZE / 10)\n\n self.retrieval_key = first_digit.to_s + rand(1000000000).to_s(36)\n if self.class.find_by_retrieval_key(retrieval_key)\n # that one is already used - go get another\n set_retrieval_key\n end\n end",
"def change_key(key, new_key, delete=false)\n return if @stored[key].nil? || @stored[key].empty? || (key == new_key)\n \n # Must maintain heap property\n raise \"Changing this key would not maintain heap property!\" unless (delete || @compare_fn[new_key, key])\n node = @stored[key].shift\n if node\n node.key = new_key\n @stored[new_key] ||= []\n @stored[new_key] << node\n parent = node.parent\n if parent\n # if heap property is violated\n if delete || @compare_fn[new_key, parent.key]\n cut(node, parent)\n cascading_cut(parent)\n end\n end\n if delete || @compare_fn[node.key, @next.key]\n @next = node\n end\n return [node.key, node.value]\n end\n nil\n end"
] |
[
"0.63506514",
"0.6293354",
"0.6109742",
"0.6109742",
"0.6037267",
"0.59949595",
"0.5844275",
"0.58176625",
"0.5816397",
"0.5796087",
"0.5796047",
"0.5768431",
"0.57432157",
"0.5669472",
"0.56666476",
"0.5666283",
"0.5628228",
"0.5625613",
"0.5605319",
"0.55553097",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.5553123",
"0.55503315",
"0.55438477",
"0.5527571",
"0.55220544",
"0.5497513",
"0.549536",
"0.54863745",
"0.54488313",
"0.5447487",
"0.54373837",
"0.5433677",
"0.5429216",
"0.54165035",
"0.5410828",
"0.5409085",
"0.53836083",
"0.53493667",
"0.5348581",
"0.5336539",
"0.5302316",
"0.529908",
"0.52984697",
"0.5294363",
"0.52938014",
"0.5293235",
"0.5282016",
"0.5257449",
"0.5256745",
"0.52432317",
"0.5241111",
"0.52377456",
"0.52242297",
"0.5221973",
"0.52162415",
"0.5202764",
"0.52004844",
"0.51933956",
"0.5192848",
"0.5192848",
"0.5179653",
"0.5176472",
"0.51758766",
"0.5163607",
"0.5154506",
"0.51536703",
"0.5153663",
"0.5151991",
"0.51512843",
"0.51512843",
"0.5141313",
"0.5141037",
"0.51364607",
"0.512966",
"0.5128019",
"0.5128019",
"0.51248604",
"0.51139027",
"0.5108855",
"0.5107769",
"0.5105215",
"0.50980145"
] |
0.0
|
-1
|
GET /espetaculos GET /espetaculos.json
|
def index
@espetaculos = Espetaculo.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end",
"def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end",
"def index\n @pedidos = Pedido.find(:all, :conditions => [\"cliente_id=?\", session[:usuario_id]])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pedidos }\n end\n end",
"def index\n @ativo_outros = AtivoOutro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ativo_outros }\n end\n end",
"def index\n @expedientes = Expediente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expedientes }\n end\n end",
"def index\n @ordenes = Orden.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordenes }\n end\n end",
"def index\n @palestrantes = Palestrante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @palestrantes }\n end\n end",
"def index\n @antecedentes = Antecedente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @antecedentes }\n end\n end",
"def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end",
"def etiquetas_por_aluno\n logger.info(params)\n @etiquetas_aluno = Etiqueta.all.where(aluno_id: params[:aluno_id])\n respond_with @etiquetas_aluno\n end",
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def index\n @equipos = Equipo.all\n render json: @equipos, status: :ok\n end",
"def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end",
"def index\n @deporte_usuarios = DeporteUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deporte_usuarios }\n end\n end",
"def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def index\n @acuerdos = Acuerdo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acuerdos }\n end\n end",
"def index\n @establecimientos = Establecimiento.all\n respond_to do |format|\n format.json { \n\n if (params[:appkey].eql? appkey) #si el appkey es correcto\n\n ests = @establecimientos.map { |establecimiento| { :nombre_establecimiento => establecimiento.nombre, :id => establecimiento.id, \n :descripcion => establecimiento.descripcion, :longitud => establecimiento.longitud,\n :latitud => establecimiento.latitud, :direccion => establecimiento.direccion, :imagen => establecimiento.foto.url(:small),\n :eventos => establecimiento.eventos.map { |evento| { :nombre => evento.nombre } } } } \n render json: ests\n else\n render json: {:error => \"No autorizado\"}\n end\n\n\n\n }\n format.html { redirect_to :controller=>'login', :action=>'login' } #solo el app movil puede revisar toda la lista de establecimientos.\n end\n end",
"def index\n logement = Logement.find_by(id:params[:logement_id])\n equipement = logement.equi_securites[0].title\n equipements = logement.equi_securites[0]\n\n render json: {\n securites:equipement,\n fichier:equipements\n }\n end",
"def index\n @asociados = Asociado.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asociados }\n end\n end",
"def index\n @empresas = Empresa.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @empresas }\n end\n end",
"def index\n\n if params[:ventas_seguimiento]\n cliente_id = params[:ventas_seguimiento][:cliente_id]\n @ventas_seguimientos = Ventas::Seguimiento.where(\"cliente_id = ?\",cliente_id).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new(:cliente_id => cliente_id)\n else\n @ventas_seguimientos = Ventas::Seguimiento.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_seguimientos }\n end\n end",
"def index\n @coordenador_estagios = CoordenadorEstagio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @coordenador_estagios }\n end\n end",
"def index\n @propuestas = Propuesta.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @propuestas }\n end\n end",
"def index\n @conseilles = Conseille.all\n respond_to do |format|\n format.html\n format.json { render json: @conseilles}\n end\n end",
"def index\n @articulos = Articulo.where(\"tipo = 'articulo'\").order(\"created_at desc\") \n @noticias = Articulo.where(\"tipo = 'noticia' and mostrar_carrusel='1'\").order(\"created_at desc\").limit(3)\n @articulos = @articulos.page(params[:page]).per_page(5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articulos }\n end\n end",
"def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end",
"def index\n @mencions = Mencion.order(\"escuela_id\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mencions }\n end\n end",
"def index\n @pedidos = Pedido.find(:all,:conditions=> {:status => [0], :user_id => current_user.id})\n if @pedidos.count > 0\n @imagen_pedidos = @pedidos[0].imagen_pedidos\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imagen_pedidos }\n end\n else\n redirect_to pedidos_path, notice: 'No tiene pedidos pendientes'\n end\n end",
"def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end",
"def index\n @ordens = Orden.all\n render json: @ordens\n end",
"def index\n @acoes = Acao.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acoes }\n end\n end",
"def index\n @ultimo_grado_de_estudios = UltimoGradoDeEstudio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ultimo_grado_de_estudios }\n end\n end",
"def index\n @prueba_jsons = PruebaJson.all\n end",
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def index\n @socios = Socio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @socios }\n end\n end",
"def index\n @programa_de_interes = ProgramaDeIntere.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programa_de_interes }\n end\n end",
"def index\n @pacientes = Pacientes.all\n render json: @pacientes\n end",
"def index\n @finalidad_cultivos = FinalidadCultivo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @finalidad_cultivos }\n end\n end",
"def index\n @listes = Liste.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listes }\n end\n end",
"def index\n @territorios = Territorio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @territorios }\n end\n end",
"def index\n @himalayas ||= Himalaya.limit(10).order('id desc')\n @descuentos ||= Descuento.limit(10).order('id desc')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @himalayas }\n end\n end",
"def index\n @departamentos = Departamento.all\n\n render json: @departamentos\n end",
"def emergencias_en_curso\n @emergencies = Emergency.where(:estado => 'f')\n render json: @emergencies\n end",
"def index\n #@imovels = Imovel.all\n \n #Traz apenas os imoveis ativos\n # Isso vai no controller do cliente. Só os ativos aparecem\n #@imovels = Imovel.all.select { |i| i.ativo == true }\n \n @imovels = Imovel.paginate :page => params[:page], :order => 'created_at DESC', :per_page => 10\n \n # Mapa para guardar os valores das transacoes associadas a cada imovel.\n # key: imovel_id, value: lista com [0]:transacao, [1]: tipos, [2] responsavel\n @hash_informacoes_imoveis = Hash.new\n \n @imovels.each do |imovel|\n popular_imovel(imovel)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imovels }\n end\n end",
"def index\n @comprobantes = Comprobante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comprobantes }\n end\n end",
"def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end",
"def index\n @detalles = Detalle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @detalles }\n end\n end",
"def index\n @ventas = Venta.order(\"fecha desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas }\n end\n end",
"def get_modelos\n marca = Marca.find(params[:marca_id])\n @modelos = Modelo.of_marca(marca.id)\n\n render json: @modelos\n\n end",
"def index\n @projetos = Projeto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projetos }\n end\n end",
"def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end",
"def index\n seleccionarMenu(:juzgados)\n @juzgados = Juzgado.order(:ciudad_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @juzgados }\n end\n end",
"def index\n if params[:propietario]\n @usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n @negocios_propios = Usuario.find(params[:usuario_id]).negocios_propios\n render json: @negocios_propios,\n root: 'negocios_propios',\n each_serializer: NegocioPropioSerializer\n else\n @negocios = Negocio.all\n render json: @negocios\n end\n end",
"def index \n @lancamentorapido = Lancamentorapido.new \n @lancamentorapidos = Lancamentorapido.all\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lancamentorapidos }\n end\n end",
"def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def index\n @postos = Posto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postos }\n end\n end",
"def index\n @preparatoria_o_universidad_de_origens = PreparatoriaOUniversidadDeOrigen.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @preparatoria_o_universidad_de_origens }\n end\n end",
"def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end",
"def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end",
"def index\n @articulocomps = Articulocomp.all\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @articulocomps }\n end\n end",
"def index\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebitos = @notadedebito.renglon_notadebitos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_notadebitos }\n end\n end",
"def index\n @veiculos = Veiculo.all\n end",
"def index\n @tipo_usuarios = TipoUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_usuarios }\n end\n end",
"def index\n\t\texecutar_acoes\n\t\t@pontos = PontoInteresse.all.order(\"enable DESC, denuncias_count DESC, created_at DESC\").page(params[:page])\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @pontos }\n\t\tend\n\tend",
"def index\n @listas_contato = ListaContato.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listas_contato }\n end\n end",
"def index\n @curriculum_vitaes = findable_curriculum_vitaes.all\n respond_to do |format|\n format.html {}\n format.json { render json: @curriculum_vitaes }\n end\n end",
"def index\n @veterinarios = Veterinario.all\n end",
"def index\n @veterinarios = Veterinario.all\n end",
"def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n @archdioceses = Archdiocese.all\n\n render json: @archdioceses\n end",
"def index\n @assuntos = Assunto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assuntos }\n end\n end",
"def index\n @contas = Conta.all\n respond_to do |format|\n format.json { render json: @contas.to_json, status: :ok }\n end\n end",
"def index\n @cadavres = Cadavre.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cadavres }\n end\n end",
"def index\n @comentario_egresados = ComentarioEgresado.all\n end",
"def show\n @escola = Escola.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @escola }\n end\n end",
"def index\n @seguridad_usuarios = Seguridad::Usuario.order('usuario')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seguridad_usuarios }\n end\n end",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\n end\n end",
"def index\n @deportes = Deporte.all\n render json: @deportes, status: :ok \n @deportes = Deporte.paginate(:page => params[:page])\n end",
"def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end",
"def index\n seleccionarMenu(:rondas)\n @rondas = Ronda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rondas }\n end\n end",
"def index\n @ivas = Iva.all\n\n render json: @ivas\n end",
"def show\n @competicao = Competicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competicao }\n end\n end",
"def index\n @factura = Factura.find(params[:factura_id])\n @renglon_facturas = @factura.renglon_facturas\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @renglon_facturas }\n end\n end",
"def index\n @premios = Premio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @premios }\n end\n end",
"def index\n @reprogramaciones = Reprogramacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reprogramaciones }\n end\n end",
"def index\n @sesions = Sesion.where(entidad_paraestatal_id: @entidad_paraestatal.id).all\n @suplente = Suplente.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sesions }\n end\n end",
"def index\n @ejemplos = Ejemplo.all\n end",
"def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end",
"def show\n\n @evento = Evento.find(params[:id])\n @comentarios = Comentario.where(:comentavel_id => @evento.id, :comentavel_type => \"Evento\").order('created_at DESC')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evento }\n end\n end",
"def index\n @enderecos = Endereco.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enderecos }\n end\n end",
"def index\n @foros = Foro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foros }\n end\n end",
"def index\n @pecas = Peca.find :all, :order => :produto_id\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pecas }\n end\n end",
"def index\n @peds = Ped.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peds }\n end\n end",
"def lista_estoque()\n @client.get(Route.new([ROTA_DID_ESTOQUE]))\n end",
"def index\n render json: @fiestas\n end",
"def index\n \t\tif params[:usuario_pedido]\n \t\t\t@usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n \t\t\t@usuario.pedidos.reload\n \t\t\trender json: @usuario.pedidos\n \t\telse\n \t\t\t@negocio = Negocio.find(params[:negocio_id])\n authorize! :update, @negocio\n \t\t@negocio.pedidos.reload\n \t\trender json: @negocio.pedidos\n \t\tend\n \tend",
"def estaciones\n\n param_estacion = params[:estacion]\n param_fecha = params[:fecha].to_i\n @info_polens = InfoPolen.where({\"ESTACIONES\" => param_estacion, \"FECHA\" => param_fecha}).order_by(:TIPOS_POLINICOS.asc)\n\n respond_to do |format|\n format.html #{ redirect_to info_polens_url }\n format.json { render json: @info_polens }\n end\n end"
] |
[
"0.73197955",
"0.707102",
"0.7012849",
"0.70035964",
"0.69860023",
"0.6959708",
"0.6896149",
"0.68805957",
"0.68773",
"0.6872416",
"0.68637776",
"0.68292385",
"0.68221456",
"0.6804849",
"0.67870945",
"0.6777491",
"0.67687154",
"0.6729278",
"0.6728037",
"0.6724299",
"0.6700408",
"0.66940355",
"0.6693258",
"0.6686459",
"0.6682995",
"0.6678699",
"0.6673262",
"0.66476965",
"0.66472065",
"0.6642125",
"0.66419405",
"0.66332984",
"0.6630419",
"0.66273075",
"0.6609603",
"0.6608711",
"0.6602773",
"0.6601673",
"0.6597056",
"0.65933746",
"0.6592383",
"0.65858775",
"0.65752995",
"0.6568461",
"0.65675217",
"0.6563446",
"0.6555821",
"0.6552147",
"0.6550826",
"0.65455025",
"0.65435636",
"0.653871",
"0.65378845",
"0.65353096",
"0.6532231",
"0.6530028",
"0.6527484",
"0.6526015",
"0.652553",
"0.6525067",
"0.6520903",
"0.6516434",
"0.65095085",
"0.65089375",
"0.6507328",
"0.6491215",
"0.6465152",
"0.6464956",
"0.64643157",
"0.6463155",
"0.6463155",
"0.6461996",
"0.64596343",
"0.64548206",
"0.64527327",
"0.6448221",
"0.64277154",
"0.64235866",
"0.6422742",
"0.6413909",
"0.6407011",
"0.64045215",
"0.6404406",
"0.64022857",
"0.6396086",
"0.63940597",
"0.6388074",
"0.6384353",
"0.638429",
"0.6376901",
"0.63753605",
"0.6366484",
"0.636546",
"0.63551176",
"0.6353208",
"0.63514245",
"0.63511044",
"0.635039",
"0.63503695",
"0.63470685"
] |
0.69549066
|
6
|
GET /espetaculos/1 GET /espetaculos/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def index\n @pedidos = Pedido.find(:all, :conditions => [\"cliente_id=?\", session[:usuario_id]])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pedidos }\n end\n end",
"def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end",
"def show\n @competicao = Competicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competicao }\n end\n end",
"def show\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @peso }\n end\n end",
"def index\n @palestrantes = Palestrante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @palestrantes }\n end\n end",
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def index\n logement = Logement.find_by(id:params[:logement_id])\n equipement = logement.equi_securites[0].title\n equipements = logement.equi_securites[0]\n\n render json: {\n securites:equipement,\n fichier:equipements\n }\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def index\n\n if params[:ventas_seguimiento]\n cliente_id = params[:ventas_seguimiento][:cliente_id]\n @ventas_seguimientos = Ventas::Seguimiento.where(\"cliente_id = ?\",cliente_id).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new(:cliente_id => cliente_id)\n else\n @ventas_seguimientos = Ventas::Seguimiento.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_seguimientos }\n end\n end",
"def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end",
"def index\n @antecedentes = Antecedente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @antecedentes }\n end\n end",
"def show\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @veiculo }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def index\n @ativo_outros = AtivoOutro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ativo_outros }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tecnico }\n end\n end",
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def index\n @expedientes = Expediente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expedientes }\n end\n end",
"def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end",
"def index\n @pedidos = Pedido.find(:all,:conditions=> {:status => [0], :user_id => current_user.id})\n if @pedidos.count > 0\n @imagen_pedidos = @pedidos[0].imagen_pedidos\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imagen_pedidos }\n end\n else\n redirect_to pedidos_path, notice: 'No tiene pedidos pendientes'\n end\n end",
"def index\n @propuestas = Propuesta.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @propuestas }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comentario }\n end\n end",
"def show\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comentario }\n end\n end",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def show\n @asiento = Asiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @asiento }\n end\n end",
"def show\n @escola = Escola.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @escola }\n end\n end",
"def index\n @asociados = Asociado.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asociados }\n end\n end",
"def show\n @descuento = Descuento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @descuento }\n end\n end",
"def index\n @acuerdos = Acuerdo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acuerdos }\n end\n end",
"def index\n @programa_de_interes = ProgramaDeIntere.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programa_de_interes }\n end\n end",
"def index\n @ordenes = Orden.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordenes }\n end\n end",
"def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n @equipos = Equipo.all\n render json: @equipos, status: :ok\n end",
"def index\n @socios = Socio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @socios }\n end\n end",
"def index\n @articulos = Articulo.where(\"tipo = 'articulo'\").order(\"created_at desc\") \n @noticias = Articulo.where(\"tipo = 'noticia' and mostrar_carrusel='1'\").order(\"created_at desc\").limit(3)\n @articulos = @articulos.page(params[:page]).per_page(5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articulos }\n end\n end",
"def index\n @conseilles = Conseille.all\n respond_to do |format|\n format.html\n format.json { render json: @conseilles}\n end\n end",
"def show\n @competency_pertenece_asignatura = CompetencyPerteneceAsignatura.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competency_pertenece_asignatura }\n end\n end",
"def index\n @projetos = Projeto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projetos }\n end\n end",
"def show\n @expediente = Expediente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expediente }\n end\n end",
"def show\n @ejercicio = Ejercicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ejercicio }\n end\n end",
"def index\n @pacientes = Pacientes.all\n render json: @pacientes\n end",
"def index\n @mencions = Mencion.order(\"escuela_id\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mencions }\n end\n end",
"def show\n @sezione = Sezione.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sezione }\n end\n end",
"def show\n @estatuto = Estatuto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estatuto }\n end\n end",
"def index\n @comprobantes = Comprobante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comprobantes }\n end\n end",
"def show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegio }\n end\n end",
"def show\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @servicio }\n end\n end",
"def index\n @prueba_jsons = PruebaJson.all\n end",
"def show\n @estacionamiento = Estacionamiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estacionamiento }\n end\n end",
"def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n @deporte_usuarios = DeporteUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deporte_usuarios }\n end\n end",
"def index\n @premios = Premio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @premios }\n end\n end",
"def show\n pessoa = Pessoa.find(params[:id])\n render json: {status: 'SUCCESS', message:'Loaded pessoa', data:pessoa},status: :ok\n end",
"def show\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estudiante }\n end\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def show\n @ventas_seguimiento = Ventas::Seguimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_seguimiento }\n end\n end",
"def index\n @territorios = Territorio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @territorios }\n end\n end",
"def index\n @acoes = Acao.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acoes }\n end\n end",
"def show\n @espacio_deportivo = EspacioDeportivo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @espacio_deportivo }\n end\n end",
"def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end",
"def index\n @ultimo_grado_de_estudios = UltimoGradoDeEstudio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ultimo_grado_de_estudios }\n end\n end",
"def index\n @detalles = Detalle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @detalles }\n end\n end",
"def show\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguro }\n end\n end",
"def show\n @cargo_eleicao = CargoEleicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cargo_eleicao }\n end\n end",
"def show\n @serv_adicionale = ServAdicionale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @serv_adicionale }\n end\n end",
"def show\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leito }\n end\n end",
"def index\n @ventas = Venta.order(\"fecha desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas }\n end\n end",
"def index\n @articulocomps = Articulocomp.all\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @articulocomps }\n end\n end",
"def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def index\n @espetaculos = Espetaculo.all\n end",
"def show\n @pedido = Pedido.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pedido }\n end\n end",
"def show\n @contato_produto = ContatoProduto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contato_produto }\n end\n end",
"def index\n @empresas = Empresa.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @empresas }\n end\n end",
"def show\n @cuerpo = Cuerpo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cuerpo }\n end\n end",
"def index\n @himalayas ||= Himalaya.limit(10).order('id desc')\n @descuentos ||= Descuento.limit(10).order('id desc')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @himalayas }\n end\n end",
"def show\n @selecao = Selecao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @selecao }\n end\n end",
"def index\n @assuntos = Assunto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assuntos }\n end\n end",
"def index\n @departamentos = Departamento.all\n\n render json: @departamentos\n end",
"def show\n @indicativo = Indicativo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicativo }\n end\n end",
"def index\n @postos = Posto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postos }\n end\n end",
"def show\n @etnia = Etnia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @etnia }\n end\n end",
"def index\n @factura = Factura.find(params[:factura_id])\n @renglon_facturas = @factura.renglon_facturas\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @renglon_facturas }\n end\n end",
"def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end",
"def show\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end",
"def show\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end",
"def show\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end",
"def show\n @publicaciones = Publicacione.find(params[:id])\n render json: @publicaciones, status: :ok\n end",
"def show\n @asociado = Asociado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asociado }\n end\n end",
"def index\n @contato_produtos = ContatoProduto.all.sort! { |a,b| b.id <=> a.id }\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contato_produtos }\n end\n end",
"def index\n @coordenador_estagios = CoordenadorEstagio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @coordenador_estagios }\n end\n end",
"def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end"
] |
[
"0.71828324",
"0.7129391",
"0.7080003",
"0.69654024",
"0.6957459",
"0.6928289",
"0.6901657",
"0.6865806",
"0.6858262",
"0.68564427",
"0.68108535",
"0.6796217",
"0.6796217",
"0.67897296",
"0.6789541",
"0.67799556",
"0.67792886",
"0.67768127",
"0.67747325",
"0.6771862",
"0.6754131",
"0.6749523",
"0.6748993",
"0.67435116",
"0.6736323",
"0.67092896",
"0.67019665",
"0.6694939",
"0.6694939",
"0.6690683",
"0.6677417",
"0.6670671",
"0.66659385",
"0.6664662",
"0.6661194",
"0.6659631",
"0.6650375",
"0.664524",
"0.66442996",
"0.6644106",
"0.6634194",
"0.6631314",
"0.6628361",
"0.6623748",
"0.6622282",
"0.66210276",
"0.6619113",
"0.66157395",
"0.66092527",
"0.6602531",
"0.65979797",
"0.6596308",
"0.65951586",
"0.6590907",
"0.6589041",
"0.6587616",
"0.6584975",
"0.65836245",
"0.6580926",
"0.6577717",
"0.6576099",
"0.65742123",
"0.65742123",
"0.65727013",
"0.65694606",
"0.6566093",
"0.6561639",
"0.65509295",
"0.6549638",
"0.6547919",
"0.6542794",
"0.65379626",
"0.65340394",
"0.6531496",
"0.653017",
"0.652627",
"0.6523435",
"0.65178376",
"0.65178376",
"0.6516698",
"0.651206",
"0.6510954",
"0.6508385",
"0.6502269",
"0.650154",
"0.6501445",
"0.6501408",
"0.64977413",
"0.648781",
"0.6484615",
"0.6483641",
"0.6481049",
"0.6480679",
"0.6476858",
"0.6476858",
"0.6476858",
"0.64678854",
"0.6466122",
"0.6465665",
"0.6465199",
"0.6459515"
] |
0.0
|
-1
|
POST /espetaculos POST /espetaculos.json
|
def create
@espetaculo = Espetaculo.new(espetaculo_params)
respond_to do |format|
if @espetaculo.save
format.html { redirect_to @espetaculo, notice: 'Espetaculo was successfully created.' }
format.json { render :show, status: :created, location: @espetaculo }
else
format.html { render :new }
format.json { render json: @espetaculo.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def troca\n @remetente = Sobrevivente.where(id: params[:de]).first\n @destinatario = Sobrevivente.where(id: params[:para]).first\n\n enviar = {agua: 1, comida: 2, medicamento: 3, municao: 4}\n receber = {agua: 0, comida: 2, medicamento: 3, municao: 8}\n\n trocou = @remetente.troca(@destinatario, enviar, receber)\n\n render json: { status: trocou }\n end",
"def create\n @estatuto = Estatuto.new(params[:estatuto])\n\n respond_to do |format|\n if @estatuto.save\n format.html { redirect_to @estatuto, notice: 'Estatuto was successfully created.' }\n format.json { render json: @estatuto, status: :created, location: @estatuto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estatuto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @asiento = Asiento.new(params[:asiento])\n\n respond_to do |format|\n if @asiento.save\n format.html { redirect_to @asiento, :notice => 'El apunte fue creado.' }\n format.json { render :json => @asiento, :status => :created, :location => @asiento }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @asiento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n# TODO ESTA HECHO UNA PORQUERIAAAAAAAAAA\n# base de datos\n @peticion = Peticion.new \n @peticion.solicitudrecurso_id=session[:ident] # params[:solicitudrecurso_id].to_s\n @peticion.diasemana=params[:diasemana]\n @peticion.horaini=params[:horaini]\n @peticion.horafin=params[:horafin]\n#carro\n @peticion=Solicitud.new\n #@peticion.solicitudrecurso_id=session[:ident] # params[:solicitudrecurso_id].to_s\n @peticion.diasemana=params[:diasemana]\n @peticion.horaini=params[:horaini]\n @peticion.horafin=params[:horafin]\n session[:tramos_horarios].solicitudes<<@peticion\n @pet=Solicitud.new\n #@peticion.solicitudrecurso_id=session[:ident] # params[:solicitudrecurso_id].to_s\n @pet.diasemana=params[:diasemana]\n @pet.horaini=params[:horaini]\n @pet.horafin=params[:horafin]\n\n\n\n# AHORA HAY QUE AÑADIR PETICION AL CARRO Y YA ESTA, RECARGAR LA VISION DE LOS TRAMOS CON AJAX\n# PERO EN EL CONTROLLER DE SOLICITUD!!!!!!!! A VER COMO HAGO EL CORTOCIRCUITO RECORDAR EL RETURNS-TO (LIBRO)\n\n session[:peticiones].solicitudes<<@pet # ACCION 6 AQUI ANADO EL TRAMO AL CARRO, LA SIGUIENTE EN SOLIC. CONTROLLER\n \n respond_to do |format|\n if @peticion.save\n \n @peticions=Peticion.all\n format.html { redirect_to(session[:direccion]) }\n format.xml { render :xml => @peticion, :status => :created, :location => @peticion }\n else\n \n format.html { render :action => \"new\" }\n format.xml { render :xml => @peticion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def create\n @etnia = Etnia.new(params[:etnia])\n\n respond_to do |format|\n if @etnia.save\n format.html { redirect_to @etnia, notice: 'Etnia was successfully created.' }\n format.json { render json: @etnia, status: :created, location: @etnia }\n else\n format.html { render action: \"new\" }\n format.json { render json: @etnia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @escola = Escola.new(params[:escola])\n\n respond_to do |format|\n if @escola.save\n format.html { redirect_to @escola, :notice => 'Escola was successfully created.' }\n format.json { render :json => @escola, :status => :created, :location => @escola }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @escola.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @responsavel = Responsavel.new(responsavel_params)\n\n if @responsavel.save\n render json: @responsavel, status: :created, location: @responsavel\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end",
"def create\n @establecimiento = Establecimiento.new(establecimiento_params)\n\n respond_to do |format|\n if @establecimiento.save\n format.html { redirect_to @establecimiento, notice: 'Establecimiento was successfully created.' }\n format.json { render :show, status: :created, location: @establecimiento }\n else\n format.html { render :new }\n format.json { render json: @establecimiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def espetaculo_params\n params.require(:espetaculo).permit(:nome, :atores, :diretor, :sonoplasta, :iluminador)\n end",
"def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully created.' }\n format.json { render :json => @tecnico, :status => :created, :location => @tecnico }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @estacionamiento = Estacionamiento.new(params[:estacionamiento])\n\n respond_to do |format|\n if @estacionamiento.save\n format.html { redirect_to @estacionamiento, notice: 'Estacionamiento was successfully created.' }\n format.json { render json: @estacionamiento, status: :created, location: @estacionamiento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estacionamiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comentario_egresado = ComentarioEgresado.new(comentario_egresado_params)\n\n respond_to do |format|\n if @comentario_egresado.save\n format.html { redirect_to @comentario_egresado, notice: 'Comentario egresado was successfully created.' }\n format.json { render :show, status: :created, location: @comentario_egresado }\n else\n format.html { render :new }\n format.json { render json: @comentario_egresado.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @apoio_educacioanl = ApoioEducacioanl.new(apoio_educacioanl_params)\n\n respond_to do |format|\n if @apoio_educacioanl.save\n format.html { redirect_to @apoio_educacioanl, notice: 'Apoio educacioanal foi cadastrado com Sucesso !' }\n format.json { render :show, status: :created, location: @apoio_educacioanl }\n else\n format.html { render :new }\n format.json { render json: @apoio_educacioanl.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ejercicio = Ejercicio.new(params[:ejercicio])\n\n respond_to do |format|\n if @ejercicio.save\n format.html { redirect_to @ejercicio, notice: 'Ejercicio was successfully created.' }\n format.json { render json: @ejercicio, status: :created, location: @ejercicio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ejercicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estacionamiento = Estacionamiento.new(estacionamiento_params)\n @lista_departamentos = Ubigeo.find_by_sql(\"select distinct idDepartamento, Departamento from ubigeos\")\n @lista_provincias = Ubigeo.find_by_sql(\"select distinct idProvincia, Provincia from ubigeos\")\n @lista_distritos = Ubigeo.find_by_sql(\"select distinct idDistrito, Distrito from ubigeos\")\n @serv_adicinales = ServAdicinale.all\n\n respond_to do |format|\n if @estacionamiento.save\n format.html { redirect_to @estacionamiento, notice: 'Estacionamiento was successfully created.' }\n format.json { render :show, status: :created, location: @estacionamiento }\n else\n format.html { render :new }\n format.json { render json: @estacionamiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @expediente = Expediente.new(params[:expediente])\n \n respond_to do |format|\n if @expediente.save\n format.html { redirect_to @expediente, notice: 'Expediente was successfully created.' }\n format.json { render json: @expediente, status: :created, location: @expediente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @expediente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @peticion = Peticion.new(peticion_params)\n\n respond_to do |format|\n if @peticion.save\n format.html { redirect_to @peticion, notice: 'Peticion was successfully created.' }\n format.json { render :show, status: :created, location: @peticion }\n else\n format.html { render :new }\n format.json { render json: @peticion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @etapa = Etapa.new(etapa_params)\n\n respond_to do |format|\n if @etapa.save\n format.html { redirect_to @etapa, notice: 'Etapa fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @etapa }\n else\n format.html { render :new }\n format.json { render json: @etapa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @laboratorio = Laboratorio.new(laboratorio_params)\n get_responsavel\n puts \"O responsavel é: #{@laboratorio.responsavel_id}\"\n if (@responsavel != \"sem_responsavel\")\n @laboratorio.docentes << Docente.find(@laboratorio.responsavel_id)\n puts \"Add relação entre #{@laboratorio.nome} e #{Docente.find(@laboratorio.responsavel_id).user.nome}\"\n end\n respond_to do |format|\n if @laboratorio.save\n format.html { redirect_to @laboratorio, notice: 'Laboratorio was successfully created.' }\n format.json { render :show, status: :created, location: @laboratorio }\n else\n format.html { render :new }\n format.json { render json: @laboratorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @objeto = DetallePedido.new(detalle_pedido_params)\n\n respond_to do |format|\n if @objeto.save\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Detalle pedido was successfully created.' }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_orcamento\n @produto = Produto.new(produto_params)\n\n respond_to do |format|\n if @produto.save\n format.html { redirect_to edit_produto_path(@produto), notice: '' }\n format.json { render :show, status: :created, location: @produto }\n else\n format.html { render :new }\n format.json { render json: @produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n respond_to do |format|\n if @especialidad.save\n format.html { redirect_to @especialidad, notice: 'Servicio creado exitosamente.' }\n format.json { render :show, status: :created, location: @especialidad }\n else\n format.html { render :new }\n format.json { render json: @especialidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render json: @respuesta, status: :created, location: @respuesta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def create\n params.permit(:intitule, :estObligatoire, :nombreDeCaractere, :ordre, :sondage_id)\n ajout = QuestionOuverteService.instance.creerQuestionOuverte(params[:intitule], params[:estObligatoire], params[:nombreDeCaractere], params[:ordre], params[:sondage_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end",
"def create\n @puesto = Puesto.new(puesto_params)\n\n respond_to do |format|\n if @puesto.save\n format.html { redirect_to @puesto, notice: 'Puesto Creado.' }\n format.json { render :show, status: :created, location: @puesto }\n else\n format.html { render :new }\n format.json { render json: @puesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @espacio_deportivo = EspacioDeportivo.new(params[:espacio_deportivo])\n\n respond_to do |format|\n if @espacio_deportivo.save\n format.html { redirect_to root_url, :notice => \"Se hizo correctamente la creacion del espacio deportivo\" }\n format.json { render json: @espacio_deportivo, status: :created, location: @espacio_deportivo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @espacio_deportivo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @competicao = Competicao.new(params[:competicao])\n\n respond_to do |format|\n if @competicao.save\n format.html { redirect_to @competicao, notice: 'Competicao was successfully created.' }\n format.json { render json: @competicao, status: :created, location: @competicao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @competicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @peso = Peso.new(params[:peso])\n\n respond_to do |format|\n if @peso.save\n format.html { redirect_to @peso, notice: 'Peso was successfully created.' }\n format.json { render json: @peso, status: :created, location: @peso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cargo_eleicao = CargoEleicao.new(params[:cargo_eleicao])\n\n respond_to do |format|\n if @cargo_eleicao.save\n format.html { redirect_to @cargo_eleicao, notice: 'Cargo eleicao was successfully created.' }\n format.json { render json: @cargo_eleicao, status: :created, location: @cargo_eleicao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cargo_eleicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #Parámetros permitidos.\n pago_params\n\n #Asignación de variables.\n fact = params[:pago][:factura_id]\n fecha = params[:pago][:fechapago]\n factura = Factura.find_by(id: fact)\n\n #Editar pago.\n @pago = Pago.new\n @pago.factura_id = fact\n @pago.fechapago = fecha\n @pago.monto = factura.total\n\n respond_to do |format|\n if @pago.save\n #Inserción en la cuenta corriente cliente por el haber.\n ctactecli = Ctactecli.find_by(cliente_id: factura.cliente_id)\n detallectactecli = Detallectactecli.new\n detallectactecli.ctactecli_id = factura.cliente_id\n detallectactecli.fechadetalle = Date.today\n detallectactecli.tipodetalle = 'Crédito por factura'\n detallectactecli.haber = factura.total\n detallectactecli.save\n ctactecli.saldo = ctactecli.saldo - factura.total\n ctactecli.save\n\n format.json { render :show, status: :created, location: @pago }\n puts'Pago guardado'\n #format.html { redirect_to @pago, notice: 'Pago was successfully created.' }\n else\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n puts'Pago no guardado'\n #format.html { render :new }\n end\n end\n end",
"def create\n @os_entregavel = OsEntregavel.new(os_entregavel_params)\n\n respond_to do |format|\n if @os_entregavel.save\n if @os_entregavel.ordem_servico.id!=nil\n format.html { redirect_to \"/os_entregavels/new?os_id=\"+@os_entregavel.ordem_servico.id.to_s, notice: 'Entregável criado com sucesso na O.S.' }\n format.json { render :show, status: :created, location: @os_entregavel }\n else\n format.html { redirect_to @os_entregavel, notice: 'Entregável criado com sucesso na O.S' }\n format.json { render :show, status: :created, location: @os_entregavel }\n end\n else\n format.html { render :new }\n format.json { render json: @os_entregavel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exemplaresproduto = Exemplaresproduto.new(exemplaresproduto_params)\n\n respond_to do |format|\n if @exemplaresproduto.save\n format.html { redirect_to @exemplaresproduto, notice: 'Exemplaresproduto was successfully created.' }\n format.json { render :show, status: :created, location: @exemplaresproduto }\n else\n format.html { render :new }\n format.json { render json: @exemplaresproduto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @anteproyecto_estudiante = AnteproyectoEstudiante.new(anteproyecto_estudiante_params)\n\n respond_to do |format|\n if @anteproyecto_estudiante.save\n format.html { redirect_to @anteproyecto_estudiante, notice: 'Anteproyecto estudiante was successfully created.' }\n format.json { render :show, status: :created, location: @anteproyecto_estudiante }\n else\n format.html { render :new }\n format.json { render json: @anteproyecto_estudiante.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @objeto = Etiqueta.new(etiqueta_params)\n\n respond_to do |format|\n if @objeto.save\n format.html { redirect_to @objeto, notice: 'Etiqueta was successfully created.' }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @oferta = Oferta.new(params[:oferta])\n\n respond_to do |format|\n if @oferta.save\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully created.' }\n format.json { render :json => @oferta, :status => :created, :location => @oferta }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, notice: 'Tecnico criado com sucesso.' }\n format.json { render json: @tecnico, status: :created, location: @tecnico }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @veterinario = Veterinario.new(veterinario_params)\n\n respond_to do |format|\n if @veterinario.save\n format.html { redirect_to @veterinario, notice: \"Veterinario was successfully created.\" }\n format.json { render :show, status: :created, location: @veterinario }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @veterinario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @equipo_torneos = EquiposTorneos.new(equipos_torneos_params)\n \n if @equipo_torneos.save\n \n else\n render json: @equipo_torneos.errors, status: :unprocessable_entity\n end\n end",
"def create\n #Parámetros permitidos.\n lectura_params\n\n #Asignación de variables.\n numero = params[:lectura][:numero].upcase\n actual = params[:lectura][:actual].to_i\n medidor = Medidor.find_by(numero: numero)\n periodo = Periodo.last\n consumominimo = Servicio.find_by(id: 1)\n\n #Cálculos.\n consumototal = actual - medidor.medicion\n consumototal = actual - medidor.medicion\n if consumototal > consumominimo.m3 then\n consumoexceso = consumototal - consumominimo.m3\n else\n consumoexceso = 0\n end\n\n #Editar lectura.\n @lectura = Lectura.new\n @lectura.cliente_id = medidor.cliente_id\n @lectura.periodo_id = periodo.id\n @lectura.fecha = Date.today\n @lectura.numero = numero\n @lectura.actual = actual\n @lectura.consumo = consumototal\n @lectura.exceso = consumoexceso\n\n #Guardar lectura.\n respond_to do |format|\n if @lectura.save\n medidor.medicion = actual\n medidor.save\n puts'Lectura guardada'\n format.json { render :show, status: :created, location: @lectura }\n #format.html { redirect_to @lectura, notice: 'La lectura fue creada.' }\n #format.js { }\n else\n puts'Lectura no guardada'\n format.json { render json: @lectura.errors, status: :unprocessable_entity }\n #format.html { render :new }\n end\n end\n end",
"def create\n @pedido = Pedido.new(pedido_params)\n\n respond_to do |format|\n if @pedido.save\n format.html { redirect_to @pedido, notice: t('.sucesso') }\n format.json { render :show, status: :created, location: @pedido }\n else\n format.html { render :new }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @descuento = Descuento.new(params[:descuento])\n\n respond_to do |format|\n if @descuento.save\n format.html { redirect_to @descuento, notice: 'Descuento was successfully created.' }\n format.json { render json: @descuento, status: :created, location: @descuento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topes_legale = TopesLegale.new(topes_legale_params)\n\n respond_to do |format|\n if @topes_legale.save\n format.html { redirect_to @topes_legale, notice: 'Tope legal creado exitosamente.' }\n format.json { render :show, status: :created, location: @topes_legale }\n else\n format.html { render :new }\n format.json { render json: @topes_legale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ejemplo = Ejemplo.new(ejemplo_params)\n\n respond_to do |format|\n if @ejemplo.save\n format.html { redirect_to @ejemplo, notice: 'Ejemplo was successfully created.' }\n format.json { render :show, status: :created, location: @ejemplo }\n else\n format.html { render :new }\n format.json { render json: @ejemplo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @asiento_de_servicio = AsientoDeServicio.new(asiento_de_servicio_params)\n\n respond_to do |format|\n if @asiento_de_servicio.save\n format.html { redirect_to @asiento_de_servicio, notice: 'Asiento de servicio was successfully created.' }\n format.json { render :show, status: :created, location: @asiento_de_servicio }\n else\n format.html { render :new }\n format.json { render json: @asiento_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ejercicio = Ejercicio.new(ejercicio_params)\n\n respond_to do |format|\n if @ejercicio.save\n format.html { redirect_to @ejercicio, notice: 'Ejercicio creado con exito..' }\n format.json { render :show, status: :created, location: @ejercicio }\n else\n format.html { render :new }\n format.json { render json: @ejercicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estadoproceso = Estadoproceso.new(estadoproceso_params)\n\n respond_to do |format|\n if @estadoproceso.save\n format.html { redirect_to @estadoproceso, notice: 'Estadoproceso was successfully created.' }\n format.json { render :show, status: :created, location: @estadoproceso }\n else\n format.html { render :new }\n format.json { render json: @estadoproceso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @selecao = Selecao.new(params[:selecao])\n\n respond_to do |format|\n if @selecao.save\n format.html { redirect_to @selecao, notice: 'Selecao was successfully created.' }\n format.json { render json: @selecao, status: :created, location: @selecao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @selecao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @veterinario = Veterinario.new(veterinario_params)\n\n respond_to do |format|\n if @veterinario.save\n format.html { redirect_to @veterinario, notice: 'Veterinario was successfully created.' }\n format.json { render :show, status: :created, location: @veterinario }\n else\n format.html { render :new }\n format.json { render json: @veterinario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts 'AQQQQQUUUUUUUIIIIII'\n json = ActiveSupport::JSON.decode(params[:pessoa])\n puts json\n @pessoa = Pessoa.new(json)\n # @address = Address.new(params[:address])\n\n # @client.addresses = @address\n\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to @pessoa, notice: 'Pessoa was successfully created.' }\n format.json { render json: @pessoa, status: :created, location: @pessoa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end",
"def create\n @objeto = Carpeta.new(carpeta_params)\n\n respond_to do |format|\n if @objeto.save\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Carpeta was successfully created.' }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def etiquetas_por_aluno\n logger.info(params)\n @etiquetas_aluno = Etiqueta.all.where(aluno_id: params[:aluno_id])\n respond_with @etiquetas_aluno\n end",
"def create\n \n\n respond_to do |format|\n if @evolucion.save\n format.html { redirect_to @evolucion, notice: 'Evolucion was successfully created.' }\n format.json { render :show, status: :created, location: @evolucion }\n else\n format.html { render :new }\n format.json { render json: @evolucion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @competency_pertenece_asignatura = CompetencyPerteneceAsignatura.new(params[:competency_pertenece_asignatura])\n\n respond_to do |format|\n if @competency_pertenece_asignatura.save\n format.html { redirect_to @competency_pertenece_asignatura, notice: 'Competency pertenece asignatura was successfully created.' }\n format.json { render json: @competency_pertenece_asignatura, status: :created, location: @competency_pertenece_asignatura }\n else\n format.html { render action: \"new\" }\n format.json { render json: @competency_pertenece_asignatura.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @veiculo = Veiculo.new(params[:veiculo])\n\n respond_to do |format|\n if @veiculo.save\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully created.' }\n format.json { render :json => @veiculo, :status => :created, :location => @veiculo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_ofertas\n\n\n\n arr_ofertas = []\n params.select { |par, val| par.starts_with?('oferta') && val.present? }.each do |puja|\n mid = puja.first.delete('oferta_')\n eliminar = params[\"delflag#{mid}\"] == '1'\n oferta = Oferta.new :mercado_id => mid, :seleccion_id => current_user.current_seleccion(session).id, :valor => puja.last.to_f, :estado => Oferta::PENDIENTE\n oferta.estado = Oferta::CANCELADA if eliminar\n\n oferta = oferta.save_if_valid\n arr_ofertas << I18n.t('mercado.oferta.oferta_creada', {:jugador => oferta.mercado.jugador.nombre, :valor => oferta.valor})\n end\n\n flash.now[:notice] = arr_ofertas.join '<br/>'\n\n # actualizamos los datos\n datos_ofertas\n\n respond_to do |format|\n format.js\n end\n\n end",
"def create\n @peso = Peso.new(peso_params)\n\n respond_to do |format|\n if @peso.save\n format.html { redirect_to @peso, notice: 'Peso was successfully created.' }\n format.json { render :show, status: :created, location: @peso }\n else\n format.html { render :new }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @posto = Posto.new(params[:posto])\n\n respond_to do |format|\n if @posto.save\n format.html { redirect_to @posto, notice: 'Posto de Saude cadastrado com sucesso' }\n format.json { render json: @posto, status: :created, location: @posto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @posto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @descuento = Descuento.new(descuento_params)\n\n respond_to do |format|\n if @descuento.save\n format.html { redirect_to @descuento, notice: 'Descuento fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @descuento }\n else\n format.html { render :new }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(respuesta_params)\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render :show, status: :created, location: api_v1_respuesta_url(@respuesta) }\n else\n format.html { render :new }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pedido = Pedido.new(params[:pedido])\n\n respond_to do |format|\n if @pedido.save\n format.html { redirect_to @pedido, notice: 'Pedido was successfully created.' }\n format.json { render json: @pedido, status: :created, location: @pedido }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @socio = Socio.new(params[:socio])\n\n respond_to do |format|\n if @socio.save\n format.html { redirect_to @socio, :notice => 'Socio cadastrado com sucesso.' }\n format.json { render :json => @socio, :status => :created, :location => @socio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @socio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def tecnicos_postulados\n coleccion = []\n self.request.each do |request|\n info = {}\n info[:id] = request.id\n info[:article] = request.article\n info[:servicio] = request.service.description\n info[:tecnicos] = request.proposal\n coleccion.append(info)\n end\n coleccion\n end",
"def create\n @peticion_servicio_ti = Peticion::ServicioTi.new(params[:peticion_servicio_ti])\n\n respond_to do |format|\n if @peticion_servicio_ti.save\n format.html { redirect_to edit_peticion_servicio_ti_path(@peticion_servicio_ti), notice: 'Guardado Correctamente.' }\n format.json { render json: @peticion_servicio_ti, status: :created, location: @peticion_servicio_ti }\n else\n format.html { render action: \"new\" }\n format.json { render json: @peticion_servicio_ti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @serv_adicionale = ServAdicionale.new(params[:serv_adicionale])\n\n respond_to do |format|\n if @serv_adicionale.save\n format.html { redirect_to @serv_adicionale, notice: 'Serv adicionale was successfully created.' }\n format.json { render json: @serv_adicionale, status: :created, location: @serv_adicionale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serv_adicionale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pedido = Pedido.new(pedido_params)\n\n respond_to do |format|\n if @pedido.save\n format.html { redirect_to '/', notice: 'Pedido was successfully created.' }\n format.json { render :show, status: :created, location: @pedido }\n else\n format.html { render :new }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n \n respond_to do |format|\n if @paciente.save\n format.html { redirect_to @paciente, notice: 'Paciente creado exitosamente.' }\n format.json { render :show, status: :created, location: @paciente }\n else \n format.html { render :new}\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n pessoa = Pessoa.new(pessoa_params) \n \n if pessoa.save\n render json: {status: 'SUCCESSO', message:'Usuário cadastrado com sucesso!', data:pessoa},status: :ok\n else\n render json: {status: 'ERRO', message:'Usuário não pode ser cadastrado. Tente novamente mais tarde.', data:pessoa.errors},status: :unprocessable_entity\n end\n end",
"def create\n @produto = Produto.new(params[:produto])\n @produto.empresa = session[:usuario].empresa\n \n params[:produto][:preco_compra] = converte_valor_banco params[:produto][:preco_compra]\n params[:produto][:preco_venda] = converte_valor_banco params[:produto][:preco_venda]\n\n respond_to do |format|\n if @produto.save\n format.html { redirect_to @produto, notice: 'Produto was successfully created.' }\n format.json { render json: @produto, status: :created, location: @produto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @puestos_entidad = PuestosEntidad.new(params[:puestos_entidad])\n\n respond_to do |format|\n if @puestos_entidad.save\n format.html { redirect_to @puestos_entidad, notice: 'Puestos entidad was successfully created.' }\n format.json { render json: @puestos_entidad, status: :created, location: @puestos_entidad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @puestos_entidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:propietario]\n @negocio_propio = Negocio.find(params[:negocio_id])\n @propietario = Usuario.find(params[:usuario_id])\n authorize! :update, @propietario\n if @propietario.negocios_propios << @negocio_propio\n render json: @propietario.negocios_propios, status: :created\n else\n render json: @propietario.negocios_propios.errors, status: :unprocessable_entity\n end\n else\n @negocio = Negocio.new(parametros_negocio)\n authorize! :create, Negocio\n if @negocio.save\n render json: @negocio, status: :created\n else\n render json: @negocio.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n @cooperativa = Cooperativa.new(params[:cooperativa])\n\n respond_to do |format|\n if @cooperativa.save\n format.html { redirect_to [:admin, @cooperativa], :notice => 'Exemplo was successfully created.' }\n format.json { render :json => @cooperativa, :status => :created, :location => @cooperativa }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cooperativa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sugestao = Sugestao.new(sugestao_params)\n\n respond_to do |format|\n if @sugestao.save\n format.html { redirect_to @sugestao, notice: 'Sugestão salva com sucesso.' }\n format.json { render :show, status: :created, location: @sugestao }\n else\n format.html { render :new }\n format.json { render json: @sugestao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tangazo = Tangazo.new(tangazo_params)\n\n respond_to do |format|\n if @tangazo.save\n format.html { redirect_to @tangazo, notice: 'Tangazo was successfully created.' }\n format.json { render :show, status: :created, location: @tangazo }\n else\n format.html { render :new }\n format.json { render json: @tangazo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @inventario_cosa = InventarioCosa.new(inventario_cosa_params)\n\n respond_to do |format|\n if @inventario_cosa.save\n format.html { redirect_to @inventario_cosa, notice: 'Inventario cosa was successfully created.' }\n format.json { render :show, status: :created, location: @inventario_cosa }\n else\n format.html { render :new }\n format.json { render json: @inventario_cosa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def crear\n # byebug\n ruta = Ruta.new\n ruta.nombre = params[:ruta][:nombre]\n ruta.descripcion = params[:ruta][:descripcion]\n ruta.subruta = params[:ruta][:subruta]\n ruta.save\n redirect_to action: \"index\"\n\n # respond_to do |format|\n # if @ruta.save\n # format.html { redirect_to @ruta, notice: \"Rutum was successfully created.\" }\n # format.json { render :show, status: :created, location: @ruta }\n # else\n # format.html { render :new }\n # format.json { render json: @ruta.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @ativo_outro = AtivoOutro.new(params[:ativo_outro])\n\n respond_to do |format|\n if @ativo_outro.save\n format.html { redirect_to @ativo_outro, notice: 'Ativo foi salvo com sucesso.' }\n format.json { render json: @ativo_outro, status: :created, location: @ativo_outro }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ativo_outro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estrutura = Estrutura.new(estrutura_params)\n\n respond_to do |format|\n if @estrutura.save\n format.html { redirect_to @estrutura, notice: 'Estrutura was successfully created.' }\n format.json { render :show, status: :created, location: @estrutura }\n else\n format.html { render :new }\n format.json { render json: @estrutura.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ocupacion = Ocupacion.new(ocupacion_params)\n\n respond_to do |format|\n if @ocupacion.save\n format.html { redirect_to @ocupacion, notice: 'Ocupacion was successfully created.' }\n format.json { render :show, status: :created, location: @ocupacion }\n else\n format.html { render :new }\n format.json { render json: @ocupacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @objetivo = Objetivo.new(objetivo_params)\n\n respond_to do |format|\n if @objetivo.save\n format.html { redirect_to @objetivo, notice: 'Objetivo was successfully created.' }\n format.json { render :show, status: :created, location: @objetivo }\n else\n format.html { render :new }\n format.json { render json: @objetivo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @traslado = Traslado.new(traslado_params)\n\n respond_to do |format|\n if @traslado.save\n format.html { redirect_to @traslado, notice: 'Traslado was successfully created.' }\n format.json { render :show, status: :created, location: @traslado }\n else\n format.html { render :new }\n format.json { render json: @traslado.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tablero = Tablero.new(tablero_params)\n m= params.require(:tablero).permit(:idusuario, :grupo, :descripcion, :e1, :e2, :e3, :puntaje)\n\n params[idusuario.each] do |i|\n miembros=[params[:idusuario[i]]:grupo[i], :descripcion[i], :e1[i], :e2[i], :e3[i], :puntaje[i]]\n end\n\n respond_to do |format|\n if @tablero.save\n format.html { redirect_to @tablero, notice: \"El tablero se creó correctamente\" }\n format.json { render :show, status: :created, location: @tablero }\n else\n format.html { render :new }\n format.json { render json: @tablero.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pedidos_has_prato = PedidosHasPrato.new(pedidos_has_prato_params)\n\n respond_to do |format|\n if @pedidos_has_prato.save\n format.html { redirect_to @pedidos_has_prato, notice: 'Pedidos has prato was successfully created.' }\n format.json { render :show, status: :created, location: @pedidos_has_prato }\n else\n format.html { render :new }\n format.json { render json: @pedidos_has_prato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @efectivo = Efectivo.new(efectivo_params)\n\n respond_to do |format|\n if @efectivo.save\n format.html { redirect_to @efectivo, notice: 'Efectivo was successfully created.' }\n format.json { render :show, status: :created, location: @efectivo }\n else\n format.html { render :new }\n format.json { render json: @efectivo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @artesano = Artesano.new(artesano_params)\n\n respond_to do |format|\n if @artesano.save\n format.html { redirect_to @artesano, notice: 'Artesano was successfully created.' }\n format.json { render :show, status: :created, location: @artesano }\n else\n format.html { render :new }\n format.json { render json: @artesano.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pedido = Pedido.new(pedido_params)\n\n respond_to do |format|\n if @pedido.save\n format.html { redirect_to @pedido, notice: 'Pedido was successfully created.' }\n format.json { render :show, status: :created, location: @pedido }\n else\n format.html { render :new }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pedido = Pedido.new(pedido_params)\n\n respond_to do |format|\n if @pedido.save\n format.html { redirect_to @pedido, notice: 'Pedido was successfully created.' }\n format.json { render :show, status: :created, location: @pedido }\n else\n format.html { render :new }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pedido = Pedido.new(pedido_params)\n\n respond_to do |format|\n if @pedido.save\n format.html { redirect_to @pedido, notice: 'Pedido was successfully created.' }\n format.json { render :show, status: :created, location: @pedido }\n else\n format.html { render :new }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @livro = Livro.new(livro_params)\n\n respond_to do |format|\n if @livro.save\n format.html { redirect_to @livro, notice: 'Livro cadastrado com sucesso.' }\n format.json { render :show, status: :created, location: @livro }\n else\n format.html { render :new }\n format.json { render json: @livro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jornada = Jornada.new(params[:jornada])\n\n respond_to do |format|\n if @jornada.save\n format.html { redirect_to jornadas_path, notice: 'La jornada se ha creado correctamente' }\n format.json { render json: @jornada, status: :created, location: @jornada }\n else\n format.html { render action: \"new\" }\n format.json { render json: @jornada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:get]\n @plato = Plato.where(\"soda_id = ?\", params[:soda_id])\n\n #if !@plato.comentario.first.nil?\n # render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id], include: [comentario:{only: [:id]}])\n #else\n render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id])\n #end\n\n else\n @plato = Plato.new(plato_params)\n\n if @plato.save\n render json: @plato, status: :created, location: @plato\n else\n render json: @plato.errors, status: :unprocessable_entity\n end\n end\n\n end",
"def create\n @enemigo = Enemigo.new(enemigo_params)\n\n respond_to do |format|\n if @enemigo.save\n format.html { redirect_to @enemigo, notice: 'Enemigo was successfully created.' }\n format.json { render :show, status: :created, location: @enemigo }\n else\n format.html { render :new }\n format.json { render json: @enemigo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entregavel = Entregavel.new(entregavel_params)\n\n respond_to do |format|\n if @entregavel.save\n format.html { redirect_to @entregavel, notice: 'Entregavel foi criado(a)' }\n format.json { render :show, status: :created, location: @entregavel }\n else\n format.html { render :new }\n format.json { render json: @entregavel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sumario = Sumario.new(sumario_params)\n\n respond_to do |format|\n if @sumario.save\n format.html { redirect_to @sumario, notice: 'Sumario was successfully created.' }\n format.json { render :show, status: :created, location: @sumario }\n else\n format.html { render :new }\n format.json { render json: @sumario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @anteproyecto_observacion = AnteproyectoObservacion.new(anteproyecto_observacion_params)\n\n respond_to do |format|\n if @anteproyecto_observacion.save\n format.html { redirect_to @anteproyecto_observacion, notice: 'Anteproyecto observacion was successfully created.' }\n format.json { render :show, status: :created, location: @anteproyecto_observacion }\n else\n format.html { render :new }\n format.json { render json: @anteproyecto_observacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comentario = Comentario.new(comentario_params)\n\n respond_to do |format|\n if @comentario.save\n format.html { redirect_to restaurante_comentarios_path(@comentario), notice: 'Plato was successfully created.' }\n format.json { render :show, status: :created, location: @restaurante }\n else\n format.html { render :new }\n format.json { render json: @comentario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estadia = Estadia.new(estadia_params)\n\n #Quando cria uma estadia nova, seta a data como a hora corrente\n @estadia.data_entrada = Time.now\n #ocupa a vaga\n @estadia.vaga.ocupada = true\n\n respond_to do |format|\n if @estadia.vaga.save && @estadia.save\n format.html { redirect_to @estadia, notice: 'Estadia was successfully created.' }\n format.json { render :show, status: :created, location: @estadia }\n else\n format.html { render :new }\n format.json { render json: @estadia.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6629244",
"0.6479606",
"0.6433449",
"0.6382739",
"0.63549143",
"0.63375264",
"0.629571",
"0.62704456",
"0.6267636",
"0.62673527",
"0.62503576",
"0.62459356",
"0.62421227",
"0.6222371",
"0.62162644",
"0.6209373",
"0.61993676",
"0.6177276",
"0.6167893",
"0.6167577",
"0.6161842",
"0.6160888",
"0.61606914",
"0.61510324",
"0.61507833",
"0.6149209",
"0.6145092",
"0.61364484",
"0.6130178",
"0.61287284",
"0.61268425",
"0.6125773",
"0.612382",
"0.61232233",
"0.6122577",
"0.61185884",
"0.6114103",
"0.6105687",
"0.61048037",
"0.60974663",
"0.60964566",
"0.6095875",
"0.60945565",
"0.60851485",
"0.608366",
"0.6079095",
"0.60775745",
"0.60722244",
"0.60657054",
"0.6062106",
"0.6061778",
"0.60606533",
"0.60534924",
"0.6049925",
"0.604858",
"0.6047339",
"0.6047283",
"0.60388154",
"0.60357344",
"0.603252",
"0.6028258",
"0.6025444",
"0.60249555",
"0.602287",
"0.6022635",
"0.6018632",
"0.6017871",
"0.60139334",
"0.60138583",
"0.6012382",
"0.6011225",
"0.601081",
"0.600584",
"0.6003886",
"0.60024995",
"0.60015565",
"0.60002285",
"0.5995582",
"0.59950006",
"0.59901035",
"0.59894425",
"0.59828657",
"0.59810615",
"0.59777576",
"0.5975926",
"0.5971853",
"0.5966816",
"0.5966149",
"0.5964662",
"0.5964662",
"0.5964662",
"0.59645736",
"0.5962215",
"0.59574896",
"0.59552133",
"0.59535056",
"0.59526527",
"0.59515023",
"0.5950001",
"0.5947942"
] |
0.66372675
|
0
|
PATCH/PUT /espetaculos/1 PATCH/PUT /espetaculos/1.json
|
def update
respond_to do |format|
if @espetaculo.update(espetaculo_params)
format.html { redirect_to @espetaculo, notice: 'Espetaculo was successfully updated.' }
format.json { render :show, status: :ok, location: @espetaculo }
else
format.html { render :edit }
format.json { render json: @espetaculo.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n respond_to do |format|\n if @servico_pacote.update(servico_pacote_params)\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @prueba_json.update(prueba_json_params)\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n if @peso.update_attributes(params[:peso])\n format.html { redirect_to @peso, notice: 'Peso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plato = Plato.find(params[:id])\n\n if @plato.update(plato_params)\n head :no_content\n else\n render json: @plato.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @parola.update(parola_params)\n format.html { redirect_to parolas_url, notice: 'Parola was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @parola.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n if @respuesta.update_attributes(params[:respuesta])\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @peticion_servicio_ti = Peticion::ServicioTi.find(params[:id])\n\n respond_to do |format|\n if @peticion_servicio_ti.update_attributes(params[:peticion_servicio_ti])\n format.html { redirect_to edit_peticion_servicio_ti_path(@peticion_servicio_ti), notice: 'Actualizado Correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peticion_servicio_ti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n if @pessoa.update_attributes(params[:pessoa])\n format.html { redirect_to pessoas_path, notice: 'Pessoa atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @poligono.update(poligono_params)\n format.html { redirect_to @poligono, notice: 'Poligono was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @poligono.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tiposveiculo.update(tiposveiculo_params)\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @protocolo.update(protocolo_params)\n addlog(\"Protocolo alterado\")\n format.html { redirect_to @protocolo, notice: 'Protocolo foi atualizado.' }\n format.json { render :show, status: :ok, location: @protocolo }\n else\n format.html { render :edit }\n format.json { render json: @protocolo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resto.update(resto_params)\n format.html { redirect_to @resto, notice: 'Entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @resto }\n else\n format.html { render :edit }\n format.json { render json: @resto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tapioca.update(tapioca_params)\n format.html { redirect_to @tapioca, notice: 'Tapioca was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tapioca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @servico.update(servico_params)\n format.html { redirect_to servicos_url, notice: 'Serviço atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @servico }\n else\n format.html { render :edit }\n format.json { render json: @servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @precio_boleto.update(precio_boleto_params)\n format.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def update\n @competicao = Competicao.find(params[:id])\n\n respond_to do |format|\n if @competicao.update_attributes(params[:competicao])\n format.html { redirect_to @competicao, notice: 'Competicao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @competicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @asiento = Asiento.find(params[:id])\n\n respond_to do |format|\n if @asiento.update_attributes(params[:asiento])\n format.html { redirect_to @asiento, :notice => 'El apunte fue cambiado.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @asiento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @selecao = Selecao.find(params[:id])\n\n respond_to do |format|\n if @selecao.update_attributes(params[:selecao])\n format.html { redirect_to @selecao, notice: 'Selecao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @selecao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\r\n respond_to do |format|\r\n if @sivic_celula.update(sivic_celula_params)\r\n format.html { redirect_to @sivic_celula, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_celula.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @os_entregavel.update(os_entregavel_params)\n if @os_entregavel.ordem_servico.id!=nil\n format.html { redirect_to \"/ordem_servicos/\"+@os_entregavel.ordem_servico.id.to_s, notice: 'Os entregavel foi atualizado(a)' }\n format.json { head :no_content }\n else\n format.html { redirect_to @os_entregavel, notice: 'Os entregavel foi atualizado(a)' }\n format.json { render :show, status: :ok, location: @os_entregavel }\n end\n else\n format.html { render :edit }\n format.json { render json: @os_entregavel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @platoon.update(platoon_params)\n format.html { redirect_to @platoon, notice: 'Platoon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(carpeta_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Carpeta was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(etiqueta_params)\n format.html { redirect_to @objeto, notice: 'Etiqueta was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\trespond_to do |format|\n\tif @precio_boleto.update(precio_boleto_params)\n\t\tformat.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully updated.' }\n\t\tformat.json { head :no_content }\n\telse\n\t\tformat.html { render action: 'edit' }\n\t\tformat.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n\tend\n\tend\nend",
"def update\n respond_to do |format|\n if @solicitacoes_avaliacoes_servico.update(solicitacoes_avaliacoes_servico_params)\n format.html { redirect_to @solicitacoes_avaliacoes_servico, notice: 'Solicitacoes avaliacoes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacoes_avaliacoes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n if @puntaje.update_attributes(params[:puntaje])\n format.html { redirect_to @puntaje, notice: 'Puntaje was successfully updated.' }\n format.json { head :no_content }\n else\n atributos\n format.html { render action: \"edit\" }\n format.json { render json: @puntaje.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @sivic_pessoa.update(sivic_pessoa_params)\r\n format.html { redirect_to @sivic_pessoa, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_pessoa.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @safra_verdoso = SafraVerdoso.find(params[:id])\n\n respond_to do |format|\n if @safra_verdoso.update_attributes(params[:safra_verdoso])\n format.html { redirect_to \"/safra_produtos/#{@safra_verdoso.safra_produto_id}/descontos\"}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @safra_verdoso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @producto.update(producto_params)\n format.html { redirect_to @producto, notice: 'Producto actualizado.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @opcao.update(opcao_params)\n format.html { redirect_to @opcao, notice: 'Opcao atualizada com sucesso!' }\n format.json { render :show, status: :ok, location: @opcao }\n else\n format.html { render :edit }\n format.json { render json: @opcao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @compra_venta_normal.update(compra_venta_normal_params)\n format.html { redirect_to @compra_venta_normal, notice: 'Compra venta normal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @compra_venta_normal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ocorrencia.update(ocorrencia_params)\n format.html { redirect_to @ocorrencia, notice: 'Ocorrencia was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ocorrencia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @precio_paquete.update(precio_paquete_params)\n format.html { redirect_to action: \"index\", notice: 'Precio paquete actualizado existosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @precio_paquete.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, notice: 'Tecnico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clientes_servico.update(clientes_servico_params)\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update\n @cooperativa = Cooperativa.find(params[:id])\n\n respond_to do |format|\n if @cooperativa.update_attributes(params[:cooperativa])\n format.html { redirect_to [:admin, @cooperativa], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cooperativa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:producto][:activo]\n id = params[:id]\n Producto.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n if @tipo_negocio.update_attributes(params[:tipo_negocio])\n format.html { redirect_to @tipo_negocio, notice: 'Tipo negocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_negocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @peso.update(peso_params)\n format.html { redirect_to @peso, notice: 'Peso was successfully updated.' }\n format.json { render :show, status: :ok, location: @peso }\n else\n format.html { render :edit }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @apologetic.update(apologetic_params)\n format.html { redirect_to @apologetic, notice: 'Apologetic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @apologetic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoenvolvido.update(tipoenvolvido_params)\n format.html { redirect_to @tipoenvolvido, notice: 'Tipoenvolvido was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoenvolvido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n if @personaje.update_attributes(params[:personaje])\n format.html { redirect_to @personaje, notice: 'Personaje was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personaje.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n respond_to do |format|\n if @pessoa.update(pessoa_params)\n format.html { redirect_to @pessoa, notice: 'Cadastro alterado com sucesso!.' }\n format.json { render :show, status: :ok, location: @pessoa }\n else\n format.html { render :edit }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n respond_to do |format|\n if @ejemplo.update(ejemplo_params)\n format.html { redirect_to @ejemplo, notice: 'Ejemplo was successfully updated.' }\n format.json { render :show, status: :ok, location: @ejemplo }\n else\n format.html { render :edit }\n format.json { render json: @ejemplo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @repuesto_servicio.update(repuesto_servicio_params)\n format.html { redirect_to @repuesto_servicio, notice: 'Repuesto o servicio fue actualizado con éxito.' }\n format.json { render :show, status: :ok, location: @repuesto_servicio }\n else\n format.html { render :edit }\n format.json { render json: @repuesto_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n if @producto.update_attributes(params[:producto])\n format.html { redirect_to @producto, notice: 'Producto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n if @solicitud_servicio.update_attributes(params[:solicitud_servicio])\n format.html { redirect_to @solicitud_servicio, notice: 'Solicitud servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitud_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cargo_eleicao = CargoEleicao.find(params[:id])\n\n respond_to do |format|\n if @cargo_eleicao.update_attributes(params[:cargo_eleicao])\n format.html { redirect_to @cargo_eleicao, notice: 'Cargo eleicao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cargo_eleicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @consumo = Consumo.find(params[:id])\n\n respond_to do |format|\n if @consumo.update_attributes(params[:consumo])\n format.html { redirect_to @consumo.cliente, :notice => 'Consumo alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @consumo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @voluntario = Voluntario.find(params[:id])\n params[:voluntario].delete :inclusoes\n\n respond_to do |format|\n if @voluntario.update_attributes(params[:voluntario])\n format.html { redirect_to(@voluntario, :notice => 'Voluntário atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @voluntario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @peticion.update(peticion_params)\n format.html { redirect_to @peticion, notice: 'Peticion was successfully updated.' }\n format.json { render :show, status: :ok, location: @peticion }\n else\n format.html { render :edit }\n format.json { render json: @peticion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @os_nivel_servico.update(os_nivel_servico_params)\n format.html { redirect_to @os_nivel_servico, notice: 'Os nivel servico foi atualizado(a)' }\n format.json { render :show, status: :ok, location: @os_nivel_servico }\n else\n format.html { render :edit }\n format.json { render json: @os_nivel_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n if @articulo.update_attributes(params[:articulo])\n format.html { redirect_to @articulo, notice: 'Articulo se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @articulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @escola = Escola.find(params[:id])\n\n respond_to do |format|\n if @escola.update_attributes(params[:escola])\n format.html { redirect_to @escola, :notice => 'Escola was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @escola.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @inventario_cosa.update(inventario_cosa_params)\n format.html { redirect_to @inventario_cosa, notice: 'Inventario cosa was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario_cosa }\n else\n format.html { render :edit }\n format.json { render json: @inventario_cosa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @serv_adicionale = ServAdicionale.find(params[:id])\n\n respond_to do |format|\n if @serv_adicionale.update_attributes(params[:serv_adicionale])\n format.html { redirect_to @serv_adicionale, notice: 'Serv adicionale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serv_adicionale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @perfilnegocio = Perfilnegocio.find(params[:id])\n\n respond_to do |format|\n if @perfilnegocio.update_attributes(params[:perfilnegocio])\n format.html { redirect_to @perfilnegocio, notice: 'Perfilnegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @perfilnegocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @servico_evento.update(servico_evento_params)\n format.html { redirect_to @servico_evento, notice: 'Evento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_evento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update\n respond_to do |format|\n if @objetivo.update(objetivo_params)\n format.html { redirect_to [@mision, @objetivo], notice: 'Objetivo was successfully updated.' }\n format.json { render :show, status: :ok, location: [@mision, @objetivo] }\n else\n format.html { render :edit }\n format.json { render json: [@mision, @objetivo].errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objetivo.update(objetivo_params)\n format.html { redirect_to @objetivo, notice: 'Objetivo was successfully updated.' }\n format.json { render :show, status: :ok, location: @objetivo }\n else\n format.html { render :edit }\n format.json { render json: @objetivo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n if @colegio.update_attributes(params[:colegio])\n format.html { redirect_to @colegio, notice: 'El Colegio fue actualizado satisfactoriamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @colegio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @asiento_de_servicio.update(asiento_de_servicio_params)\n format.html { redirect_to @asiento_de_servicio, notice: 'Asiento de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @asiento_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @asiento_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parlo.update(parlo_params)\n format.html { redirect_to @parlo, notice: 'Parlo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @parlo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @sivic_contcelula.update(sivic_contcelula_params)\r\n format.html { redirect_to @sivic_contcelula, notice: 'Sivic contcelula was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_contcelula.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n set_funcionario\n if @ordem_servico.update(ordem_servico_params)\n format.html { redirect_to @ordem_servico, notice: t('messages.cadastro_atualizado') }\n format.json { render :show, status: :ok, location: @ordem_servico }\n else\n format.html { render :edit }\n format.json { render json: @ordem_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @producto_platillo.update(producto_platillo_params)\n format.html { redirect_to @producto_platillo, notice: 'El Detalle del Platillo Fue Actualizado Exitosamente.' }\n format.json { render :show, status: :ok, location: @producto_platillo }\n else\n format.html { render :edit }\n format.json { render json: @producto_platillo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @responsavel = Responsavel.find(params[:id])\n\n if @responsavel.update(responsavel_params)\n head :no_content\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end",
"def update\n @sistema = Sistema.find(params[:id])\n\n respond_to do |format|\n if @sistema.update_attributes(params[:sistema])\n format.html { redirect_to @sistema, notice: 'Sistema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sistema.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prace_polozka.update(prace_polozka_params)\n format.html { redirect_to @prace_polozka, notice: 'Zaznam byl zmenen.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prace_polozka.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n if @paciente.update_attributes(params[:paciente])\n format.html { redirect_to @paciente, notice: 'Paciente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n if @articulo.update_attributes(params[:articulo])\n format.html { redirect_to @articulo, notice: 'Articulo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @articulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n if @producto.update_attributes(params[:producto])\n format.html { redirect_to @producto, notice: 'El producto ha sido actualizado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_de_servicio.update(tipo_de_servicio_params)\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @voluntario.update(voluntario_params) and @voluntario.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @voluntario, notice: 'Voluntario was successfully updated.' }\n format.json { render :show, status: :ok, location: @voluntario }\n else\n format.html { render :edit }\n format.json { render json: @voluntario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n if @comentario.update_attributes(params[:comentario])\n format.html { redirect_to @comentario, notice: 'Comentario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comentario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def atualiza_um_pet_existente(objeto)\n uri = \"#{ENV['BASE_URI']}/pet\"\n \n without_authentication('put', uri, objeto.to_json)\n end",
"def update\n respond_to do |format|\n if @topico.update(topico_params)\n format.html { redirect_to set_path, notice: 'Tópico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contato.update(contato_params)\n format.html { redirect_to @contato, flash: { success: 'Contato was successfully updated.' } }\n format.json { render :show, status: :ok, location: @contato }\n else\n format.html { render :edit }\n format.json { render json: @contato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @livro = Livro.find(params[:id])\n\n respond_to do |format|\n if @livro.update_attributes(params[:livro])\n format.html { redirect_to @livro, :notice => 'Livro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @livro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @inventario.update(inventario_params)\n format.html { redirect_to @inventario, notice: 'Inventario was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario }\n else\n format.html { render :edit }\n format.json { render json: @inventario.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6754576",
"0.67299086",
"0.6715537",
"0.663927",
"0.6634241",
"0.66322494",
"0.6624645",
"0.6623522",
"0.66041064",
"0.6566747",
"0.6555308",
"0.6537978",
"0.653486",
"0.65325713",
"0.6508927",
"0.6490175",
"0.6483012",
"0.64702094",
"0.6454734",
"0.64513063",
"0.64513063",
"0.6450714",
"0.6447408",
"0.6440689",
"0.64394283",
"0.64308167",
"0.6429654",
"0.64076144",
"0.64065117",
"0.63975555",
"0.6396739",
"0.63902265",
"0.6389426",
"0.6379691",
"0.6378032",
"0.6373933",
"0.63704085",
"0.6369925",
"0.6369445",
"0.636744",
"0.63590235",
"0.6356785",
"0.63551927",
"0.6352724",
"0.63520885",
"0.6349176",
"0.63428783",
"0.63427997",
"0.63427377",
"0.63404167",
"0.6332095",
"0.63320094",
"0.63286215",
"0.6325224",
"0.6324843",
"0.6323535",
"0.6321622",
"0.631969",
"0.6317517",
"0.63155323",
"0.6314531",
"0.6314054",
"0.6313089",
"0.63096994",
"0.63095397",
"0.6308942",
"0.6308916",
"0.6302501",
"0.63018894",
"0.63008064",
"0.62984407",
"0.62943023",
"0.6286019",
"0.62818617",
"0.6281079",
"0.6280282",
"0.6280282",
"0.62796277",
"0.6278324",
"0.62776625",
"0.627483",
"0.6268952",
"0.6266792",
"0.62590206",
"0.62589383",
"0.62586135",
"0.62572646",
"0.62571675",
"0.62527317",
"0.62514186",
"0.6250345",
"0.62477916",
"0.6244377",
"0.6243628",
"0.62435716",
"0.62389684",
"0.62374777",
"0.62367356",
"0.62355673",
"0.62344736"
] |
0.6528476
|
14
|
DELETE /espetaculos/1 DELETE /espetaculos/1.json
|
def destroy
@espetaculo.destroy
respond_to do |format|
format.html { redirect_to espetaculos_url, notice: 'Espetaculo was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @veiculo = Veiculo.find(params[:id])\n @veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to veiculos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end",
"def destroy\n @asiento = Asiento.find(params[:id])\n @asiento.destroy\n\n respond_to do |format|\n format.html { redirect_to asientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @escola = Escola.find(params[:id])\n @escola.destroy\n\n respond_to do |format|\n format.html { redirect_to escolas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cargo_eleicao = CargoEleicao.find(params[:id])\n @cargo_eleicao.destroy\n\n respond_to do |format|\n format.html { redirect_to cargo_eleicaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ocorrencia.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servicio = Servicio.find(params[:id])\n @servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to servicios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exura = Exura.find(params[:id])\n @exura.destroy\n\n respond_to do |format|\n format.html { redirect_to exuras_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @descuento = Descuento.find(params[:id])\n @descuento.destroy\n\n respond_to do |format|\n format.html { redirect_to descuentos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @safra_verdoso = SafraVerdoso.find(params[:id])\n @safra_verdoso.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/safra_produtos/#{@safra_verdoso.safra_produto_id}/descontos\"}\n format.json { head :no_content }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuestum.destroy\n respond_to do |format|\n format.html { redirect_to comentarios_url }\n format.json { head :no_content }\n end\n end",
"def delete\n unless possui_acesso?()\n return\n end\n @aviso = Aviso.find(params[:id])\n @aviso.destroy\n\n respond_to do |format|\n format.html { redirect_to avisos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @fulcliente = Fulcliente.find(params[:id])\n @fulcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to fulclientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asociado = Asociado.find(params[:id])\n @asociado.destroy\n\n respond_to do |format|\n format.html { redirect_to asociados_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @retroalimentacion = Retroalimentacion.find(params[:id])\n @retroalimentacion.destroy\n\n respond_to do |format|\n format.html { redirect_to retroalimentacions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sezione = Sezione.find(params[:id])\n @sezione.destroy\n\n respond_to do |format|\n format.html { redirect_to sezioni_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @serv_adicionale = ServAdicionale.find(params[:id])\n @serv_adicionale.destroy\n\n respond_to do |format|\n format.html { redirect_to serv_adicionales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @selecao = Selecao.find(params[:id])\n @selecao.destroy\n\n respond_to do |format|\n format.html { redirect_to selecaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @etiquetum.destroy\n respond_to do |format|\n format.html { redirect_to etiqueta_url, notice: 'Etiqueta borrada!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @especialidad.destroy\n respond_to do |format|\n format.html { redirect_to especialidads_url, notice: 'Servicio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nota_tecnica.destroy\n respond_to do |format|\n format.html { redirect_to nota_tecnicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @peso = Peso.find(params[:id])\n @peso.destroy\n\n respond_to do |format|\n format.html { redirect_to pesos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @colegio = Colegio.find(params[:id])\n @colegio.destroy\n\n respond_to do |format|\n format.html { redirect_to colegios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @seguro = Seguro.find(params[:id])\n @seguro.destroy\n\n respond_to do |format|\n format.html { redirect_to seguros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @veiculo.destroy\n respond_to do |format|\n format.html { redirect_to veiculos_url, notice: 'Veiculo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ejemplo.destroy\n respond_to do |format|\n format.html { redirect_to ejemplos_url, notice: 'Ejemplo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @competicao = Competicao.find(params[:id])\n @competicao.destroy\n\n respond_to do |format|\n format.html { redirect_to competicoes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pedido.destroy\n respond_to do |format|\n format.html { redirect_to pedidos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estacionamiento = Estacionamiento.find(params[:id])\n @estacionamiento.destroy\n\n respond_to do |format|\n format.html { redirect_to estacionamientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @inventario_cosa.destroy\n respond_to do |format|\n format.html { redirect_to inventario_cosas_url, notice: 'Inventario cosa was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipoapreensao.destroy\n respond_to do |format|\n format.html { redirect_to tipoapreensoes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apoio_educacioanl.destroy\n respond_to do |format|\n format.html { redirect_to apoio_educacioanls_url, notice: 'Apoio educacioanal foi excluído com Sucesso !' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ativo_outro = AtivoOutro.find(params[:id])\n @ativo_outro.destroy\n\n respond_to do |format|\n format.html { redirect_to ativo_outros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @indicativo = Indicativo.find(params[:id])\n @indicativo.destroy\n\n respond_to do |format|\n format.html { redirect_to indicativos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @detalle = Detalle.find(params[:id])\n @detalle.destroy\n\n respond_to do |format|\n format.html { redirect_to detalles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @sivic_contcelula.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_contcelulas_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @datos_estudiante.destroy\n respond_to do |format|\n format.html { redirect_to datos_estudiantes_url, notice: 'Datos estudiante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientepedido = Clientepedido.find(params[:id])\n @clientepedido.destroy\n\n respond_to do |format|\n format.html { redirect_to clientepedidos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objet = Objet.find(params[:id])\n @objet.destroy\n\n respond_to do |format|\n format.html { redirect_to objets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to etiquetas_url, notice: 'Etiqueta was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resto.destroy\n respond_to do |format|\n format.html { redirect_to restos_url, notice: 'Entry was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n checar_egresso_super\r\n @egresso.destroy\r\n respond_to do |format|\r\n format.html { redirect_to egressos_url, notice: 'Egresso excluído com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @tipoveiculo.destroy\n respond_to do |format|\n format.html { redirect_to tipoveiculos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oficio.destroy\n respond_to do |format|\n format.html { redirect_to oficios_url, notice: 'Oficio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n @observacao_vocacionada.destroy\n\n respond_to do |format|\n format.html { redirect_to observacao_vocacionadas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @orcamento.destroy\n respond_to do |format|\n format.html { redirect_to orcamentos_url, notice: 'Orçamento apagado com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lectura.destroy\n respond_to do |format|\n format.html { redirect_to lecturas_url, notice: 'La lectura fue eliminada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lectura.destroy\n respond_to do |format|\n format.html { redirect_to lecturas_url, notice: 'La lectura fue eliminada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lixotodo.destroy\n respond_to do |format|\n format.html {redirect_to lixotodos_url, notice: 'Registro excluído com sucesso.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @objet = Objet.find(params[:id])\n @objet.destroy\n respond_to do |format|\n format.html { redirect_to objets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @livro.destroy\n respond_to do |format|\n format.html { redirect_to livros_url, notice: 'Livro apagado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @ordem_servico.destroy\n respond_to do |format|\n format.html { redirect_to ordem_servicos_url, notice: t('messages.cadastro_removido') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @articulo = Articulo.find(params[:id])\n @articulo.destroy\n\n respond_to do |format|\n format.html { redirect_to articulos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @articulo = Articulo.find(params[:id])\n @articulo.destroy\n\n respond_to do |format|\n format.html { redirect_to articulos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @articulo = Articulo.find(params[:id])\n @articulo.destroy\n\n respond_to do |format|\n format.html { redirect_to articulos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #--ADICIONADO\n @cliente.perfilclientes.destroy\n #--ADICIONADO\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @etnia = Etnia.find(params[:id])\n @etnia.destroy\n\n respond_to do |format|\n format.html { redirect_to etnias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asiento_de_servicio.destroy\n respond_to do |format|\n format.html { redirect_to asiento_de_servicios_url, notice: 'Asiento de servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sugerencia = Sugerencia.find(params[:id])\n @sugerencia.destroy\n\n respond_to do |format|\n format.html { redirect_to sugerencias_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @venta = Venta.find(params[:id])\n @venta.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inventario.destroy\n respond_to do |format|\n format.html { redirect_to inventarios_url, notice: 'Inventario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inventario.destroy\n respond_to do |format|\n format.html { redirect_to inventarios_url, notice: 'Inventario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entrada_inventario = EntradaInventario.find(params[:id])\n @entrada_inventario.destroy\n\n respond_to do |format|\n format.html { redirect_to entrada_inventarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @opcao.destroy\n respond_to do |format|\n format.html { redirect_to opcaos_url, notice: 'Opção Apagada com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sitio_entrega = SitioEntrega.find(params[:id])\n @sitio_entrega.destroy\n\n respond_to do |format|\n format.html { redirect_to sitio_entregas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @redacao.destroy\n respond_to do |format|\n format.html { redirect_to redacaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n @tipo_vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_vehiculos_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @donante.destroy\n respond_to do |format|\n format.html { redirect_to donantes_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7378611",
"0.73478216",
"0.7294123",
"0.72779894",
"0.72760147",
"0.7243003",
"0.72137994",
"0.7204482",
"0.7200267",
"0.7197665",
"0.7196717",
"0.71902996",
"0.7182072",
"0.71516937",
"0.71492255",
"0.71477383",
"0.713861",
"0.71360874",
"0.7134037",
"0.7116888",
"0.7114829",
"0.7106234",
"0.7103514",
"0.70940405",
"0.70908153",
"0.7089281",
"0.70870185",
"0.70870185",
"0.708559",
"0.7084204",
"0.70834273",
"0.7083347",
"0.70805615",
"0.70799476",
"0.70781296",
"0.7074041",
"0.7070701",
"0.7070701",
"0.7070701",
"0.7070165",
"0.70675683",
"0.7065663",
"0.70648396",
"0.70625824",
"0.7061156",
"0.7059017",
"0.7055247",
"0.705466",
"0.7052813",
"0.7050016",
"0.7048722",
"0.7044067",
"0.7042929",
"0.70380944",
"0.7035537",
"0.7035537",
"0.7035537",
"0.7034035",
"0.70325935",
"0.70318395",
"0.7030071",
"0.70294213",
"0.70252603",
"0.70249015",
"0.7023169",
"0.7019299",
"0.70169437",
"0.7011812",
"0.7008666",
"0.70083416",
"0.7007995",
"0.7007856",
"0.7007847",
"0.7007841",
"0.7007841",
"0.7007475",
"0.70046294",
"0.7004346",
"0.7003267",
"0.7002254",
"0.70016015",
"0.7001339",
"0.7001339",
"0.7001339",
"0.7000383",
"0.70003074",
"0.6994898",
"0.69937223",
"0.69908696",
"0.6988867",
"0.69869894",
"0.6986418",
"0.6986418",
"0.6983854",
"0.69821393",
"0.6981949",
"0.6979487",
"0.69783086",
"0.6975935",
"0.69755584"
] |
0.7135924
|
18
|
Use callbacks to share common setup or constraints between actions.
|
def set_espetaculo
@espetaculo = Espetaculo.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def espetaculo_params
params.require(:espetaculo).permit(:nome, :atores, :diretor, :sonoplasta, :iluminador)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Nova instancia do Banpara
|
def initialize(campos = {})
campos[:local_pagamento] = 'Pagar preferencialmente em agência do Banpará'
super(campos)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n\n @boleto = Boleto.new\n\n end",
"def agregar_palabra\n\t\t@palabra = @bot.palabras.new\n\tend",
"def nueva\n @ciudad = Ciudad.new\n end",
"def create\n # Submit de new, crea nueva instance en DB.\n end",
"def create_api_instance\n facturama_user='prueba'\n facturama_password='pruebas2011'\n is_development = true # true = Modo de pruebas / sandbox, false = Modo de Producción (Timbrado real)\n\n\n #Creacion de una instancia de FacturamaApiMultiemisor\n Facturama::FacturamaApiMulti.new(facturama_user,facturama_password,is_development)\n end",
"def new\n \t@entrega = Entrega.new\n \tend",
"def new\n @permiso_pernocta = PermisoPernocta.new\n @id = PermisoPernocta.next_id\n @solicita = User.get_solicitante(current_user.id)\n @VoBo = User.get_jefe_area(current_user.id)\n @vehiculos = Vehiculo.get_area_vehiculos(current_user.id)\n end",
"def new\n @bet = Bet.new\n end",
"def new\n @seccion = \"Nueva Publicación\"\n @publicacion = Publicacion.new\n end",
"def create_api_instance\n facturama_user='prueba'\n facturama_password='pruebas2011'\n is_development = true # true = Modo de pruebas / sandbox, false = Modo de Producción (Timbrado real)\n\n\n #Creacion de una instancia de FacturamaApi\n Facturama::FacturamaApiWeb.new(facturama_user,facturama_password,is_development)\n end",
"def set_banco\n @banco = Banco.find(params[:id])\n end",
"def set_banco\n @banco = Banco.find(params[:id])\n end",
"def set_banco\n @banco = Banco.find(params[:id])\n end",
"def prueba\n if self.moduloCreate.nil? == false\n Modulo.create(nombre: self.moduloCreate)\n end\n end",
"def initialize (banco, numero_cuenta, saldo_cuenta = 0)\n @banco = banco\n @numero_cuenta = numero_cuenta\n @saldo_cuenta = saldo_cuenta\n end",
"def set_banco\n @banco = Banco.find(params[:id])\n end",
"def new_entity\n Taxcalendario::Admin::Client::Entities::Obrigacao.new\n end",
"def new\n \n end",
"def agregar_palabra\n @variable = Variable.all\n @palabra = @bot.palabras.new\n end",
"def new\n @constante_paie = ConstantePaie.new\n end",
"def initialize(name)\n @name = name\n @nota\n #declaracion v instancia\n end",
"def create!\n end",
"def new\n @campeonato = Campeonato.new\n end",
"def set_banesco\n @banesco = Banesco.find(params[:id])\n end",
"def cod_banco\n raise Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando'\n end",
"def set_precio_boleto\n @precio_boleto = PrecioBoleto.find(params[:id])\n end",
"def new\n @fornecedor = Fornecedor.new\n \n end",
"def new\n \t@usuario = Usuario.new\n end",
"def criaParcela(dataVenda, numeroParcela)\n\n novaParcela = Vendaplano.new(vendaplano_params)\n novaParcela.dt_baixa = nil\n novaParcela.recebido_por = nil\n novaParcela.dt_pagto = dataVenda >> numeroParcela\n\n return novaParcela\n end",
"def new\n @annonce = Annonce.new\n end",
"def set_precio_boleto\n\t@precio_boleto = PrecioBoleto.find(params[:id])\n\tend",
"def new\n @diet = Diet.new()\n end",
"def new\n\t\t\n\tend",
"def new\n\t\t\n\tend",
"def create\n \n end",
"def new\n @post = Post.new #creates new instance of the/a post\n #since it's only creating an instance in memory have to create/post method create blw\n end",
"def new\n @mahasiswa = Mahasiswa.new\n end",
"def new\n @paie = @periode.paies.new\n end",
"def instance; end",
"def instance; end",
"def instance; end",
"def new\n @programa = Programa.new\n end",
"def initialize(nombre, cantidad = 1)\n @nombre = nombre\n @cantidad = cantidad\n end",
"def new\n @bond = Bond.new\n end",
"def new\n @disco=Disco.new\n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n @member = Member.new\n \n end",
"def new\n\t\t@bank = Bank.new\n\tend",
"def set_nebulosa\n @nebulosa = Nebulosa.find(params[:id])\n end",
"def create\n @intranet_boleto = Intranet::Boleto.new(intranet_boleto_params)\n\n respond_to do |format|\n if @intranet_boleto.save\n format.html { redirect_to @intranet_boleto, notice: \"Boleto was successfully created.\" }\n format.json { render :show, status: :created, location: @intranet_boleto }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @intranet_boleto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_entity\n Taxcalendario::Admin::Client::Entities::Conta.new\n end",
"def new\n @task = Podcast.new\n end",
"def create\n \n end",
"def initialize(numero, titular, saldo)\n @numero = numero#variavel de instacia\n @titular = titular\n @saldo = saldo\n end",
"def set_abogado_p\n @abogado_p = AbogadoP.find(params[:id])\n end",
"def set_palabra_bolsa\n @palabra_bolsa = PalabraBolsa.find(params[:id])\n end",
"def new\n \n end",
"def new\n # @gossip = Gossip.new\n\n end",
"def create\n end",
"def new\n @periode = Periode.new\n end",
"def create\n @banco = Banco.new(banco_params)\n\n respond_to do |format|\n if @banco.save\n format.html { redirect_to bancos_url, notice: 'Banco was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n \t\n end",
"def new\n\n @clinica = Clinica.new\n @usuario = Usuario.new\n\n end",
"def new\n @business = Business.new\n end",
"def make_reservation\n #@reservation = Reservation.new\n end",
"def create\n end",
"def new\r\n\r\n end",
"def new\n @restaurante = Restaurante.new\n \n end",
"def create\r\n end",
"def show\n @pedido = Pedido.new\n end",
"def new\n @mensaje = Mensaje.new\n end",
"def new\n @avoir = Avoir.new\n end",
"def new\n\t\t@restaurante = Restaurante.new\n\tend",
"def new\n @contra = Contra.new\n end",
"def initialize(name) # aqui ionicializamos nuestro contructor ahora que instanciemos un objeto este ira primero aqui \n @nombre = name #esta es una variable de instancia \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n @estados = Estado.find(:all)\n super\n end",
"def set_bien_de_consumo\n \t@bien_de_consumo = BienDeConsumo.find(params[:id])\n end",
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def new\n \t\t@pokemon = Pokemon.new\n \tend",
"def initialize(p)\n raise TypeError, \"Esperada pregunta como parámetro de entrada\" unless p.is_a? (Pregunta)\n @cabeza = Nodo.new(p, nil, nil)\n @cola = @cabeza\n @total = 1\n end",
"def new\n @pareja = Pareja.new\n @pareja.activo = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pareja }\n end\n end",
"def initialize(name)\n @nombre = name\n end",
"def new\n @member = Member.new\n end",
"def new\n @member = Member.new\n end",
"def new\n @member = Member.new\n end",
"def new\n @member = Member.new\n end",
"def initialize(nome = \"Sem nome\")\r\n @nome = nome\r\n @livros = []\r\n end",
"def new\n @advert = @advert_class.new\n end",
"def create_instance\n create_instances(1).first\n end"
] |
[
"0.6932435",
"0.6585127",
"0.65364414",
"0.64174217",
"0.63053",
"0.6287078",
"0.6286138",
"0.62072134",
"0.6206646",
"0.61825156",
"0.6109247",
"0.6109247",
"0.6109247",
"0.61002296",
"0.60981727",
"0.60583806",
"0.6027515",
"0.60097814",
"0.6004025",
"0.59978026",
"0.5980913",
"0.5960217",
"0.5952081",
"0.591291",
"0.5897959",
"0.5891797",
"0.58726084",
"0.5860053",
"0.5856423",
"0.5848207",
"0.58399904",
"0.5801106",
"0.5789635",
"0.5789635",
"0.5781597",
"0.5774473",
"0.57731485",
"0.5754499",
"0.5746502",
"0.5746502",
"0.5746502",
"0.57412183",
"0.573774",
"0.57230043",
"0.5719721",
"0.57118464",
"0.57118464",
"0.57118464",
"0.57118464",
"0.57118464",
"0.5687106",
"0.5679519",
"0.56780463",
"0.5677072",
"0.5666461",
"0.566493",
"0.5660321",
"0.56559575",
"0.5654356",
"0.5652476",
"0.5650389",
"0.56445557",
"0.56426495",
"0.563802",
"0.5635356",
"0.56351864",
"0.56343037",
"0.56308645",
"0.5630267",
"0.56250185",
"0.5618893",
"0.5617865",
"0.5612259",
"0.5611188",
"0.56091213",
"0.5607974",
"0.5607512",
"0.560727",
"0.56004363",
"0.5598666",
"0.5598666",
"0.5598666",
"0.5598666",
"0.5598666",
"0.55957454",
"0.55953187",
"0.5589525",
"0.5589525",
"0.5589525",
"0.5589525",
"0.55856824",
"0.5580691",
"0.5578514",
"0.55714595",
"0.55628884",
"0.55628884",
"0.55628884",
"0.55628884",
"0.556216",
"0.5560523",
"0.5558941"
] |
0.0
|
-1
|
Aceite Nao tem no manual, foi baseado em boleto modelo enviado pela prefeitura
|
def aceite
'N'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def suivre; end",
"def aplicar_efecto(objeto_espacial_generador_de_choque, objeto_espacial_receptor_de_choque)\n porcentaje_de_masa_actual = @porcentaje_de_masa\n if(porcentaje_de_masa_actual.to_s.include? \"%\")\n porcentaje_de_masa_actual.gsub!(/%/, \"\")\n end\n objeto_espacial_generador_de_choque.masa = objeto_espacial_generador_de_choque.masa + ((porcentaje_de_masa_actual.to_f/100) * objeto_espacial_receptor_de_choque.masa) \n end",
"def zuruecksetzen()\n end",
"def mi_carrera\n\n\tend",
"def auditoria_antes(accion, tabla, objeto)\n auditoria = Auditoria.new\n auditoria.usuario = current_usuario.login\n auditoria.ip = request.remote_ip\n auditoria.accion = accion\n auditoria.tabla = tabla\n auditoria.pista_antes = objeto.to_json\n auditoria.sistema = \"RUE\"\n auditoria.save\n\n auditoria.id\n\n end",
"def controlQxxt(jugadalot)\n \n @modelo = Aliasmodelosiglasorteot.where(:siglasorteo => jugadalot.sorteot.sigla).first.modelocontrolq \n @modelo = @modelo.capitalize.classify.constantize # Esto para convertir string en constante y poder acceder al modelos de Active Record. Scado de este link: https://stackoverflow.com/questions/34757582/using-variables-for-model-names-in-active-record \n c = @modelo.where(:numero => jugadalot.n1.to_i).first\n (c.limite - c.vendida) - jugadalot.monto # retorna la diferencia. # Disponible = (c.limite - c.vendida) \n\n end",
"def aplicar_efecto(objeto_colisionador, objeto_colisionado); end",
"def saveObject(params)\r\n \r\n @solicitudlabexa.usuario_id = params[:usuario][:identificador].to_i\r\n if params[:asignatura].nil?\r\n @solicitudlabexa.asignatura=Asignatura.new\r\n @solicitudlabexa.asignatura.titulacion_id=params[:titulacion][:titulacion_id] unless params[:titulacion].nil? \r\n @solicitudlabexa.asignatura.curso=params[:nivel]\r\n @solicitudlabexa.asignatura.id=0\r\n else\r\n @solicitudlabexa.asignatura_id = params[:asignatura][:id].to_i\r\n end\r\n @solicitudlabexa.fechasol=Date.today\r\n @solicitudlabexa.npuestos=params[:npuestos]\r\n @solicitudlabexa.curso=params[:nivel].to_s == '0' ? 'optativa' : params[:nivel].to_s\r\n @solicitudlabexa.comentarios=Iconv.conv('ascii//translit//ignore', 'utf-8', params[:comentarios].to_s)\r\n @solicitudlabexa.horaini=params[:horaini][:comienzo]\r\n @solicitudlabexa.horafin=params[:horafin][:fin]\r\n @solicitudlabexa.asignado=\"N\"\r\n \r\n pref=\"\"\r\n @especiales=Laboratorio.where('especial=?',\"t\").to_a \r\n for especial in @especiales do\r\n nombre=especial.ssoo.to_s\r\n if params[:\"#{nombre}\"] and params[:\"#{nombre}\"].to_s!='in'\r\n pref+=especial.nombre_lab.to_s+'-'+nombre+'-'+params[:\"#{nombre}\"]+\";\"\r\n end\r\n end\r\n @solicitudlabexa.preferencias=pref\r\n\r\n if params[:fecha]=~ /[0-3]?[0-9]\\-[0-1]?[0-9]\\-[0-9]{4}/\r\n @solicitudlabexa.fecha=formato_europeo(params[:fecha])\r\n else\r\n @solicitudlabexa.fecha=nil\r\n end\r\n end",
"def preencher\n cliente.set CONFIG['cliente']\n seleciona_Cliente.set CONFIG['idcliente']\n tipo_de_operacao.set CONFIG['tipooperacao'] \n cond_pagamento.set CONFIG['condpagamento']\n topico.set CONFIG['topico']\n tipo_venda.set CONFIG['tipovenda'] \n condicoes_de_frete.set CONFIG['condiFrete'] \n apelido.set CONFIG['apelido'] \n botaopesquisar.click\n\n end",
"def enviar_transaccion(trx,idfactura)\n begin\n logger.debug(\"...Inicio enviar transaccion\")\n info = InfoGrupo.where('id_banco= ?',trx['destino']).first\n url = 'http://integra'+info[:numero].to_s+'.ing.puc.cl/api/pagos/recibir/'+trx[0]['_id'].to_s\n #url = 'http://localhost:3000/api/pagos/recibir/'+trx['_id'].to_s\n request = Typhoeus::Request.new(\n url,\n method: :get,\n params:{\n idfactura: idfactura\n },\n headers: { ContentType: \"application/json\"})\n response = request.run\n logger.debug(\"...Fin enviar transaccion\")\n return {:validado => true, :trx => trx}\n rescue => ex\n Applog.debug(ex.message,'enviar_transaccion')\n return {:validado => false, :trx => trx}\nend\nend",
"def create\n @mueble = Mueble.new(mueble_params)\n \n\n respond_to do |format|\n if @mueble.save\n #@modelo = @mueble.modelos.new\n #@modelo.nombre = 'Base'\n #@modelo.codigo=@mueble.nombre.concat('-BASE')\n #@modelo.descripcion= 'Modelo BASE automático (creado al crear el mueble base)' \n #@modelo.save\n format.html { redirect_to @mueble, notice: 'Se ha creado el mueble correctamente' }\n format.json { render :show, status: :created, location: @mueble }\n else\n format.html { render :new }\n format.json { render json: @mueble.errors, status: :unprocessable_entity }\n end\n end\n end",
"def formation; end",
"def preco\n @preco\n end",
"def setorden\n @xml = params[:solicitud]\n @arreglo = Orden.validarRemota(@xml)\n if !(@arreglo.nil?)\n # @cliente = Persona.new(@xml[:cliente])\n # @cliente.save\n\n # @tarjeta = @xml[:tarjeta]\n # @tarjeta = TipoPago.new(@tarjeta)\n # @tarjeta.personas_id = @cliente.id\n # @tarjeta.save\n\n # @recoleccion = Direccion.new(@xml[:direccionrecoleccion])\n @entrega = Direccion.new(@xml[:direccionentrega])\n # @recoleccion.save\n @entrega.save\n\n @orden = Orden.new(@xml[:orden])\n @orden.estado = 'Pendiente por recolectar'\n @orden.personas_id= @arreglo[0]\n @orden.save\n\n @paquete = Paquete.new(@xml[:paquete])\n @paquete.ordens_id = @orden.id\n @paquete.personas_id = @arreglo[0]\n @paquete.save\n\n @historico1= Historico.new(:ordens_id => @orden.id, :direccions_id => @arreglo[2], :tipo => 'Recolectada')\n @historico= Historico.new(:ordens_id => @orden.id, :direccions_id => @entrega.id, :tipo => 'Entregada')\n @historico1.save\n @historico.save\n \n @monto = Enviar.montoTotal(@orden.id)\n @iva = (@monto * 0.12).round(2)\n @montototal = @monto + @iva\n Enviar.compania\n @factura = Factura.new(:companias_id => 1, :ordens_id =>@orden.id , :tipo_pagos_id => @arreglo[1] , :costoTotal => @monto ,:iva => @iva)\n @factura.save\n else\n render \"errorxml\"\n end\n end",
"def sommaire\n @data = Membre.codePostaux\n end",
"def retornoBusqueda()\nreturn @busqueda\nend",
"def corrigiendo_manualmente\n screen_name(\"#{@task.class.to_s}/corrigiendo_manualmente\")\n\n # Need a document\n check_for_target_document\n\n # Read it so we can display it\n @xml_text = get_dummy_text\n\n @am_result = AmResult.where(\"ot_id = #{@ot.id}\").order(\"run_date DESC\").first\n\n respond_to do |format|\n format.html { render action: \"corrigiendo_manualmente\" }\n format.json { head :ok }\n end\n end",
"def set_paciente\r\n @paciente= FichaOdontologica.find(params[:ficha]).paciente\r\n end",
"def obra_params\n params.require(:obra).permit(:descricao, :local)\n end",
"def datos_default\n if new_record?\n lastRecord = MovMovimiento.last\n if lastRecord\n self.hoja = lastRecord.hoja\n end\n\n num_abonos = ComPago.where(com_compra: com_compra).count + 1\n self.concepto = \"Abono #{num_abonos} a compra \\\"#{com_compra.title}\\\"\"\n end\n end",
"def modelo_start\n $productos = 'Productos.csv'\n $clientes = 'Usuarios.csv'\n $vendedores = 'Vendedores.csv'\nend",
"def create\r\n \r\n @valor_oferta = sivic_relatorioscelula_params[:VALR_Oferta] \r\n @valor_oferta = @valor_oferta.gsub('.', '')\r\n @valor_oferta = @valor_oferta.gsub(',', '.').to_f\r\n @sivic_relatorioscelula = SivicRelatorioscelula.new(sivic_relatorioscelula_params)\r\n @sivic_relatorioscelula.VALR_Oferta = @valor_oferta\r\n\r\n\r\n respond_to do |format|\r\n if @sivic_relatorioscelula.save\r\n format.html { redirect_to @sivic_relatorioscelula, notice: 'Registro inserido com sucesso.' }\r\n format.json { render action: 'show', status: :created, location: @sivic_relatorioscelula }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @sivic_relatorioscelula.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def import_bien b\n\n # Good location\n good_address = {}\n loc = BienEmplacement.new\n\tloc.pays = \"France\"\n\tloc.code_postal = b[\"bien_cp\"]\n\tloc.ville = b[\"bien_ville\"]\n\n\tref = b[\"bien_ref\"]\n\treturn if ref.nil? or ref.empty?\n\t\n\ttransaction_type = BienTransaction.where(:nom => TRANSACTION_MATCHING[b['type_transaction'].to_i]).first\n\treturn if transaction_type.nil?\n\t\n\tcat = BienType.find_or_create CODE_MATCHING[b[\"type_bien\"].to_i]\n \n\tnb = Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n nb = Bien.new if nb.nil?\n\t\n\tdesc = b[\"bien_descriptif_fr\"]\n\tnb.is_accueil = false\n\t# nb.is_accueil = true if b[\"TEXTE_MAILING\"] && (b[\"TEXTE_MAILING\"].to_s.downcase =~ /.*virtual.*touch.*/)\n\n nb.passerelle = @passerelle\n nb.reference = ref\n nb.bien_type = cat\n nb.bien_transaction = transaction_type\n nb.bien_emplacement = loc\n nb.nb_piece = b[\"bien_nb_pieces\"]\n nb.surface = b[\"bien_surf_habitable\"]\n nb.nb_chambre = b[\"bien_nb_chambres\"]\n nb.surface_terrain = b[\"bien_surf_terrain\"]\n nb.titre = CODE_MATCHING[b[\"type_bien\"].to_i]\n nb.prix = b[\"bien_prix\"] if (b[\"bien_prix_affiche\"].to_i != 0)\n nb.description = desc\n\t\n\tnb.statut = 'new'\n nb.save!\n\t\n\tnb.valeur_dpe = b[\"bien_conso_energie\"]\n\tnb.valeur_ges = b[\"bien_emission_ges\"]\n # nb.classe_dpe = b['bilan_energie']\n # nb.class_ges = b['bilan_ges']\n\t\t\n\t# If new images : Drop old images, add current images\n if b[\"photos\"] && b[\"photos\"][\"photo\"]\n # un-attach old\n\t nb.bien_photos.each{ |photo|\n\t\t photo.bien = nil\n\t\t photo.save!\n\t }\n pl = b[\"photos\"][\"photo\"]\n \n # When there only exists a single image, +pl+ will directly be the hash\n pl = [pl] unless pl.kind_of? Array\n # Map photo-hashes to medias, filter out failures, and add medias to good\n\t number = 0\n\t counter = 0\n pl.map { |p| import_local_media(p.to_s,(counter+=1),nb,p.to_s) }\n end\n\t\n nb.save!\n\n return\n\tend",
"def modelo_carne_build_data_right(doc, boleto, colunas, linhas)\n # LOGOTIPO do BANCO\n doc.image boleto.logotipo, x: (colunas[2] - 0.11), y: linhas[0]\n\n # Numero do banco\n doc.moveto x: colunas[4], y: linhas[0]\n doc.show \"#{boleto.banco}-#{boleto.banco_dv}\", tag: :grande\n\n # linha digitavel\n doc.moveto x: colunas[6], y: linhas[0]\n doc.show boleto.codigo_barras.linha_digitavel, tag: :media\n\n # local de pagamento\n doc.moveto x: colunas[2], y: linhas[1]\n doc.show boleto.local_pagamento\n\n # vencimento\n doc.moveto x: colunas[11], y: linhas[1]\n doc.show boleto.data_vencimento.to_s_br\n\n # cedente\n doc.moveto x: colunas[2], y: linhas[2]\n doc.show boleto.cedente\n\n # agencia/codigo cedente\n doc.moveto x: colunas[11], y: linhas[2]\n doc.show boleto.agencia_conta_boleto\n\n # data do documento\n doc.moveto x: colunas[2], y: linhas[3]\n doc.show boleto.data_documento.to_s_br if boleto.data_documento\n\n # numero documento\n doc.moveto x: colunas[3], y: linhas[3]\n doc.show boleto.documento_numero\n\n # especie doc.\n doc.moveto x: colunas[8], y: linhas[3]\n doc.show boleto.especie_documento\n\n # aceite\n doc.moveto x: colunas[9], y: linhas[3]\n doc.show boleto.aceite\n\n # dt processamento\n doc.moveto x: colunas[10], y: linhas[3]\n doc.show boleto.data_processamento.to_s_br if boleto.data_processamento\n\n # nosso numero\n doc.moveto x: colunas[11], y: linhas[3]\n doc.show boleto.nosso_numero_boleto\n\n # uso do banco\n ## nada...\n\n # carteira\n doc.moveto x: colunas[3], y: linhas[4]\n doc.show boleto.carteira\n\n # especie\n doc.moveto x: colunas[5], y: linhas[4]\n doc.show boleto.especie\n\n # quantidade\n doc.moveto x: colunas[7], y: linhas[4]\n doc.show boleto.quantidade\n\n # valor documento\n doc.moveto x: colunas[8], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # valor do documento\n doc.moveto x: colunas[11], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # Instruções\n doc.moveto x: colunas[2], y: linhas[5]\n doc.show boleto.instrucao1\n doc.moveto x: colunas[2], y: linhas[6]\n doc.show boleto.instrucao2\n doc.moveto x: colunas[2], y: linhas[7]\n doc.show boleto.instrucao3\n doc.moveto x: colunas[2], y: linhas[8]\n doc.show boleto.instrucao4\n doc.moveto x: colunas[2], y: linhas[9]\n doc.show boleto.instrucao5\n doc.moveto x: colunas[2], y: linhas[10]\n doc.show boleto.instrucao6\n\n # Sacado\n doc.moveto x: colunas[2], y: linhas[11]\n if boleto.sacado && boleto.sacado_documento\n doc.show \"#{boleto.sacado} - #{boleto.sacado_documento.formata_documento}\"\n end\n\n # Sacado endereço\n doc.moveto x: colunas[2], y: linhas[12]\n doc.show boleto.sacado_endereco.to_s\n\n # codigo de barras\n # Gerando codigo de barra com rghost_barcode\n if boleto.codigo_barras\n doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.2 cm', x: colunas[2],\n y: linhas[14])\n end\n end",
"def test_transferencia\n origem = Conta.create(:nome => 'Origem', :tipo_conta => TipoConta.find(:first))\n destino = Conta.create(:nome => 'Destino', :tipo_conta => TipoConta.find(:last))\n lanc = origem.transferir(destino,:empresa => Empresa.find(:first), :data => Time.now, :tipo_documento => TipoDocumento.find(:first), :valor => 200)\n assert lanc\n assert_same lanc.origem.id, origem.id\n assert_same lanc.destino.id, destino.id\n end",
"def create\n @tipomaquinat = Tipomaquinat.new(tipomaquinat_params)\n #@tipomaquinat = Tipomaquinat.new\n #@tipomaquinat.id=401\n #@tipomaquinat.tipomaquina = \"KLK\" #params.require(:tipomaquinat).permit(:tipomaquina)\n #@tipomaquinat.descripcion = \"YOOOO\" #params.require(:tipomaquinat).permit(:descripcion)\n #descripcion\n\n # params.require(:tipomaquinat).permit(:tipomaquina, :descripcion,\n\n respond_to do |format|\n if @tipomaquinat.save\n format.html { redirect_to @tipomaquinat, notice: 'Tipomaquinat was successfully created.' }\n format.json { render :show, status: :created, location: @tipomaquinat }\n else\n format.html { render :new }\n format.json { render json: @tipomaquinat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cria_especialidade_valida\n @especialidadevalida = {\n :Nome => \"EspecialidadeBemIncomumPraTeste\",\n :Descricao => \"especdiferente\",\n :ativo => 1 \n }\nend",
"def premio_manual_params\n params.require(:premio_manual).permit(:nformato, :fecha, :maquina, :valor, :coninicial, :confinal, :dni, :nomcliente, :apepaterno, :apematerno)\n end",
"def busqueda\n \t@pagadero = Payment.find_by_id(params[:id])\n \t# @imp = @pagadero.to_s\n end",
"def enviar_factura(factura)\n begin\n logger.debug(\"...Iniciar enviar factura\")\n info = InfoGrupo.where('id_grupo = ?',factura['cliente']).first\n url = 'http://integra'+info[:numero].to_s+'.ing.puc.cl/api/facturas/recibir/'+factura['_id'].to_s\n #url = 'http://localhost:3000/api/facturas/recibir/'+factura['_id'].to_s\n request = Typhoeus::Request.new(\n url,\n method: :get,\n headers: { ContentType: \"application/json\"})\n response = request.run \n logger.debug(\"...Fin enviar factura\")\n return {:validado => true, :factura => factura}\n rescue => ex\n Applog.debug(ex.message,'enviar_factura')\n return {:validado => false, :factura => factura}\n end\nend",
"def create\n # @post.user = current_user\n # @user = User.find(params[:user_id])\n # @model = @user.models.create(params[:model])\n\n # On construit le model pour l utilsateur courant\n @model = current_user.models.build(params[:model])\n #Equivault a ces deux lignes\n # @model = Model.new(params[:model])\n # @model.user = current_user\n\n #On appelle la procedure objSize\n # @model.name= objSize\n # @model.name = \"test\"\n\n @model.scale = 1\n @model.modelPath = @model.avatar.url\n @model.bbX=100\n @model.bbY=100\n @model.bbZ=100\n\n respond_to do |format|\n\n if @model.save\n get_volume_value\n format.html { redirect_to @model, notice: 'Model was successfully created.' }\n format.json { render json: @model, status: :created, location: @model }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @model.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n @lancamentorapido = Lancamentorapido.new(params[:lancamentorapido])\n \n #Validações padrão\n @lancamentorapido.tipo = :receita if @lancamentorapido.tipo.blank?\n @lancamentorapido.valor = 0 if @lancamentorapido.valor.blank? \n \n respond_to do |format|\n if @lancamentorapido.save\n format.html { redirect_to lancamentorapidos_path, notice: 'Lancamento was successfully created.' } \n# format.html { redirect_to '/lancamentorapidos'}\n format.json { render json: lancamentorapidos_path, status: :created, location: @lancamentorapido }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lancamentorapido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @solicitudlabexa = Solicitudlabexa.new(params[:solicitudlabexa])\n @solicitudlabexa.usuario_id = @usuario_actual.id\n @solicitudlabexa.asignatura_id = params[:asignatura][:id].to_i unless params[:asignatura].nil?\n @solicitudlabexa.fechasol=Date.today\n @solicitudlabexa.npuestos=params[:npuestos]\n @solicitudlabexa.curso=params[:nivel].to_s == \"0\" ? \"optativa\" : params[:nivel].to_s\n @solicitudlabexa.comentarios=Iconv.conv('ascii//translit//ignore', 'utf-8', params[:comentarios].to_s)\n @solicitudlabexa.horaini=params[:horaini][:comienzo]\n @solicitudlabexa.horafin=params[:horafin][:fin]\n @solicitudlabexa.asignado=false\n \n if params[:fecha]=~ /[0-3]?[0-9]\\-[0-1]?[0-9]\\-[0-9]{4}/\n nfecha=formato_europeo(params[:fecha])\n #nfechaini=params[:fechaini].to_s.split('-')\n #nfechaini=fecha[2]+\"-\"+fecha[1]+\"-\"+fecha[0]\n @solicitudlabexa.fecha=nfecha.to_date\n else\n @solicitudlabexa.fecha=nil\n end\n\n pref=\"\"\n @especiales=Laboratorio.where('especial=?',\"t\").to_a\n for especial in @especiales do\n nombre=especial.ssoo.to_s\n if params[:\"#{nombre}\"].to_s!='in'\n pref+=especial.nombre_lab.to_s+'-'+nombre+'-'+params[:\"#{nombre}\"]+\";\"\n end\n end\n @solicitudlabexa.preferencias=pref\n @solicitudlabexa.tipo=\"P\"\n \n respond_to do |format|\n\n if @solicitudlabexa.save \n CorreoTecnicos::emitesolicitudexamen(@solicitudlabexa,params[:fecha],\"\",\"Nueva \").deliver_later \n @solicitudlabexas = Solicitudlabexa.where(\"usuario_id = ? \",@usuario_actual.id).to_a\n format.html { redirect_to :action => \"index\" }\n format.xml { render :xml => @solicitudlabexas, :status => :created, :location => @solicitudlabexas }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @solicitudlabexas.errors, :status => :unprocessable_entity }\n end\n \n end\n \n end",
"def create\n @produto = Produto.new(params[:produto])\n @produto.empresa = session[:usuario].empresa\n \n params[:produto][:preco_compra] = converte_valor_banco params[:produto][:preco_compra]\n params[:produto][:preco_venda] = converte_valor_banco params[:produto][:preco_venda]\n\n respond_to do |format|\n if @produto.save\n format.html { redirect_to @produto, notice: 'Produto was successfully created.' }\n format.json { render json: @produto, status: :created, location: @produto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def urna_params\n params.require(:urna).permit(:escola, :numero, :localidade, :total_votacao, :eleicao_id, :finalizada, :secoes, :eleitores)\n end",
"def partido\n localidad.partido\n end",
"def set_nombr_comune\n begin\n @nombr_comune = NombreComun.find(params[:id])\n rescue\n @nombr_comune={:nombre_comun => nil}\n end\n end",
"def from_ficha\r\n ficha = FichaOdontologica.find(params[:ficha])\r\n @paciente= ficha.paciente\r\n @area= Area.find_by_nombre('Odontología')\r\n @consulta= ConsultaOdontologica.new\r\n get_doctores_odontologia\r\n end",
"def solicitudes_atrasadas\n end",
"def save_atributos\n\n unless @pre.nil?\n @pre[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@pre[:valor][key],campo:'precio')\n end\n end\n\n unless @compraAtributo.nil?\n @compraAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@compraAtributo[:valor][key],campo:'compra')\n end\n end\n\n unless @polizaAtributo.nil?\n @polizaAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@polizaAtributo[:valor][key],campo:'poliza')\n end\n end\n\n unless @tipovehiculoAtributo.nil?\n @tipovehiculoAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@tipovehiculoAtributo[:valor][key],campo:'tipovehiculo')\n end\n end\n\n unless @tipoproductoAtributo.nil?\n @tipoproductoAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@tipoproductoAtributo[:valor][key],campo:'tipoproducto')\n end \n end\n \n unless @aseguradoraAtributo.nil?\n @aseguradoraAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@aseguradoraAtributo[:valor][key],campo:'aseguradora')\n end\n end\n \n unless @destacadoAtributo.nil?\n @destacadoAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@destacadoAtributo[:valor][key],campo:'destacado')\n end\n end\n\n unless @vigenciaAtributo.nil?\n @vigenciaAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@vigenciaAtributo[:valor][key],campo:'vigencia')\n end\n end\n\n end",
"def create\n @prueba = Prueba.new(prueba_params)\n\n cantidadAlmacenada = @prueba.cantidad_almacenada\n cantidadDesechada = @prueba.cantidad_desechada\n\n @prueba.cantidad = cantidadAlmacenada + cantidadDesechada \n\n respond_to do |format|\n if @prueba.save\n\n @etiqueta = Etiqueta.new\n\n etiquetaAnalisis = @prueba.etiqueta.etiqueta\n idAnalisis = @prueba.id\n idAnalisisString = idAnalisis.to_s\n\n @etiqueta.etiqueta = etiquetaAnalisis + idAnalisisString + \"-\"\n @etiqueta.formato_id = 2\n @etiqueta.save\n\n format.html { redirect_to etiqueta_mostrar_path(@etiqueta.id), notice: 'Prueba was successfully created.' }\n format.json { render :show, status: :created, location: @prueba }\n else\n format.html { render :new }\n format.json { render json: @prueba.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # valor = params[:pedido][:valor]\n # params[:pedido][:valor] = valor.split( ',').join('.')\n\n #Esta verificacao e feita para evitar que quando um NOVO pedido nao possa ser confirmado por falta de itens disponiveis, os itens do pedido não sejam decrescidos.\n if @pedido.situacao == \"Em processamento\"\n @flag_situacao = 1\n elsif @pedido.situacao == \"Confirmado\"\n @flag_situacao = 2\n end\n\n# descricao = \"\"\n @pedido.situacao = \"Em processamento\"\n @pedido.save\n @pedido.cliente = Cliente.find_by_id(params[:cliente_id].to_i)\n\n pa = @pedido.pedidos_acompanhamentos\n acompanhamento_editado = []\n acompanhamento_novo = []\n acompanhamentos = Acompanhamento.where(:disponibilidade => true).count\n for i in 0...acompanhamentos do\n acompanhamento=nil\n if !params[\"acompanhamento_#{i}\"].blank?\n acompanhamento = Acompanhamento.find(params[\"acompanhamento_#{i}\"])\n end\n if (( @pedido.acompanhamentos.include? acompanhamento) && ( !params[\"acompanhamento_#{i}\"].blank?) && (params[\"quantidade_acompanhamento_#{i}\"].to_i != @pedido.pedidos_acompanhamentos.find_by_acompanhamento_id(acompanhamento.id).quantidade) && (@flag_situacao != 1) )\n atualiza_acompanhamento = @pedido.pedidos_acompanhamentos.find_by_acompanhamento_id(params[\"acompanhamento_#{i}\"])\n acompanhamento.acrescer(atualiza_acompanhamento.quantidade) #Aqui adiciona o que tinha ficado no pedido antes de ser editado.\n atualiza_acompanhamento.quantidade = params[\"quantidade_acompanhamento_#{i}\"].to_i\n acompanhamento_editado << atualiza_acompanhamento\n atualiza_acompanhamento.save\n elsif (( @pedido.acompanhamentos.include? acompanhamento) && ( !params[\"acompanhamento_#{i}\"].blank?) && (params[\"quantidade_acompanhamento_#{i}\"].to_i == @pedido.pedidos_acompanhamentos.find_by_acompanhamento_id(acompanhamento.id).quantidade))\n atualiza_acompanhamento = @pedido.pedidos_acompanhamentos.find_by_acompanhamento_id(params[\"acompanhamento_#{i}\"])\n acompanhamento.acrescer(atualiza_acompanhamento.quantidade)\n acompanhamento_editado << atualiza_acompanhamento\n elsif ( !(@pedido.acompanhamentos.include? acompanhamento) && ( !params[\"acompanhamento_#{i}\"].blank?) && ( !params[\"quantidade_acompanhamento_#{i}\"].nil?))\n acompanhamento_novo << @pedido.pedidos_acompanhamentos.create!(:acompanhamento_id => params[\"acompanhamento_#{i}\"], :quantidade => params[\"quantidade_acompanhamento_#{i}\"])\n #acompanhamento_novo.last.acompanhamento.decrescer(acompanhamento_novo.last.quantidade)\n end\n end\n if @flag_situacao != 1\n acompanhamentos_removidos = pa - acompanhamento_editado\n acompanhamentos_removidos = acompanhamentos_removidos - acompanhamento_novo\n acompanhamentos_removidos.each do |acompanhamento_removido|\n acompanhamento_removido.acompanhamento.acrescer(acompanhamento_removido.quantidade)\n acomp = Acompanhamento.find_by_id(acompanhamento_removido.acompanhamento_id)\n @pedido.pedidos_acompanhamentos.delete(acompanhamento_removido)\n @pedido.acompanhamentos.delete(acomp)\n acompanhamento_removido.destroy\n end\n end\n\n proteina_novo = []\n pc = @pedido.pedidos_proteinas\n proteina_editado = []\n proteinas = Proteina.where(:disponibilidade => true).count #tem que ver outra quantidade pra colocar, pq senao pode dar ruim, caso alguma proteina seja desativada.\n #proteinas = @pedido.pedidos_proteinas.count talvez seja esse o tamanho ideal... mas vamos ver... pensar\n for i in 0..proteinas do\n proteina=nil\n if !params[\"proteina_#{i}\"].blank?\n proteina = Proteina.find(params[\"proteina_#{i}\"])\n end\n if (( @pedido.proteinas.include? proteina) && ( !params[\"proteina_#{i}\"].blank?) && (params[\"quantidade_proteina_#{i}\"].to_i != @pedido.pedidos_proteinas.find_by_proteina_id(proteina.id).quantidade) && (@flag_situacao != 1) )\n atualiza_proteina = @pedido.pedidos_proteinas.find_by_proteina_id(params[\"proteina_#{i}\"])\n proteina.acrescer(atualiza_proteina.quantidade) #Aqui adiciona o que tinha ficado no pedido antes de ser editado.\n atualiza_proteina.quantidade = params[\"quantidade_proteina_#{i}\"].to_i\n proteina_editado << atualiza_proteina # Ver se está adicionando duas instancias de pedidos_proteinas no vetor\n atualiza_proteina.save\n elsif (( @pedido.proteinas.include? proteina) && ( !params[\"proteina_#{i}\"].blank?) && (params[\"quantidade_proteina_#{i}\"].to_i == @pedido.pedidos_proteinas.find_by_proteina_id(proteina.id).quantidade) && (@flag_situacao != 1))\n atualiza_proteina = @pedido.pedidos_proteinas.find_by_proteina_id(params[\"proteina_#{i}\"])\n proteina.acrescer(atualiza_proteina.quantidade) #Aqui adiciona o que tinha ficado no pedido antes de ser editado.\n proteina_editado << atualiza_proteina\n # Aqui acho que poderia não fazer nada...\n elsif ( !(@pedido.proteinas.include? proteina) && ( !params[\"proteina_#{i}\"].blank?) && ( !params[\"quantidade_proteina_#{i}\"].nil?) )\n proteina_novo << @pedido.pedidos_proteinas.create!(:proteina_id => params[\"proteina_#{i}\"], :quantidade => params[\"quantidade_proteina_#{i}\"])\n #proteina_novo.last.proteina.decrescer(proteina_novo.last.quantidade)\n # Cria nova proteina adicionada no pedido e remove a quantidade da qtd disponivel no cardapio.\n end\n end\n #### Removendo proteinas após edição ####\n\n if @flag_situacao != 1\n proteinas_removidos = pc - proteina_editado\n proteinas_removidos = proteinas_removidos - proteina_novo\n proteinas_removidos.each do |proteina_removido|\n proteina_removido.proteina.acrescer(proteina_removido.quantidade)\n prote = Proteina.find_by_id(proteina_removido.proteina_id)\n @pedido.pedidos_proteinas.delete(proteina_removido)\n @pedido.proteinas.delete(prote)\n proteina_removido.destroy\n end\n end\n ##################### Fim proteinas removidos #####################\n\n\n guarnicao_novo = []\n pc = @pedido.pedidos_guarnicoes\n guarnicao_editado = []\n guarnicoes = Guarnicao.where(:disponibilidade => true).count\n for i in 0..guarnicoes do\n guarnicao=nil\n if !params[\"guarnicao_#{i}\"].blank?\n guarnicao = Guarnicao.find(params[\"guarnicao_#{i}\"])\n end\n if (( @pedido.guarnicoes.include? guarnicao) && ( !params[\"guarnicao_#{i}\"].blank?) && (params[\"quantidade_guarnicao_#{i}\"].to_i != @pedido.pedidos_guarnicoes.find_by_guarnicao_id(guarnicao.id).quantidade) && (@flag_situacao != 1))\n atualiza_guarnicao = @pedido.pedidos_guarnicoes.find_by_guarnicao_id(params[\"guarnicao_#{i}\"])\n guarnicao.acrescer(atualiza_guarnicao.quantidade)\n atualiza_guarnicao.quantidade = params[\"quantidade_guarnicao_#{i}\"].to_i\n guarnicao_editado << atualiza_guarnicao\n atualiza_guarnicao.save\n elsif (( @pedido.guarnicoes.include? guarnicao) && ( !params[\"guarnicao_#{i}\"].blank?) && (params[\"quantidade_guarnicao_#{i}\"].to_i == @pedido.pedidos_guarnicoes.find_by_guarnicao_id(guarnicao.id).quantidade) && (@flag_situacao != 1))\n atualiza_guarnicao = @pedido.pedidos_guarnicoes.find_by_guarnicao_id(params[\"guarnicao_#{i}\"])\n guarnicao.acrescer(atualiza_guarnicao.quantidade)\n guarnicao_editado << atualiza_guarnicao\n elsif ( !(@pedido.guarnicoes.include? guarnicao) && ( !params[\"guarnicao_#{i}\"].blank?) && ( !params[\"quantidade_guarnicao_#{i}\"].nil?))\n guarnicao_novo << @pedido.pedidos_guarnicoes.create!(:guarnicao_id => params[\"guarnicao_#{i}\"], :quantidade => params[\"quantidade_guarnicao_#{i}\"])\n #guarnicao_novo.last.guarnicao.decrescer(guarnicao_novo.last.quantidade)\n end\n end\n\n #### Removendo proteinas após edição ####\n if @flag_situacao != 1\n guarnicoes_removidos = pc - guarnicao_editado\n guarnicoes_removidos = guarnicoes_removidos - guarnicao_novo\n guarnicoes_removidos.each do |guarnicao_removido|\n guarnicao_removido.guarnicao.acrescer(guarnicao_removido.quantidade)\n guarni = Guarnicao.find_by_id(guarnicao_removido.guarnicao_id)\n @pedido.pedidos_guarnicoes.delete(guarnicao_removido)\n @pedido.guarnicoes.delete(guarni)\n guarnicao_removido.destroy\n end\n end\n ##################### Fim guarnicoes removidos #####################\n\n\n salada_novo = []\n pc = @pedido.pedidos_saladas\n salada_editado = []\n saladas = Salada.where(:disponibilidade => true).count\n for i in 0..saladas do\n salada=nil\n if !params[\"salada_#{i}\"].blank?\n salada = Salada.find(params[\"salada_#{i}\"])\n end\n if (( @pedido.saladas.include? salada) && ( !params[\"salada_#{i}\"].blank?) && (params[\"quantidade_salada_#{i}\"].to_i != @pedido.pedidos_saladas.find_by_salada_id(salada.id).quantidade) && (@flag_situacao != 1))\n atualiza_salada = @pedido.pedidos_saladas.find_by_salada_id(params[\"salada_#{i}\"])\n salada.acrescer(atualiza_salada.quantidade)\n atualiza_salada.quantidade = params[\"quantidade_salada_#{i}\"].to_i\n salada_editado << atualiza_salada\n atualiza_salada.save\n elsif (( @pedido.saladas.include? salada) && ( !params[\"salada_#{i}\"].blank?) && (params[\"quantidade_salada_#{i}\"].to_i == @pedido.pedidos_saladas.find_by_salada_id(salada.id).quantidade) && (@flag_situacao != 1))\n atualiza_salada = @pedido.pedidos_saladas.find_by_salada_id(params[\"salada_#{i}\"])\n salada.acrescer(atualiza_salada.quantidade)\n salada_editado << atualiza_salada\n elsif ( !(@pedido.saladas.include? salada) && ( !params[\"salada_#{i}\"].blank?) && ( !params[\"quantidade_salada_#{i}\"].nil?))\n salada_novo << @pedido.pedidos_saladas.create!(:salada_id => params[\"salada_#{i}\"], :quantidade => params[\"quantidade_salada_#{i}\"])\n #salada_novo.last.salada.decrescer(salada_novo.last.quantidade)\n end\n end\n\n #### Removendo proteinas após edição ####\n if @flag_situacao != 1\n saladas_removidos = pc - salada_editado\n saladas_removidos = saladas_removidos - salada_novo\n saladas_removidos.each do |salada_removido|\n salada_removido.salada.acrescer(salada_removido.quantidade)\n salad = Salada.find_by_id(salada_removido.salada_id)\n @pedido.pedidos_saladas.delete(salada_removido)\n @pedido.saladas.delete(salad)\n salada_removido.destroy\n end\n end\n ##################### Fim saladas removidos #####################\n\n\n bebida_novo = []\n pc = @pedido.pedidos_bebidas\n bebida_editado = []\n bebidas = Bebida.where(:disponibilidade => true).count\n for i in 0..bebidas do\n bebida=nil\n if !params[\"bebida_#{i}\"].blank?\n bebida = Bebida.find(params[\"bebida_#{i}\"])\n end\n if (( @pedido.bebidas.include? bebida) && ( !params[\"bebida_#{i}\"].blank?) && (params[\"quantidade_bebida_#{i}\"].to_i != @pedido.pedidos_bebidas.find_by_bebida_id(bebida.id).quantidade) && (@flag_situacao != 1))\n atualiza_bebida = @pedido.pedidos_bebidas.find_by_bebida_id(params[\"bebida_#{i}\"])\n bebida.acrescer(atualiza_bebida.quantidade)\n atualiza_bebida.quantidade = params[\"quantidade_bebida_#{i}\"].to_i\n bebida_editado << atualiza_bebida\n atualiza_bebida.save\n elsif (( @pedido.bebidas.include? bebida) && ( !params[\"bebida_#{i}\"].blank?) && (params[\"quantidade_bebida_#{i}\"].to_i == @pedido.pedidos_bebidas.find_by_bebida_id(bebida.id).quantidade) && (@flag_situacao != 1))\n atualiza_bebida = @pedido.pedidos_bebidas.find_by_bebida_id(params[\"bebida_#{i}\"])\n bebida.acrescer(atualiza_bebida.quantidade)\n bebida_editado << atualiza_bebida\n elsif ( !(@pedido.bebidas.include? bebida) && ( !params[\"bebida_#{i}\"].blank?) && ( !params[\"quantidade_bebida_#{i}\"].nil?))\n bebida_novo << @pedido.pedidos_bebidas.create!(:bebida_id => params[\"bebida_#{i}\"], :quantidade => params[\"quantidade_bebida_#{i}\"])\n #bebida_novo.last.bebida.decrescer(bebida_novo.last.quantidade)\n end\n end\n\n #### Removendo proteinas após edição ####\n if @flag_situacao != 1\n bebidas_removidos = pc - bebida_editado\n bebidas_removidos = bebidas_removidos - bebida_novo\n bebidas_removidos.each do |bebida_removido|\n bebida_removido.bebida.acrescer(bebida_removido.quantidade)\n bebid = Bebida.find_by_id(bebida_removido.bebida_id)\n @pedido.pedidos_bebidas.delete(bebida_removido)\n @pedido.bebidas.delete(bebid)\n bebida_removido.destroy\n end\n end\n ##################### Fim bebidas removidos #####################\n\n\n sobremesa_novo = []\n pc = @pedido.pedidos_sobremesas\n sobremesa_editado = []\n sobremesas = Sobremesa.where(:disponibilidade => true).count\n for i in 0..sobremesas do\n sobremesa=nil\n if !params[\"sobremesa_#{i}\"].blank?\n sobremesa = Sobremesa.find(params[\"sobremesa_#{i}\"])\n end\n if (( @pedido.sobremesas.include? sobremesa) && ( !params[\"sobremesa_#{i}\"].blank?) && (params[\"quantidade_sobremesa_#{i}\"].to_i != @pedido.pedidos_sobremesas.find_by_sobremesa_id(sobremesa.id).quantidade) && (@flag_situacao != 1))\n atualiza_sobremesa = @pedido.pedidos_sobremesas.find_by_sobremesa_id(params[\"sobremesa_#{i}\"])\n sobremesa.acrescer(atualiza_sobremesa.quantidade)\n atualiza_sobremesa.quantidade = params[\"quantidade_sobremesa_#{i}\"].to_i\n sobremesa_editado << atualiza_sobremesa\n atualiza_sobremesa.save\n elsif (( @pedido.sobremesas.include? sobremesa) && ( !params[\"sobremesa_#{i}\"].blank?) && (params[\"quantidade_sobremesa_#{i}\"].to_i == @pedido.pedidos_sobremesas.find_by_sobremesa_id(sobremesa.id).quantidade) && (@flag_situacao != 1))\n atualiza_sobremesa = @pedido.pedidos_sobremesas.find_by_sobremesa_id(params[\"sobremesa_#{i}\"])\n sobremesa_editado << atualiza_sobremesa\n elsif ( !(@pedido.sobremesas.include? sobremesa) && ( !params[\"sobremesa_#{i}\"].blank?) && ( !params[\"quantidade_sobremesa_#{i}\"].nil?))\n sobremesa_novo << @pedido.pedidos_sobremesas.create!(:sobremesa_id => params[\"sobremesa_#{i}\"], :quantidade => params[\"quantidade_sobremesa_#{i}\"])\n #sobremesa_novo.last.sobremesa.decrescer(sobremesa_novo.last.quantidade)\n end\n end\n\n #### Removendo sobremesas após edição ####\n if @flag_situacao != 1\n sobremesas_removidos = pc - sobremesa_editado\n sobremesas_removidos = sobremesas_removidos - sobremesa_novo\n sobremesas_removidos.each do |sobremesa_removido|\n sobremesa_removido.sobremesa.acrescer(sobremesa_removido.quantidade)\n sobremes = Sobremesa.find_by_id(sobremesa_removido.sobremesa_id)\n @pedido.pedidos_sobremesas.delete(sobremesa_removido)\n @pedido.sobremesas.delete(sobremes)\n sobremesa_removido.destroy\n end\n end\n\n # debugger\n\n# puts \"teste\"\n ##################### Fim sobremesas removidos #####################\n\n # proteinas = Proteina.where(:disponibilidade => true, :tipo => \"Carne\").count\n # for i in 0...proteinas do\n # if !params[\"proteina_#{i}\"].blank?\n # @pedido.pedidos_proteinas.new(:proteina_id => params[\"proteina_#{i}\"], :quantidade => params[\"quantidade_#{i}\"])\n # end\n # end\n# parametros = pedido_params\n\n\n # itens = params[:pedido][:item_de_pedidos_attributes]\n # vetor_itens = params[:pedido][:item_de_pedidos_attributes].to_a\n # if !itens.nil?\n # for indice in 0..vetor_itens.count do\n # if vetor_itens[indice] != nil\n # puts \"DELETAR\"\n # if vetor_itens[indice][1][:_destroy] == \"1\"\n # codigo_item = vetor_itens[indice][1]\n # item = ItemDePedido.find(codigo_item.to_i)\n # item.destroy\n # itens.delete(\"#{vetor_itens[indice][0]}\")\n # elsif vetor_itens[indice][1][:produto_id].blank?\n # puts \"IGNORAR\"\n # itens.delete(\"#{vetor_itens[indice][0]}\")\n # #itens.delete(\"#{i}\")\n # end\n # end\n # end\n # parametros[:item_de_pedidos_attributes].replace(itens)\n # end\n\n # if !itens.blank?\n # @pedido.calcular_valor\n # end\n# @pedido.valor = 0 + params[:valor].to_f\n # end\n # if !params[:arroz].nil?\n # descricao = \"Arroz \"+ params[:arroz] + \",\"\n # end\n # if params[:feijao] = \"Sim\"\n # descricao = descricao + \" Feijao, \"\n # end\n\n # if params[:farofa] == \"Sim\"\n # descricao = descricao + \" Farofa,\"\n # end\n\n # descricao = descricao + params[:proteina] + \", \" + params[:acompanhamento] + \" Salada: \"+ params[:salada]\n # @pedido.descricao = descricao\n #@pedido.calcular_valor\n\n #parametros[:valor] = @pedido.valor\n respond_to do |format|\n if @pedido.update(pedido_params)\n @pedido.calcular_valor\n @pedido.conta.calcular_saldo\n #proteina = @pedido.proteina\n #carne.decrescer\n format.html { redirect_to @pedido, notice: 'Pedido atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def troca\n @remetente = Sobrevivente.where(id: params[:de]).first\n @destinatario = Sobrevivente.where(id: params[:para]).first\n\n enviar = {agua: 1, comida: 2, medicamento: 3, municao: 4}\n receber = {agua: 0, comida: 2, medicamento: 3, municao: 8}\n\n trocou = @remetente.troca(@destinatario, enviar, receber)\n\n render json: { status: trocou }\n end",
"def urna_params\n params.require(:urna).permit(:escola, :numero, :localidade, :total_votacao, :eleicao_id)\n end",
"def create\n @movimento = Movimento.new(params[:movimento])\n @movimento.entidade_id = current_usuario.entidade_id\n @movimento.valor = params[:movimento][:valor].gsub(',','.')\n @movimento.usuario_id = current_usuario.id\n #@movimento.updated_by = current_usuario.id\n @movimento.data_vencimento = @movimento.data_pagamento if current_usuario.entidade_id == 1\n respond_to do |format|\n if @movimento.save\n flash[:notice] = 'Movimento cadastrado com sucesso.'\n format.html { redirect_to(@movimento) }\n format.xml { render :xml => @movimento, :status => :created, :location => @movimento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @movimento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def import_bien b\n\n # Good location\n good_address = {}\n loc = BienEmplacement.new\n\tloc.pays = \"France\"\n\tloc.code_postal = b[\"BIEN_CODE_POSTAL\"]\n\tloc.ville = b[\"BIEN_VILLE\"]\n\n\tref = b[\"BIEN_REFERENCE\"]\n\t\n\tif @transaction_type.nom == \"Vente\"\n\t\tcat_s = b[\"BIEN_TYPE\"].to_s\n\t\tprice = b[\"BIEN_PRIX\"]\n\telse\n\t\tcat_code = b[\"BIEN_TYPE\"].to_s\n\t\tcat_s = CODE_MATCHING[cat_code]\n\t\tprice = b[\"BIEN_LOYER\"]\n\tend\n\t\n\tcat = BienType.find_or_create cat_s.up_first\n \n\tnb = Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n nb = Bien.new if nb.nil?\n\t\n\tdesc = b[\"BIEN_DESCRIPTION\"]\n\tnb.is_accueil = false\n\t# nb.is_accueil = true if b[\"TEXTE_MAILING\"] && (b[\"TEXTE_MAILING\"].to_s.downcase =~ /.*virtual.*touch.*/)\n\n nb.passerelle = @passerelle\n nb.reference = ref\n nb.bien_type = cat\n nb.bien_transaction = @transaction_type\n nb.bien_emplacement = loc\n nb.nb_piece = b[\"BIEN_NB_PIECE\"]\n nb.nb_chambre = b[\"BIEN_NB_CHAMBRE\"]\n nb.surface = b[\"BIEN_SURFACE_TOTALE\"]\n nb.surface_terrain = b[\"BIEN_SURFACE_TERRAIN\"]\n nb.titre = b[\"BIEN_LIBELLE\"]\n nb.prix = price\n nb.description = desc\n\t\n\tnb.statut = 'new'\n nb.save!\n\t\n\tnb.valeur_dpe = b[\"BIEN_CONSO_ENERGETIQUE\"]\n\tnb.valeur_ges = b[\"BIEN_EMISSION_GES\"]\n\t\t\n\t# If new images : Drop old images, add current images\n if b[\"photo\"]\n # un-attach old\n\t nb.bien_photos.each{ |photo|\n\t\t photo.bien = nil\n\t\t photo.save!\n\t }\n pl = b[\"photo\"]\n \n # When there only exists a single image, +pl+ will directly be the hash\n pl = [pl] unless pl.kind_of? Array\n # Map photo-hashes to medias, filter out failures, and add medias to good\n\t number = 0\n\t counter = 0\n pl.map { |p| import_local_media(\"#{p.to_s}.jpg\",(counter+=1),nb,\"#{p.to_s}.jpg\") }\n end\n\t\n nb.save!\n\n return\n\tend",
"def set_bien_de_consumo\n \t@bien_de_consumo = BienDeConsumo.find(params[:id])\n end",
"def modelo_params\n params.require(:modelo).permit(:marca, :configuracao, :valor, :tipo)\n end",
"def setar_data\n if params[\"laudo\"]\n unless params[\"laudo\"][\"data_formatada\"].blank?\n $data_formatada = params[\"laudo\"][\"data_formatada\"]\n end\n else\n if params['voluntario'] and params['voluntario']['criterios'] and params['voluntario']['criterios']['data_formatada']\n $data_formatada = params['voluntario']['criterios']['data_formatada']\n end\n end\n end",
"def create\n @reuniao = Reuniao.new(reuniao_params)\n @pautum=Pautum.new\n @reuniao.pautum =@pautum\n @reuniao.atum=Atum.new\n @reuniao.status=\"Preparação\"\n @pautum.status=\"Preparação\"\n \n respond_to do |format|\n if @reuniao.save\n @pautum.titulo=@reuniao.titulo\n @pautum.save\n format.html { redirect_to @reuniao, notice: 'Reuniao was successfully created.' }\n format.json { render :show, status: :created, location: @reuniao }\n else\n format.html { render :new }\n format.json { render json: @reuniao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def aluno_params\n params.require(:aluno).permit(\n\n :nome, :celular, :telefone, :ativo, :endereco, :numero, :bairro, :cidade, :estado, :email, :data_nascimento, :data_cadastro, :cpf, :rg,\n \n :nome_pai,:endereco_pai,:numero_pai,:bairro_pai,:cidade_pai,:estado_pai,:data_nascimento_pai,:escolaridade_pai,:profissao_pai,:telefone_pai, :rg_pai, :cpf_pai, :obs_pai,\n \n :nome_mae,:endereco_mae,:numero_mae,:bairro_mae,:cidade_mae,:estado_mae,:data_nascimento_mae,:escolaridade_mae,:profissao_mae,:telefone_mae, :rg_mae, :cpf_mae, :obs_mae , \n \n :escolar_trocas, :escolar_fala_atual , :escolar_ordens , :escolar_idade , :escolar_numero_escolas ,:escolar_aproveitamento , :escolar_comportamento , :escolar_frequenta_escola , :escolar_vida_escolar, :escolar_vida_social,\n :escolar_vive , :escolar_ambiente_familiar, :escolar_distrair, :escolar_amigos,\n\n :saude_medicacao, :saude_acompanhamento_medico, :saude_nome_medico, :saude_fono, :saude_psico, :saude_fisio, :saude_outros, :saude_tempo, :saude_observacoes, :saude_alergia, \n :saude_convenio, :saude_tem_convenio, \n\n :beneficio_bpc, :beneficio_bf, :beneficio_viva_leite, :beneficio_outro,\n\n :gestacao_gravidez,:gestacao_desejada, :gestacao_comentarios, :gestacao_mexer, :gestacao_prenatal, :gestacao_doencas, :gestacao_medicamentos,\n :gestacao_sobre,\n\n :nascimento_local, :nascimento_parto, :nascimento_peso, :nascimento_demorado, :nascimento_cordao, :nascimento_oxigenio,\n :nascimento_doencas, :nascimento_posicao, :nascimento_reacoes, :nascimento_chorou, :nascimento_roxo, :nascimento_observacoes,\n\n :primeiro_relato, :primeiro_criado, :primeiro_doenca, :primeiro_alergia, :primeiro_rinite, :primeiro_asma, :primeiro_adenoide, :primeiro_bronquite, :primeiro_otite, :primeiro_garganta,\n :primeiro_bronco, :primeiros_outros, :primeiro_internado, :primeiro_epilepsia, :primeiro_convulsao, :primeiro_acidentes, :primeiro_sono, :primeiro_soliloquio, :primeiro_escoplesia,\n :primeiro_bruxismo, :primeiro_sonambulismo, :primeiro_pesadelo, :primeiro_ronco, :primeiro_baba, :primeiro_respira, :primeiro_transpira, :primeiro_eneurese, :primeiro_audicao,\n :primeiro_visao, :primeiro_unha, :primeiro_mao, :primeiro_boca, :primeiro_chupa, :primeiro_chupeta, :primeiro_mamadeira, :primeiro_sexualidade, :primeiro_mamou, :primeiro_engolia,\n :primeiro_vomitava, :primeiro_engasgava, :primeiro_succao, :primeiro_refluxo, :primeiro_amamentacao, :primeiro_mamadeira_01, :primeiro_inicio_alimentacao, :primeiro_concistencia,\n :primeiro_seio, :primeiro_mamadeira_02, :primeiro_rejeitou, :primeiro_tomada, :primeiro_super, :primeiro_solidos, :primeiro_atual, :primeiro_engolir, :primeiro_engolir_obs, :primeiro_fatos,\n :primeiro_sustentou, :primeiro_sentou, :primeiro_pe, :primeiro_andou, :primeiro_falou, :primeiro_trocas, :primeiro_engatinhou,\n :irmaos, :quantas, :idade, :antecedentes, :caracteristicas, :opiniao, :outra_natureza, :tipo_local, :irmao, :quantas, :idade, :antecedentes, :caracteristicas, \n :opiniao, :outra_natureza, :tipo_local, :saude, :uso_medicamentos, :relatorio, :carteira_sus, :ciclo, :ra, :idpdi, :deficiencia, :data_fechamento_diagnostico,\n :escola_origem\n\n )\n end",
"def create\n @objeto = current_usuario.objetos.new(objeto_params)\n #@objeto.objetovalparametros.valparametros = nil\n\n #print @objeto.parametros\n respond_to do |format|\n if @objeto.save\n format.html { redirect_to @objeto, notice: 'Objeto was successfully created.' }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def schubert; end",
"def aprovar\n @oferta = Oferta.new\n @oferta.cotacao = Cotacao.find(params[:id])\n @oferta.cotacao.update_attributes(:status => Status.find_by_descricao('Aprovado'))\n\n @oferta.administrador = Administrador.first\n @oferta.data_inicio = @oferta.cotacao.data_inicio\n @oferta.data_fim = @oferta.cotacao.data_fim\n @oferta.valor_convite = @oferta.cotacao.valor\n @oferta.status = Status.find 2\n\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.json { render :json => @oferta }\n end\n end",
"def set_situacao\n logger.debug \"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\"\n\n id_busca = params[:id]\n @os_id = params[:os_id]\n @os_tarefa = OsTarefa.find(id_busca)\n @os_tarefa.situacao=params[:situacao]\n @ordem_servico = OrdemServico.find(@os_id)\n logger.debug \"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\"\n\n if @os_tarefa.situacao=='REJEITADA'\n @os_tarefa.ordem_servico_pagamento= nil\n @os_tarefa.situacao=OsTarefa.situacoes[2]\n else\n @os_tarefa.ordem_servico_pagamento= @ordem_servico\n @os_tarefa.situacao=OsTarefa.situacoes[0]\n end\n @os_tarefa.save\n respond_to do |format|\n\n format.json { head :no_content }\n format.js { render :layout => false }\n\n end\n end",
"def create\n # valor = params[:pedido][:valor]\n # params[:pedido][:valor] = valor.split( ',').join('.')\n conta = Conta.find_by_cliente_id(params[:pedido][:cliente_id])\n @proteinas_disponiveis = Proteina.where(:disponibilidade => true)\n @acompanhamentos_disponiveis = Acompanhamento.where(:disponibilidade => true)\n @guarnicoes_disponiveis = Guarnicao.where(:disponibilidade => true)\n @saladas_disponiveis = Salada.where(:disponibilidade => true)\n @bebidas_disponiveis = Bebida.where(:disponibilidade => true)\n @sobremesas_disponiveis = Sobremesa.where(:disponibilidade => true)\n #descricao = \"\"\n @pedido = Pedido.new(pedido_params)\n @pedido.conta_id = conta.id.to_i\n # if @pedido.cliente.nil?\n # @pedido.cliente = Cliente.find(current_usuario.cliente.id)\n # @pedido.conta = Conta.find_by_cliente_id(current_usuario.id)\n # end\n # ENTRADAS #\n # acompanhamentos = params[:pedido][:acompanhamento_ids]\n # acompanhamentos.each do |id|\n # if !id.blank?\n # acompanhamento = Acompanhamento.find(id.to_i)\n # @pedido.pedidos_acompanhamentos.new(:acompanhamento_id => id)\n # #@pedido.acompanhamentos << acompanhamento\n # end\n # end\n ###### FINAL ENTRADAS ########\n acompanhamentos = Acompanhamento.where(:disponibilidade => true).count\n for i in 0...acompanhamentos do\n if !params[\"acompanhamento_#{i}\"].blank?\n @pedido.pedidos_acompanhamentos.new(:acompanhamento_id => params[\"acompanhamento_#{i}\"], :quantidade => params[\"quantidade_acompanhamento_#{i}\"])\n end\n end\n\n proteinas = Proteina.where(:disponibilidade => true).count\n for i in 0...proteinas do\n if !params[\"proteina_#{i}\"].blank?\n @pedido.pedidos_proteinas.new(:proteina_id => params[\"proteina_#{i}\"], :quantidade => params[\"quantidade_proteina_#{i}\"])\n end\n end\n\n guarnicoes = Guarnicao.where(:disponibilidade => true).count\n for i in 0...guarnicoes do\n if !params[\"guarnicao_#{i}\"].blank?\n @pedido.pedidos_guarnicoes.new(:guarnicao_id => params[\"guarnicao_#{i}\"], :quantidade => params[\"quantidade_guarnicao_#{i}\"])\n end\n end\n\n saladas = Salada.where(:disponibilidade => true).count\n for i in 0...saladas do\n if !params[\"salada_#{i}\"].blank?\n @pedido.pedidos_saladas.new(:salada_id => params[\"salada_#{i}\"], :quantidade => params[\"quantidade_salada_#{i}\"])\n end\n end\n\n bebidas = Bebida.where(:disponibilidade => true).count\n for i in 0...bebidas do\n if !params[\"bebida_#{i}\"].blank?\n @pedido.pedidos_bebidas.new(:bebida_id => params[\"bebida_#{i}\"], :quantidade => params[\"quantidade_bebida_#{i}\"])\n end\n end\n\n sobremesas = Sobremesa.where(:disponibilidade => true).count\n for i in 0...sobremesas do\n if !params[\"sobremesa_#{i}\"].blank?\n @pedido.pedidos_sobremesas.new(:sobremesa_id => params[\"sobremesa_#{i}\"], :quantidade => params[\"quantidade_sobremesa_#{i}\"])\n end\n end\n\n\n #@pedido.proteinas << Proteina.where(:nome => params[:proteina]).first\n\n # debugger\n # if !params[:arroz].nil?\n # descricao = \"Arroz \"+ params[:arroz] + \",\"\n # end\n # if params[:feijao] = \"Sim\"\n # descricao = descricao + \" Feijao, \"\n # end\n\n # if params[:farofa] == \"Sim\"\n # descricao = descricao + \" Farofa,\"\n # end\n\n # descricao = descricao + params[:proteina] + \", \" + params[:acompanhamento] + \" Salada: \"+ params[:salada]\n # @pedido.descricao = descricao\n # itens = params[:pedido][:item_de_pedidos_attributes]\n\n # if !itens.nil?\n # for i in 0..params[:pedido][:item_de_pedidos_attributes].count do\n # if itens[\"#{i}\"] != nil\n # if itens[\"#{i}\"][:produto_id].blank?\n # itens.delete(\"#{i}\")\n # end\n # else\n # itens.delete(\"#{i}\")\n # end\n # end\n # end\n # if !itens.blank?\n # @pedido.calcular_valor\n # else\n # @pedido.item_de_pedidos.destroy_all\n # @pedido.valor = 0\n # end\n # if !itens.nil?\n # params[:pedido][:item_de_pedidos_attributes].replace(itens)\n # end\n\n @pedido.situacao = \"Em processamento\"\n #parametros[:valor] = @pedido.valor\n\n respond_to do |format|\n if @pedido.save\n @pedido.calcular_valor\n @pedido.conta.calcular_saldo\n #@pedido.adicionar_conta\n #proteina = @pedido.proteina\n #proteina.decrescer\n format.html { redirect_to @pedido }\n format.json { render action: 'show', status: :created, location: @pedido }\n else\n format.html { render action: 'new' }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tipomaquinat_params\n # params.require(:tipomaquinat).permit(:tipomaquina, :descripcion, :tipomaquinat)\n params.require(:tipomaquinat).permit(:tipomaquina, :descripcion) # :tipomaquinat) ESTABA DE MAS?? DEFAULT O NO? CREO QUE NO. OK.\n #params.require(:tipomaquinat).permit(:tipomaquina)\n end",
"def create\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n \n #Cobro en el banco\n client = Savon::Client.new(\"http://localhost:3001/servicios/wsdl\")\n tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n total_pagar = params[:orden][:total]\n pago = '<Message>\n <Request>\n <numero_tdc>'+tdc.numero+'</numero_tdc>\n <nombre_tarjetahabiente>'+tdc.tarjetahabiente+'</nombre_tarjetahabiente>\n <fecha_vencimiento>'+tdc.mes_vencimiento+'/'+tdc.ano_vencimiento+'</fecha_vencimiento>\n <codigo_seguridad>'+tdc.codigo+'</codigo_seguridad>\n <tipo_tarjeta>'+tdc.tipo+'</tipo_tarjeta>\n <direccion_cobro>'+tdc.direccion+'</direccion_cobro>\n <total_pagar>'+total_pagar+'</total_pagar>\n <cuenta_receptora>'+cuenta_receptora+'</cuenta_receptora>\n </Request>\n </Message>'\n #response = client.request :verificar_pago, body: { \"value\" => pago } \n #if response.success?\n # data = response.to_hash[:verificar_pago_response][:value][:response].first\n # @respuesta = XmlSimple.xml_in(data)\n #end\n\n #NAMESPACE = 'pagotdc'\n #URL = 'http://localhost:8080/'\n #banco = SOAP::RPC::Driver.new(URL, NAMESPACE)\n #banco.add_method('verificar_pago', 'numero_tdc', 'nombre_tarjetahabiente', 'fecha_vencimiento', 'codigo_seguridad', 'tipo_tarjeta', 'direccion_cobro', 'total_pagar', 'cuenta_receptora')\n #\n \n #respuesta = banco.verificar_pago(tdc.numero, tdc.tarjetahabiente, tdc.mes_vencimiento.to_s+'/'+tdc.ano_vencimiento.to_s, tdc.codigo, tdc.tipo, params[:orden][:total], tdc.direccion)\n \n if true #respuesta.ack.eql?(0)\n params[:orden][:cliente_id] = usuario_actual.id\n params[:orden][:total] = Seleccion.precio_total(usuario_actual.id)\n params[:orden][:fecha_entrega] = \"0000-00-00\"\n @orden = Orden.new(params[:orden])\n \n if @orden.save\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n @venta = Venta.new(:producto_id=>p.id, \n :orden_id=>@orden.id,\n :categoria_id=>p.categoria_id, \n :cantidad=>seleccion.cantidad,\n :costo=>p.precio)\n @venta.save\n end\n \n Seleccion.vaciar_carro(usuario_actual.id)\n respond_to do |format|\n format.html { redirect_to ver_ordenes_path, notice: 'Orden generada correctamente.' }\n end\n else\n respond_to do |format|\n format.html { render action: \"new\" }\n end\n end\n else\n respond_to do |format|\n format.html { render action: \"new\", notice: respuesta.mensaje }\n end\n end\n end",
"def set_paciente\n @paciente= FichaNutricionalAdulto.find(params[:ficha]).paciente\n end",
"def prepare_result; end",
"def create\n @parametro = Parametro.new(parametro_params)\n @parametro.observacion = @parametro.multiparametro('Ingresa 1', 'Ingresa 2', 'Ingresa 3')\n respond_to do |format|\n if @parametro.save\n format.html { redirect_to @parametro, notice: \"Parametro was successfully created.\" }\n format.json { render :show, status: :created, location: @parametro }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @parametro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_informativo_obra\n @informativo_obra = InformativoObra.find(params[:id])\n end",
"def get_data()\t\n\tend",
"def make_and_model; end",
"def harga(buah) # Dapat dilihat bahwa harga sebuah method dan buah sebagai parameter sebuah template pada variabel\n puts \"Mas buah #{buah} ini dijual?\"\nend",
"def create\n @basico_modelo_vehiculo = Basico::ModeloVehiculo.new(basico_modelo_vehiculo_params)\n puts \"--------------->>>\"\n puts @basico_modelo_vehiculo.marcaVehiculo\n puts @basico_modelo_vehiculo.marcaVehiculo_id\n respond_to do |format|\n if @basico_modelo_vehiculo.save\n format.html { redirect_to @basico_modelo_vehiculo, notice: 'Modelo vehiculo was successfully created.' }\n format.json { render :show, status: :created, location: @basico_modelo_vehiculo }\n else\n format.html { render :new }\n format.json { render json: @basico_modelo_vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Cabcompra.transaction do\n @cabcompra = Cabcompra.new(params[:cabcompra])\n @comprobante = Tipocomprobante.find(@cabcompra.tipocomprobante_id)\n if ((@comprobante.tcom_discriminaiva.to_s == 'No') || ((params[:rencompras][:rcom_netorenglon].nil?) || (params[:rencompras][:rcom_netorenglon][0].to_i > 0)))\n idplanilla = Cabcompra.maximum(:id, :conditions => [\"sucursal_id = ?\", session[:sucursal]]) \n @cabcompra.id = [idplanilla.to_i + 1, session[:sucursal]]\n # busco y grabo proveedor_id \n str_tokens = \"\"\n str_tokens = params[:proveedor][:prov_cuit].split(\"|\") if params[:proveedor]\n \n @proveedor = Proveedor.find(:first, :conditions => [\"sucursal_id = ? and prov_codigo = ? \", session[:sucursal], str_tokens[2].lstrip] ) if str_tokens[2] \n @cabcompra.proveedor_id = @proveedor.id[0] if str_tokens[2] \n $proveedor = @proveedor.id[0] if str_tokens[2] #para la validacion de proveedores 1 y 2\n @proveedor.prov_cuit = params[:proveedor][:prov_cuit].to_s if str_tokens[2] # por si vuelve con error\n @cabcompra.ccom_ultmod = DateTime.now\n @cabcompra.ccom_usuario = session[:user].usur_nombre\n @cabcompra.ccom_hastacompro = (params[:cabcompra][:ccom_hastacompro].nil? || params[:cabcompra][:ccom_hastacompro].to_i == 0) ? params[:cabcompra][:ccom_desdecompro] : params[:cabcompra][:ccom_hastacompro]\n str_tokens = @cabcompra.id.to_s.split(\",\") \n $plaegid = params[:cabcompra][:cabplaegreso_id]\n $sucursal = session[:sucursal]\n #graba compra o gasto segun el comprobante tenga o no iva\n if (params[:cabcompra][:ccom_iva].nil? || params[:cabcompra][:ccom_iva].to_d == 0 )\n @cabcompra.ccom_gastocompra = 'GASTO'\n else\n @cabcompra.ccom_gastocompra = 'COMPRA'\n end\n @cabcompra.ccom_gastocompra = 'COMPRA' if @comprobante.tcom_cabecera.to_s == 'S' #para los comprobantes de retenciones\n respond_to do |format|\n if @cabcompra.save\n if ((@comprobante.tcom_discriminaiva.to_s == 'Si') && (params[:rencompras][:rcom_netorenglon][0].to_d > 0) && @comprobante.tcom_cabecera.to_s == 'N') \n grabarenglonescompra()\n end\n \n flash[:notice] = 'El comprobante ha sido creado.'\n if @cabcompra.cabplaegreso_id > 0\n format.html { redirect_to(:controller => 'cabcompras', :action => 'index', :nrope => @cabcompra.ccom_nroplaegreso, :idpe => @cabcompra.cabplaegreso_id) }\n else\n format.html { redirect_to(:controller => 'cabcompras', :action => 'comprobantes', :id => 0) }\n end\n format.xml { render :xml => @cabcompra, :status => :created, :location => @cabcompra }\n else\n params[:idpe] = params[:cabcompra][:cabplaegreso_id]\n params[:nrope] = params[:cabcompra][:ccom_nroplaegreso]\n \n @alicuotaivas = Alicuotaiva.find(:all) \n @rencompra = Rencompra.new\n @jurisdiccions = Jurisdiccion.find(:all, :order =>\"juri_nombre\")\n @cabplaegreso = Cabplaegreso.find([params[:idpe], session[:sucursal]])\n @conceptoegresos = Conceptoegreso.find(:all, :order =>\"cegr_detalle\")\n @tipocomprobantes = Tipocomprobante.find(:all, :order =>\"tcom_nombre\")\n @iva = Tipocomprobante.find(@cabcompra.tipocomprobante_id) \n \n format.html { render :action => \"new\" }\n format.xml { render :xml => @cabcompra.errors, :status => :unprocessable_entity }\n end\n end\n else\n render :text => \"<h7> El comprobante no se guardo porque no cargo ningun detalle (renglón) </h7>\", :layout => 'application' \n end\n end\n end",
"def transact; end",
"def verdi; end",
"def set_requisito\n @objeto = Requisito.find(params[:id])\n end",
"def enviar_despacho(idfactura,cliente)\n begin \n logger.debug(\"...Inicio enviar despacho\")\n info = InfoGrupo.where('id_grupo = ?',cliente).first\n url = 'http://integra'+info[:numero].to_s+'.ing.puc.cl/api/despachos/recibir/'+idfactura.to_s\n #url = 'http://localhost:3000/api/despachos/recibir/'+idfactura.to_s\n request = Typhoeus::Request.new(\n url,\n method: :get,\n headers: { ContentType: \"application/json\"})\n response = request.run\n logger.debug(\"...Fin enviar despacho\")\n return {:validado => true}\n rescue => ex\n Applog.debug(ex.message,'enviar_despacho')\n return {:validado => false}\n end\nend",
"def create\n\n @empresa = Empresa.find(:first, :conditions => [\"prefijo = ?\", params[:empresa_id]])\n \n @gtin = params[:gtin] if params[:gtin] != ''\n\n\n params[:producto][:gtin] = Producto.crear_gtin(params[:producto][:id_tipo_gtin], params[:empresa_id], params[:gtin], params[:producto][:codigo_prod]) \n params[:producto][:fecha_creacion] = Time.now\n params[:producto][:id_estatus] = 3\n \n # Se asigna el codigo de producto\n\n params[:producto][:codigo_prod] = params[:producto][:gtin][7..11] if params[:producto][:id_tipo_gtin] == '3' and (@empresa.prefijo.to_s.size == 7 or @empresa.prefijo.to_s.size == 5)\n params[:producto][:codigo_prod] = params[:producto][:gtin][9..11] if params[:producto][:id_tipo_gtin] == '3' and @empresa.prefijo.to_s.size == 9 and @empresa.prefijo.to_s[3..5] == \"400\"\n params[:producto][:codigo_prod] = params[:producto][:gtin][3..6] if params[:producto][:id_tipo_gtin] == '1'\n params[:producto][:codigo_prod] = params[:producto][:gtin][9..12] if params[:producto][:id_tipo_gtin] == '4' \n params[:producto][:codigo_prod] = params[:producto][:gtin][8..12] if params[:producto][:id_tipo_gtin] == '5' # GTIN 14 base 12 \n params[:producto][:codigo_prod] = params[:producto][:gtin][8..12] if params[:producto][:id_tipo_gtin] == '6' and (@empresa.prefijo.to_s.size == 7 or @empresa.prefijo.to_s.size == 5)\n params[:producto][:codigo_prod] = params[:producto][:gtin][10..12] if params[:producto][:id_tipo_gtin] == '6' and @empresa.prefijo.to_s.size == 9 and @empresa.prefijo.to_s[3..5] == \"400\"\n\n params[:producto][:prefijo] = params[:empresa_id]\n\n @producto = Producto.new(params[:producto])\n\n respond_to do |format|\n if @producto.save\n\n Auditoria.registrar_evento(session[:usuario],\"producto\", \"Crear\", Time.now, \"GTIN:#{@producto.gtin} DESCRIPCION:#{@producto.descripcion} TIPO GTIN:#{@producto.tipo_gtin.tipo}\")\n format.html { redirect_to empresa_productos_path, notice: \"EL #{@producto.tipo_gtin.tipo} #{@producto.gtin} fue creado correctamente.\" } \n\n else\n format.html { \n render action: \"new\" } \n end\n end\n end",
"def preparar_mate_params\n params.require(:preparar_mate).permit(:título, :descrición)\n end",
"def agregar_compra(producto, unidades = 1)\n DB.execute(\"insert into compras values ( ?, ?)\", producto, unidades)\nend",
"def model=(_arg0); end",
"def model=(_arg0); end",
"def model=(_arg0); end",
"def model=(_arg0); end",
"def informacoes_da_conta(local)\n\t\t\t\t\traise NotImplementedError.new('Sobreescreva este método na classe referente ao banco que você esta criando')\n\t\t\t\tend",
"def to_s\n \t\t\t\"(Nombre:#{@nombre},Proteinas:#{@proteinas},Carbohidratos:#{@carbohidratos},Lipidos:#{@Lipidos},Gei:#{@gei},Terreno:#{@terreno})\"\n \t\t\n\t\tend",
"def new\n \n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n respond_to do |format|\n unless @selecciones.empty?\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n @orden = Orden.new(:direccion_entrega=>usuario_actual.direccion)\n t = Time.now\n fecha = t.strftime(\"%Y-%m-%d\")\n client = Savon::Client.new(\"http://192.168.1.121/DistribuidorFIF/webservices/servicio.php?wsdl\")\n preorden = \"<solicitud_pedido>\n <num_orden>001</num_orden>\n <nombre_comercio>Tukiosquito</nombre_comercio>\n <fecha_solicitud>\"+fecha.to_s+\"</fecha_solicitud>\n <nombre_cliente>\"+usuario_actual.nombre+\" \"+usuario_actual.apellido+\"</nombre_cliente>\n <direccion_comercio>\n <avenida>Sucre</avenida>\n <calle>-</calle>\n <edificio_casa>CC Millenium</edificio_casa>\n <local_apt>C1-15</local_apt>\n <parroquia>Leoncio Martinez</parroquia>\n <municipio>Sucre</municipio>\n <ciudad>Caracas</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_comercio>\n <direccion_destino>\n <avenida>Santa Rosa</avenida>\n <calle>Tierras Rojas</calle>\n <edificio_casa>Villa Magica</edificio_casa>\n <local_apt>69</local_apt>\n <parroquia> </parroquia>\n <municipio>Zamora</municipio>\n <ciudad>Cua</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_destino>\"\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n preorden = preorden+\"\n <articulo>\n <id>\"+p.id.to_s+\"</id>\n <descripcion>\"+p.descripcion+\"</descripcion>\n <peso>\"+p.peso.to_s+\"</peso>\n <cantidad>\"+seleccion.cantidad.to_s+\"</cantidad>\n <precio>\"+p.precio.to_s+\"</precio>\n </articulo>\"\n end\n preorden = preorden+\"</solicitud_pedido>\"\n response = client.request :ejemplo, body: { \"value\" => preorden } \n if response.success? \n respuesta = response.to_hash[:ejemplo_response][:return]\n datos = XmlSimple.xml_in(respuesta)\n end\n\n @precio_envio = datos[\"num_orden\"][0]\n #@arreglo = XmlSimple.xml_in('')\n #@xml = XmlSimple.xml_out(@arreglo, { 'RootName' => 'solicitud_pedido' })\n #url = 'http://192.168.1.101/Antonio/tukyosquito/proyecto/servicio/servicio.php'\n #cotizacion = SOAP::RPC::Driver.new(url)\n #cotizacion.add_method('obtener','asd')\n #tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n #@respuesta = cotizacion.obtener('123')\n format.html # new.html.erb\n else\n format.html { redirect_to carrito_path, notice: 'No tiene productos agregados al carro de compras para generar una orden.' }\n end\n end\n end",
"def create\n\n @var=params[:despachar]\n if !(params[:enviar].nil?)\n\n @ordenes=params[:enviar]\n @ordenes.each do |orden|\n if orden[1] != \"no\"\n @orden = Orden.find(orden[1])\n @orden.empleado_id = @var[\"recolector\"]\n @orden.estado = \"Asignada para Recoleccion\"\n NUESTRO_LOG.info \"Se despacho la orden correctamente\"\n @orden.save\n end\n end\n end\n @ordenprincipal = Orden.find(@var[\"orden\"])\n @ordenprincipal.estado = \"Asignada para Recoleccion\"\n @ordenprincipal.empleado_id = @var[\"recolector\"]\n @ordenprincipal.save\n redirect_to(despachador_path, :notice => t('rutarecolecciones'))\n\n end",
"def valor_nuevo\n begin\n if self.campo =~ /\\w+id$/ && self.value\n row = eval(\"#{self.campo.gsub(\"_id\", \"\").camelize}.find('#{self.value}')\") if self.campo == 'persona_id' && Object.const_defined?(self.campo.gsub(\"_id\", \"\").camelize)\n row ||= eval(\"#{self.campo.gsub(\"_id\", \"\").camelize}.find(#{self.value})\") if Object.const_defined?(self.campo.gsub(\"_id\", \"\").camelize)\n row ||= eval(\"Catalogo.#{self.campo.gsub(\"_id\", \"\")}.find(#{self.value})\") if Catalogo.respond_to?(self.campo.gsub(\"_id\", \"\").downcase)\n vn = (row && row.respond_to?(:descripcion)) ? row.descripcion : nil\n vn ||= (row && row.respond_to?(:persona_id)) ? row.persona.nombre_completo : self.value\n return vn\n else\n return self.value\n end\n rescue SyntaxError, NameError => err\n err\n end\n end",
"def oportunidade_params\r\n params.require(:oportunidade).permit(:contato_id, :empresa_id, :curso, :cargo, :requisitos, :salario, :observacoes, :local_inscricao, :fim_oferta, :ini_oferta, :tipo_oferta, :formadoa, :nivel, :descricao, :panoconclusao_inicio, :panoconclusao_fim, :pidioma, :ptipo, :dispo, :visivel, :situacao)\r\n end",
"def transmission; end",
"def import_bien b\n\n\t\t# Good location\n\t\tgood_address = {}\n\t\tloc \t\t\t\t\t= BienEmplacement.new\n\t\tloc.pays \t\t\t\t= \"France\"\n\t\tloc.code_postal \t\t= b['cp']\n\t\tloc.ville \t\t\t\t= b['lieu']\n\n\t\t# Category & Transaction type\n\t\tcat = BienType.find_or_create b['categoriebien'].up_first\n\n\t\ttransaction_type = BienTransaction.where(:nom => b['etat'].up_first).first\n\t\treturn if transaction_type.nil?\n\n\t\t# find if good already exist, unless create it\n\t\tref = b['reference'] \n\t\tnb = Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n\t\tnb = Bien.new if nb.nil?\n\n\t\tnb.is_accueil \t\t\t= false\n\t\t#nb.is_accueil = true if b[\"TEXTE_MAILING\"] && (b[\"TEXTE_MAILING\"].to_s.downcase =~ /.*virtual.*touch.*/)\n\n\t\t# update attributes\n\t\tnb.passerelle \t\t\t= @passerelle\n\t\tnb.reference \t\t\t= ref\n\t\tnb.bien_type \t\t\t= cat\n\t\tnb.bien_transaction \t= transaction_type\n\t\tnb.bien_emplacement \t= loc\n\n\t\tnb.nb_piece \t\t\t= b['piece'].to_i\n\t\tnb.surface \t\t\t\t= b['surface'].to_i\n\t\tnb.titre \t\t\t\t= b['libelle'].up_first\n\n\t\tif(b['charge'] && (b['charge'].to_i > 0))\n\t\t\tnb.prix_hors_charges \t\t= b['prixouloyer']\n\t\t\tnb.prix_charges_comprises \t= b['prixouloyer'].to_i + b['charge'].to_i\n\t\telse\n\t\t\tnb.prix_charges_comprises \t= b['prixouloyer']\n\t\tend\n\t\tnb.prix\t\t\t\t\t= nb.prix_charges_comprises\n\t\tnb.honoraires_agence \t= b['honoraire']\n\t\t\t\n\t\tnb.description \t\t\t= b['description']\n\t\tnb.valeur_dpe \t\t\t= b['energie']\n\t\tnb.classe_dpe \t\t\t= nb.classe_energie\n\t\tnb.statut \t\t\t\t= 'new'\n\t\tnb.save!\n\n\t\t# If new images : Drop old images, add current images\n\t\tif b['photos'] && b['photos']['photo']\n\t\t\t# un-attach old\n\t\t\tnb.bien_photos.each{ |photo|\n\t\t\t\tphoto.bien = nil\n\t\t\t\tphoto.save!\n\t\t\t}\n\n\t\t\tpl = b['photos']['photo']\n\t\t\tpl = [pl] unless pl.kind_of? Array\n\n\t\t\tnumber = 0\n\t\t\tpl.each{ |urlPhoto|\n\t\t\t\tLogger.send(\"warn\", \"calling import_remote_media(#{urlPhoto}, #{(number+=1)}, nb)\")\n\t\t\t\timport_remote_media(urlPhoto, (number+=1), nb)\n\t\t\t}\n\t\tend\n\n\t\tnb.save!\n\n\t\treturn true\n\tend",
"def generar_tramitado\n @documento = Documento.new\n @documento.TipoDocumento = TipoDocumento.new\n\n @tramite = Tramite.find(params[:tramite_id])\n @tramite.update_attribute(\"documento\", true)\n @producto_id = params[:producto_id]\n @tramitando = true\n @descripcion = TipoDocumento.find(params[:tipo_id]).descripcion\n @presentaciones = Presentacion.where(:productos_id => @producto_id)\n @importadores = Importador.where(:productos_id => @producto_id)\n puts @tramitado\n flash[:accion] = \"Agregar Documento\"\n flash.keep\n render :action => :new\n end",
"def realizar_cuestionario_demora\n @paciente = Paciente.find(params[:id])\n @accionPerfilamiento = \"Cuestionario por Demora\"\n end",
"def create\n obtener_datos()\n @ventum = current_user.ventum.new(cliente:@cliente, clave:@clave, fecha:@fecha, iva:@iva, subtotal:@preciofinal ,total:@totalcosto, descuentogeneral: @descglobal, distribuidor: @distribuidor, status: \"En proceso\")\n respond_to do |format|\n if(@ventum.save)\n salvar()\n format.html { redirect_to @ventum, notice: 'Venta almacenada exitosamente!.' }\n else\n format.html { redirect_to eventos_path, notice: 'Fallo el almacenamiento de la venta.' }\n end\n \n end\n end",
"def set_basico_modelo_vehiculo\n @basico_modelo_vehiculo = Basico::ModeloVehiculo.find(params[:id])\n end",
"def reentrada_params\n #params.fetch(:reentrada, {})\n\n params.require(:reentrada).permit(:ciclo_id, :cadastro_reentrando_id, :cadastro_adicionado_id, :cadastro_principal_id, :flagopcional)\n end",
"def set_precio_boleto\n\t@precio_boleto = PrecioBoleto.find(params[:id])\n\tend",
"def resultado_params\n params.require(:resultado).permit(:resposta_id, :parametro_id)\n end",
"def import_bien b\n\n\t\t# Good location\n\t\tgood_address = {}\n\t\tloc \t\t\t= BienEmplacement.new\n\t\tloc.pays \t\t= \"France\"\n\t\tloc.code_postal = b['CodePostal']\n\t\tloc.ville \t\t= b['Ville']\n\n\t\t# Category & Transaction type\n\t\tcat = BienType.find_or_create b['TypeBien'].up_first\n\n\t\ttransaction_type = BienTransaction.where(:nom => b['TypeTransaction'].up_first).first\n\t\treturn if transaction_type.nil?\n\n\t\t# find if good already exist, unless create it\n\t\tref = b['Reference'] \n\t\tnb = Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n\t\tnb = Bien.new if nb.nil?\n\n\t\tnb.is_accueil \t\t\t= false\n\t\t#nb.is_accueil = true if b[\"TEXTE_MAILING\"] && (b[\"TEXTE_MAILING\"].to_s.downcase =~ /.*virtual.*touch.*/)\n\n\t\t# update attributes\n\t\tnb.passerelle \t\t\t= @passerelle\n\t\tnb.reference \t\t\t= ref\n\t\tnb.bien_type \t\t\t= cat\n\t\tnb.bien_transaction\t \t= transaction_type\n\t\tnb.bien_emplacement \t= loc\n\n\t\tnb.nb_piece \t\t\t= b['NbPieces'].to_i\n\t\tnb.nb_chambre \t\t\t= b['NbChambres'].to_i\n\t\tnb.surface\t\t\t\t= b['SurfaceHabitable'].to_i\n\t\tnb.surface_terrain \t\t= b['SurfaceTerrain1'].to_i\n\t\tnb.titre\t\t\t\t= b['Titre']\n\t\tif(nb.titre.nil? || nb.titre.empty?)\n\t\t\tnb.titre = b['TypeBien'].up_first\n\t\tend\n\n\t\tif((transaction_type.nom == \"Location\") && b['ChargesMensuelles'] && (b['ChargesMensuelles'].to_i > 0))\n\t\t\tnb.prix_hors_charges \t\t= b['Prix']\n\t\t\tnb.prix_charges_comprises \t= b['Prix'].to_i + b['ChargesMensuelles'].to_i\n\t\telse\n\t\t\tnb.prix_charges_comprises \t= b['Prix']\n\t\tend\n\t\tnb.prix \t\t\t\t= nb.prix_charges_comprises\n\t\tnb.honoraires_agence \t= b['Honoraires']\n\t\t\n\t\tnb.description \t\t\t= b['Texte']\n\t\tnb.valeur_dpe \t\t\t= b['Dpe_energie']\n\t\tif(b['Dpe_energie_etiquette'] && !(b['Dpe_energie_etiquette'].empty?))\n\t\t\tnb.classe_dpe = b['Dpe_energie_etiquette']\n\t\telse\n\t\t\tnb.classe_dpe = nb.classe_energie\n\t\tend\n\n\t\tnb.valeur_ges \t\t\t= b['Dpe_emission_ges']\n\t\tif(b['Dpe_emission_ges_etiquette'] && !(b['Dpe_emission_ges_etiquette'].empty?))\n\t\t\tnb.class_ges = b['Dpe_emission_ges_etiquette']\n\t\telse\n\t\t\tnb.class_ges = nb.classe_ges\n\t\tend\n\t\t\n\t\tnb.statut = 'new'\n\t\tnb.save!\n\n\t\t# If new images : Drop old images, add current images\n\t\tif b['Photos'] && b['Photos']['Photo']\n\t\t\t# un-attach old\n\t\t\tnb.bien_photos.each{ |photo|\n\t\t\t\tphoto.bien = nil\n\t\t\t\tphoto.save!\n\t\t\t}\n\t\t\tpl = b['Photos']['Photo']\n\n\t\t\t# When there only exists a single image, +pl+ will directly be the hash\n\t\t\tpl = [pl] unless pl.kind_of? Array\n\t\t\t# Map photo-hashes to medias, filter out failures, and add medias to good\n\t\t\tnumber = 0\n\t\t\tpl.map { |p| import_remote_media(p['UrlOriginal'], p['Position'], nb) }\n\t\tend\n\t\t\n\t\tnb.save!\n\t\treturn\n\tend",
"def anular\n self.estado = Cancelacion::ESTADOS[:anulada]\n end",
"def opera_params\n params.require(:opera).permit(:numero, :sub, :descrizione, :anno, :ente, :target_id, :target_type, :target, :responsabile_id)\n end",
"def preencher(nome,data1,string,string2,data2, string3, string4, string8,descriao,status,related)\n tarefa_nova.set(nome)\n select string8, from: 'priority'\n descricao_bug.set(descriao) \n select status, from: 'status'\n find('#parent_type').find(\"option[value='\"+related+\"']\").select_option\n sleep 2\n savagem.click\n sleep 2 \n end",
"def save_cobertura(e, op, c)\n cob = Cobertura.where(endereco: e).first\n v = (op == 'vivo') ? c : nil;\n o = (op == 'oi') ? c : nil;\n n = (op == 'net') ? c : nil;\n \n if cob == nil\n puts \"Criando nova Cobertura...\"\n \n cob = Cobertura.create!(endereco: e, vivo: v, net: n, oi: o)\n puts cob\n else\n puts \">>> Atualizando Cobertura cadastrada #{e}\"\n if (op == 'vivo') \n cob.vivo = c\n end\n if (op == 'oi') \n cob.oi = c\n end\n if (op == 'net') \n cob.net = c\n end\n cob.save\n end\n cob\n end",
"def precio_boleto_params\n\tparams.require(:precio_boleto).permit(:precio, :clase, :destino, :origen)\n\tend",
"def asignar_titulo_propiedad()\n \n end",
"def create\n @boat = Boat.new(params[:boat])\n\n @model = Model.where(:valm_malli => params[:boat][:valm_malli]).first\n\n if @model.nil?\n @model = Model.new\n @model.korkeus = @boat.korkeus\n @model.leveys = @boat.leveys\n @model.pituus = @boat.pituus\n @model.syvyys = @boat.syvyys\n @model.uppouma = @boat.uppouma\n @model.valm_malli = @boat.valm_malli\n @model.tyyppi = @boat.tyyppi\n @model.save\n end\n\n @laituri_idt = Dock.all.map(&:id)\n @laituri_idt.insert(0,nil)\n\n @vapaat_laituripaikat = Berth.where(:dock_id => 1).all.map(&:number)\n @vapaat_laituripaikat.insert(0,nil)\n parse_jno_from_omistajatxtbox\n changejnoToId\n respond_to do |format|\n if @boat.valid? && @onkoOk #&& check_for_only_one_payer\n check_dock_and_berth(format)\n @boat.save\n format.html { redirect_to @boat, notice: 'Vene luotiin onnistuneesti.' }\n format.json { render json: @boat, status: :created, location: @boat }\n else\n format.html { flash.now[:alert] = @member == nil ? 'Jäsentä ei löytynyt' : 'Tuntematon virhe'\n render action: \"new\" }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n\n end"
] |
[
"0.59089756",
"0.57431155",
"0.5694201",
"0.5669907",
"0.56440896",
"0.5592507",
"0.5523988",
"0.5507846",
"0.5480099",
"0.54769",
"0.5471223",
"0.5437455",
"0.5409709",
"0.5408578",
"0.54035497",
"0.53992236",
"0.53588724",
"0.53509355",
"0.53457624",
"0.53361833",
"0.5331918",
"0.53279895",
"0.53219295",
"0.5299485",
"0.5285401",
"0.5281907",
"0.5269642",
"0.52636844",
"0.5258915",
"0.5257624",
"0.52573353",
"0.525421",
"0.5252126",
"0.5247965",
"0.52395844",
"0.52335376",
"0.5231864",
"0.52309763",
"0.522931",
"0.522862",
"0.52247524",
"0.5224682",
"0.5222707",
"0.52163476",
"0.52142483",
"0.5211952",
"0.5209676",
"0.52044207",
"0.52020955",
"0.5191145",
"0.51899576",
"0.51889724",
"0.5187792",
"0.5187561",
"0.51838773",
"0.5180568",
"0.5177715",
"0.5172384",
"0.51673895",
"0.5167117",
"0.516373",
"0.5163599",
"0.5160613",
"0.51559466",
"0.51377296",
"0.5134264",
"0.5133147",
"0.5130766",
"0.512908",
"0.51156414",
"0.5115348",
"0.51093",
"0.51051587",
"0.5104424",
"0.5103451",
"0.5103451",
"0.5103451",
"0.5103451",
"0.51011485",
"0.5098115",
"0.50977594",
"0.508887",
"0.5086728",
"0.5082548",
"0.5078775",
"0.5077658",
"0.50770706",
"0.50764835",
"0.5073497",
"0.5067165",
"0.5063645",
"0.50621617",
"0.50576186",
"0.5056704",
"0.5050833",
"0.5048678",
"0.5045564",
"0.5041677",
"0.50411904",
"0.5039036",
"0.50383765"
] |
0.0
|
-1
|
GET /insurances GET /insurances.json
|
def index
init_oco if !session[:organization]
if session[:organization] != '0'
@insurances = Insurance.where(organization_id: session[:organization]).paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)
else
@insurances = Insurance.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @insurances }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all(params = {})\n @client.make_request(:get, 'insurances', MODEL_CLASS, params)\n end",
"def retrieve(id)\n @client.make_request(:get, \"insurances/#{id}\", MODEL_CLASS)\n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @life_insurances }\n end\n end",
"def index\n @health_insurances = HealthInsurance.all\n end",
"def index\n @insurance_queries = InsuranceQuery.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @insurance_queries }\n end\n end",
"def index\n @insurancestatuses = Insurancestatus.all\n end",
"def index\n @life_insurances = LifeInsurance.all\n end",
"def index\n @incomes = Income.all\n\n respond_to do |format|\n format.json { render json: @incomes }\n end\n end",
"def index\n @inciting_incidents = IncitingIncident.all\n render json: @inciting_incidents\n end",
"def index\n render :json => UserInterest.all\n end",
"def index\n @incidents = @quote.incidents.all\n respond_to do |format|\n format.json { render :json => @incidents }\n end\n end",
"def show\n @insurance = load_insurance\n\n respond_to do |format|\n format.html\n format.json\n end \n end",
"def index\n @illnesses = Illness.all\n\n render json: @illnesses\n end",
"def index\n @inspirations = Inspiration.all\n end",
"def index\n @incidents = current_user.incidents\n end",
"def index\n @incomes = current_company.incomes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @incomes }\n end\n end",
"def index\n getProfile\n @consents = TherapistConsent.where('therapist_id = ? ', @therapist.id)\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render :status => 200, :json => { action: 'index', consents: @consents }}\n end\n end",
"def index\n @innings = Inning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @innings }\n end\n end",
"def index\n @unemployment_insurances = UnemploymentInsurance.all\n end",
"def index\n @incidents = Incident.all\n end",
"def index\n @insurance_coverages = InsuranceCoverage.all\n end",
"def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interests }\n end\n end",
"def index\n @illnesses = Illness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @illnesses }\n end\n end",
"def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @interests }\n end\n end",
"def index\n @surrenders = @insurance.surrenders.all\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def get_resolved_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"resolved\", :fields => \"incident_number\" }\n end",
"def incident_list(statuspage_id)\n request :method => :get,\n :url => @url + 'incident/list/' + statuspage_id\n end",
"def index_invites\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.invited_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def index\n @issuances = Issuance.all\n end",
"def index\n @issuances = Issuance.all\n end",
"def index\n @issuing_institutions = IssuingInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @issuing_institutions }\n end\n end",
"def index\n @sigurances = Sigurance.all\n end",
"def index\n @involvements = Involvement.all\n end",
"def index\n @identities = Identity.all\n\n render json: @identities\n end",
"def index\n @ownerships = ownerships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ownerships }\n end\n end",
"def show\n @encounter = Encounter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @encounter }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @life_insurance }\n end\n end",
"def show\n p 'show?'\n @acceptances = []\n if(current_user)\n if(params[:id])\n @acceptance = Acceptance.find(params[:id])\n else\n @acceptances = Acceptance.where(\"user_id=? and (status=? or status = ?) and end_time> ?\", current_user.id, \"successfully paid\", \"payment pending\", Time.now())\n end\n end\n p \"acceptances are \"\n \n presenter = Api::V3::AcceptancesPresenter.new\n acceptances_json = @acceptances.map{|x| presenter.as_json(x)}\n p acceptances_json\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: acceptances_json }\n end\n end",
"def incident_list_by_id(statuspage_id)\n request :method => :get,\n :url => @url + 'incidents/' + statuspage_id\n end",
"def index\n @api_v1_mentorship_interests = Api::V1::MentorshipInterest.all\n end",
"def index\n if params[:story_id].present?\n @invitations = Story.find(params[:story_id]).invitations\n else\n @invitations = Invitation.find_by_email(@current_user.email)\n end\n render json: @invitations\n end",
"def get_institutions\r\n # Prepare query url.\r\n _path_url = '/institutions'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n decoded.map { |element| Institution.from_hash(element) }\r\n end",
"def index\n @infections = Infection.all\n end",
"def show\n @income = Income.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @income }\n end\n end",
"def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end",
"def index\n @involvements = Involvement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @involvements }\n end\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interest }\n end\n end",
"def index\n @insurance_facilities = InsuranceFacility.all\n end",
"def show\n @breadcrumb = 'read'\n @insurance = Insurance.find(params[:id])\n @workers = @insurance.workers.paginate(:page => params[:page], :per_page => per_page).order('worker_code')\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @insurance }\n end\n end",
"def get_ack_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"acknowledged\", :fields => \"incident_number\" }\n end",
"def index\n @interests = Interest.all\n end",
"def index\n @interests = Interest.all\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @interest }\n end\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @interest }\n end\n end",
"def index\n @incarnations = Incarnation.all\n end",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def index\n @institucions = Institucion.search(params[:search], params[:page])\n end",
"def show\n @event_interest = EventInterest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_interest }\n end\n end",
"def incidents\n return @incidents\n end",
"def index\n @user_interests = UserInterest.all\n end",
"def index\n @conflict_illnesses = ConflictIllness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conflict_illnesses }\n end\n end",
"def index\n @weigh_ins = WeighIn.all\n end",
"def show\n @endurance = Endurance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @endurance }\n end\n end",
"def index\n @interruptions = Interruption.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interruptions }\n end\n end",
"def index\n @interviews = Interview.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interviews }\n end\n end",
"def show\n @illness = Illness.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @illness }\n end\n end",
"def show\n @income_entry = IncomeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @income_entry }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @insurer }\n end\n end",
"def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end",
"def get_insurer\n # bound to specific insurer\n rp = request.method == 'GET' ? request.query_parameters.to_json : request.raw_post\n @request_payload = rp\n @insurers = []\n if !rp.blank? && !JSON.parse(rp)['insurer_company_code'].blank?\n\n insurers = Insurer.where(company_code: JSON.parse(rp)['insurer_company_code']).where(status: true).where(activation_status: true)\n\n if insurers.any?\n\n insurer = insurers.first\n\n # unless current_client.insurers.where(id: insurer.id).any?\n # render_error(ERROR_INSURER_NOT_SUPPORTED, \"forbidden\")\n # create_api_log and return\n # end\n\n unless InsurerClient.where(insurer_id: insurer.id).where(client_id: current_client.id).where(product_id: current_client_api.product_id).any?\n render_error(ERROR_INSURER_NOT_SUPPORTED, \"forbidden\")\n create_api_log and return\n end\n\n @insurers << insurer\n else\n render_error(ERROR_INSURER_NOT_MATCH, \"not_found\")\n create_api_log and return\n end\n\n else\n # get Insurers\n insurer_clients = InsurerClient.where(product_id: current_client_api.product_id).where(client_id: current_client.id)\n\n if insurer_clients.blank?\n render_error(ERROR_INSURER_NOT_MATCH, \"not_found\")\n create_api_log and return\n end\n\n insurer_clients.each do |ic|\n insurer = Insurer.find(ic.insurer_id)\n next unless insurer.status && insurer.activation_status\n @insurers << Insurer.find(ic.insurer_id)\n end\n\n end\n @insurers\n end",
"def index\n @interest_on_housing_loans = InterestOnHousingLoan.all\n end",
"def index\n @investigations = Investigation.where(:visible => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @investigations }\n end\n end",
"def index\n @incomes = Income.all\n end",
"def received_invitations\n user = User.find(params[:user_id])\n @invitations = user.invitations\n\n render json: @invitations\n end",
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def identities\n render json: current_user.identities\n end",
"def get_triggered_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"triggered\", :fields => \"incident_number\" }\n end",
"def index\n @incomes = current_user.incomes\n end",
"def index\n @inflows = Inflow.all\n end",
"def index\n sighting = Sighting.all \n render json: SightingSerializer.new(sighting)\n end",
"def show\n @inspiration = Inspiration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inspiration }\n end\n end",
"def index\n number_tweets = if params[\"count\"] then params[\"count\"].to_i else 10 end\n tweet_ids = []\n if @user.interests\n for i in 1..number_tweets\n interest = @user.interests.sample\n tweet = Rails.application.config.twitter_client.search(\"#{interest[:hashtag]}\", count: 1).take(1)\n tweet_ids.push(tweet.first.id.to_s)\n end\n end\n\n render json: tweet_ids, status: :ok\n end",
"def index\n @inscriptions = Inscription.includes(:tournament).all\n\n respond_to do |format|\n format.html # index.rb\n format.xml { render :xml => @inscriptions }\n end\n end",
"def index\n @sigandannies = Sigandanny.all\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def index\n @incidents = apply_scopes(Incident).order(\"occured_on\").page(params[:page]).per(50)\n @location_groups = LocationGroup.all\n\n if params[:location] && params[:location] > \"\"\n location = Location.find(params[:location])\n @location_name = location.name\n end\n\n @start_date = params[:by_period].try(:[], :start_date).try(:to_date) ||\n Incident.default_period_range.first\n @end_date = params[:by_period].try(:[], :end_date).try(:to_date) ||\n Incident.default_period_range.end\n @incident_types = Incident.uniq.order(\"incident_type\").pluck(:incident_type)\n logger.debug @incident_types\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @incidents }\n end\n end",
"def show\n @inspiration = Inspiration.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inspiration }\n end\n end",
"def index\n @indivisuals = Indivisual.all\n end",
"def index_single_gift\n render json: @gift, include: :ages, status: :ok\n end",
"def index\n @one_reg_institutions = OneRegInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @one_reg_institutions }\n end\n end",
"def index\n @noises = Noise.search(params).group_by(&:user_id)\n\n respond_with @noises\n end",
"def get_incidents\n page = Nokogiri::HTML(open(INCIDENTS_URL))\n rows = page.css('table').css('tr').to_a.drop(1).map do |row|\n cols = row.css('td').to_a.reduce([]) do |acc, col|\n if col.at_css('li')\n incident_link = col.css('li').css('a')[0]['href']\n acc.push(BASE_URL + incident_link)\n else\n acc.push(col.text)\n end\n end\n end\n end",
"def index\n @sightings = Sighting.all\n render json: @sightings\n end",
"def index\n @seihinns = Seihinn.all\n end",
"def create(params = {})\n wrapped_params = { insurance: params }\n @client.make_request(:post, 'insurances', MODEL_CLASS, wrapped_params)\n end",
"def index\n @noise = Noise.new\n @noises = Noise.all\n params[:page] ||= 1\n\n respond_to do |format|\n format.html { @noises = Noise.paginate(per_page: 20, page: params[:page]) }\n format.json do \n list = @noises.map\n render json: Noise.all.select('id, sounds, icon') \n end\n end\n end",
"def index\n \n @interests = Interest.find(@interestsId)\n \n if params[:persona_id] == nil \n @interests = Interest.order(:name) \n end\n \n respond_to do |format|\n format.json { render :json => @interests }\n end\n end",
"def index\n @universes = Universe.all.page(params[:page]).per(25)\n respond_to do |format|\n format.html\n format.json { render json: @universes }\n end\n end"
] |
[
"0.7403342",
"0.70758814",
"0.6451256",
"0.64166343",
"0.63968",
"0.6316312",
"0.62888956",
"0.62385476",
"0.6186712",
"0.6174553",
"0.6106109",
"0.60953295",
"0.60716",
"0.60701185",
"0.60585976",
"0.60043454",
"0.6001137",
"0.59882796",
"0.59633946",
"0.5942013",
"0.5925933",
"0.59154487",
"0.5877631",
"0.5868069",
"0.5867739",
"0.5852397",
"0.5850861",
"0.58508545",
"0.583866",
"0.5821956",
"0.5809892",
"0.5809892",
"0.5799326",
"0.5798459",
"0.5783358",
"0.5774019",
"0.57581854",
"0.5751732",
"0.5729168",
"0.5728344",
"0.57224965",
"0.5697744",
"0.5687506",
"0.56841445",
"0.56661683",
"0.56559676",
"0.5643511",
"0.5618742",
"0.56186765",
"0.5617132",
"0.5603084",
"0.5587366",
"0.5576559",
"0.5576559",
"0.5574141",
"0.55704916",
"0.5562122",
"0.5556826",
"0.55535537",
"0.55492485",
"0.5547803",
"0.55465215",
"0.5544771",
"0.55390394",
"0.5537431",
"0.5536903",
"0.55368567",
"0.55318975",
"0.552736",
"0.55250037",
"0.55207735",
"0.55190915",
"0.5517388",
"0.5509233",
"0.5502534",
"0.5499169",
"0.5493497",
"0.5484016",
"0.5483092",
"0.5480334",
"0.5464456",
"0.54544973",
"0.545199",
"0.54487437",
"0.54465365",
"0.54317653",
"0.54313576",
"0.54310715",
"0.542867",
"0.5426386",
"0.5423443",
"0.5420607",
"0.5414279",
"0.5411068",
"0.5409543",
"0.54089147",
"0.5408826",
"0.53987753",
"0.539658",
"0.5393362"
] |
0.6540112
|
2
|
GET /insurances/1 GET /insurances/1.json
|
def show
@breadcrumb = 'read'
@insurance = Insurance.find(params[:id])
@workers = @insurance.workers.paginate(:page => params[:page], :per_page => per_page).order('worker_code')
respond_to do |format|
format.html # show.html.erb
format.json { render json: @insurance }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def retrieve(id)\n @client.make_request(:get, \"insurances/#{id}\", MODEL_CLASS)\n end",
"def all(params = {})\n @client.make_request(:get, 'insurances', MODEL_CLASS, params)\n end",
"def show\n @insurance = load_insurance\n\n respond_to do |format|\n format.html\n format.json\n end \n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @life_insurances }\n end\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end",
"def index\n init_oco if !session[:organization]\n if session[:organization] != '0'\n @insurances = Insurance.where(organization_id: session[:organization]).paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n else\n @insurances = Insurance.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @insurances }\n end\n end",
"def index\n @health_insurances = HealthInsurance.all\n end",
"def show\n @encounter = Encounter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @encounter }\n end\n end",
"def index\n @incomes = Income.all\n\n respond_to do |format|\n format.json { render json: @incomes }\n end\n end",
"def index\n @insurance_queries = InsuranceQuery.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @insurance_queries }\n end\n end",
"def index\n @insurancestatuses = Insurancestatus.all\n end",
"def show\n @income = Income.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @income }\n end\n end",
"def index\n @life_insurances = LifeInsurance.all\n end",
"def index\n getProfile\n @consents = TherapistConsent.where('therapist_id = ? ', @therapist.id)\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render :status => 200, :json => { action: 'index', consents: @consents }}\n end\n end",
"def show\n @institucional = Institucional.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institucional }\n end\n end",
"def index\n @inciting_incidents = IncitingIncident.all\n render json: @inciting_incidents\n end",
"def index\n render :json => UserInterest.all\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interest }\n end\n end",
"def show\n @inspiration = Inspiration.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inspiration }\n end\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @interest }\n end\n end",
"def index\n @inspirations = Inspiration.all\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @life_insurance }\n end\n end",
"def show\n @inspiration = Inspiration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inspiration }\n end\n end",
"def show\n @income_entry = IncomeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @income_entry }\n end\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @interest }\n end\n end",
"def show\n @incident = Incident.find(params[:id])\n\n render json: @incident\n end",
"def index\n @illnesses = Illness.all\n\n render json: @illnesses\n end",
"def show\n @endurance = Endurance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @endurance }\n end\n end",
"def index\n @incomes = current_company.incomes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @incomes }\n end\n end",
"def show\n @event_interest = EventInterest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_interest }\n end\n end",
"def index\n @incidents = @quote.incidents.all\n respond_to do |format|\n format.json { render :json => @incidents }\n end\n end",
"def show\n @insure_result = InsureResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @insure_result }\n end\n end",
"def show\n @title = \"Тип страхования\"\n @insurance_type = InsuranceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @insurance_type }\n end\n end",
"def index\n @innings = Inning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @innings }\n end\n end",
"def show\n @illness = Illness.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @illness }\n end\n end",
"def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interests }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @insurer }\n end\n end",
"def index\n @identities = Identity.all\n\n render json: @identities\n end",
"def index\n @incidents = Incident.all\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end",
"def show\n @initiative = Initiative.find(params[:id])\n\n respond_to do |format|\n format.html # _show.html.erb\n format.json { render json: @initiative }\n end\n end",
"def show\n institution = Institution.find(params[:id])\n render json: { status: '200', message: \"Loaded Institution with id #{params[:id]}\", data: institution }, status: :ok\n rescue ActiveRecord::RecordNotFound\n render json: { status: '404', error: \"No Institution with id #{params[:id]}\", data: institution }, status: :not_found\n end",
"def incident_list_by_id(statuspage_id)\n request :method => :get,\n :url => @url + 'incidents/' + statuspage_id\n end",
"def show\n @interruption = Interruption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interruption }\n end\n end",
"def show\n @incident_kind = IncidentKind.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incident_kind }\n end\n end",
"def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @interests }\n end\n end",
"def index\n @issuing_institutions = IssuingInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @issuing_institutions }\n end\n end",
"def index\n @insurance_coverages = InsuranceCoverage.all\n end",
"def index\n @illnesses = Illness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @illnesses }\n end\n end",
"def incident_list(statuspage_id)\n request :method => :get,\n :url => @url + 'incident/list/' + statuspage_id\n end",
"def index\n @one_reg_institutions = OneRegInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @one_reg_institutions }\n end\n end",
"def show \n @inmate = Inmate.find(params[:id])\n render json: @inmate\n end",
"def index\n @unemployment_insurances = UnemploymentInsurance.all\n end",
"def index\n @ownerships = ownerships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ownerships }\n end\n end",
"def show\n @institution = Institution.find(params[:id])\n\n render json: @institution\n\n rescue ActiveRecord::RecordNotFound\n render json: {message: 'Resource not found'}, status: 404\n\n end",
"def show\n @insurance_co = InsuranceCo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @insurance_co }\n end\n end",
"def show\n render json: @inciting_incident\n end",
"def index\n @incidents = current_user.incidents\n end",
"def get_resolved_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"resolved\", :fields => \"incident_number\" }\n end",
"def show\n @inning = Inning.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inning }\n end\n end",
"def show\n p 'show?'\n @acceptances = []\n if(current_user)\n if(params[:id])\n @acceptance = Acceptance.find(params[:id])\n else\n @acceptances = Acceptance.where(\"user_id=? and (status=? or status = ?) and end_time> ?\", current_user.id, \"successfully paid\", \"payment pending\", Time.now())\n end\n end\n p \"acceptances are \"\n \n presenter = Api::V3::AcceptancesPresenter.new\n acceptances_json = @acceptances.map{|x| presenter.as_json(x)}\n p acceptances_json\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: acceptances_json }\n end\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def show\n @issuance = Issuance.where(id: params[:id]).first\n end",
"def index\n @issuances = Issuance.all\n end",
"def index\n @issuances = Issuance.all\n end",
"def show\n @income = Income.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @income }\n format.js\n end\n end",
"def show\n @asistence = Asistence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @asistence }\n end\n end",
"def show\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incident }\n end\n end",
"def show\n @conflict_illness = ConflictIllness.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conflict_illness }\n end\n end",
"def show\n @exprience = Exprience.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exprience }\n end\n end",
"def show\n @incucai = Incucai.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incucai }\n end\n end",
"def show\n @financial_institution = FinancialInstitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @financial_institution }\n end\n end",
"def show\n @impgen = Impgen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @impgen }\n end\n end",
"def show\n @person_interest = PersonInterest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @person_interest }\n end\n end",
"def show\n @interview = Interview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interview }\n end\n end",
"def index\n @surrenders = @insurance.surrenders.all\n end",
"def show\n @income = current_company.incomes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.js\n format.json { render json: @income }\n end\n end",
"def index\n @interruptions = Interruption.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interruptions }\n end\n end",
"def new\n @breadcrumb = 'create'\n @insurance = Insurance.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @insurance }\n end\n end",
"def show\n @incomestock = Incomestock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incomestock }\n end\n end",
"def show\n @ingridient = Ingridient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ingridient }\n end\n end",
"def show\n @showItin = Itinerary.find(itin_params)\n render json: @showItin, status: 200\n end",
"def index_single_gift\n render json: @gift, include: :ages, status: :ok\n end",
"def index\n @involvements = Involvement.all\n end",
"def show\n @inschool = Inschool.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inschool }\n end\n end",
"def index\n \n @interests = Interest.find(@interestsId)\n \n if params[:persona_id] == nil \n @interests = Interest.order(:name) \n end\n \n respond_to do |format|\n format.json { render :json => @interests }\n end\n end",
"def show\n @consensu = Consensu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consensu }\n end\n end",
"def show\n @insider_deal = InsiderDeal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @insider_deal }\n end\n end",
"def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end",
"def index\n @api_v1_mentorship_interests = Api::V1::MentorshipInterest.all\n end",
"def show\n @one_reg_institution = OneRegInstitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @one_reg_institution }\n end\n end",
"def index_invites\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.invited_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def index\n if params[:story_id].present?\n @invitations = Story.find(params[:story_id]).invitations\n else\n @invitations = Invitation.find_by_email(@current_user.email)\n end\n render json: @invitations\n end",
"def show\n @institution_ad = InstitutionAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution_ad }\n end\n end",
"def index\n @interviews = Interview.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interviews }\n end\n end",
"def show\n @interview = Interview.find_by_slug(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interview }\n end\n end",
"def show\n @investigation = Investigation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @investigation }\n end\n end",
"def index\n @affiliates = Affiliate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @affiliate }\n end\n end",
"def index\n @insurance_facilities = InsuranceFacility.all\n end"
] |
[
"0.7571588",
"0.6953954",
"0.65308404",
"0.6412268",
"0.6378631",
"0.635725",
"0.6346357",
"0.6323069",
"0.63030297",
"0.6291674",
"0.6273025",
"0.62484175",
"0.62144905",
"0.61850584",
"0.61679864",
"0.6157394",
"0.61315674",
"0.61246824",
"0.6111852",
"0.6104262",
"0.6097528",
"0.60964966",
"0.60890096",
"0.6085226",
"0.6074616",
"0.6059803",
"0.6054536",
"0.6045024",
"0.60272735",
"0.60152274",
"0.59924775",
"0.5985034",
"0.59392715",
"0.5933526",
"0.5932738",
"0.591412",
"0.5906131",
"0.59051126",
"0.5898908",
"0.58968794",
"0.58968794",
"0.58939683",
"0.5887753",
"0.58810425",
"0.5878087",
"0.5870949",
"0.5863755",
"0.58584166",
"0.5856577",
"0.5849252",
"0.5842611",
"0.58415276",
"0.583561",
"0.5828791",
"0.5824215",
"0.58240986",
"0.58081454",
"0.5803206",
"0.5798903",
"0.5787679",
"0.5784245",
"0.57840174",
"0.5782297",
"0.5773285",
"0.577237",
"0.577237",
"0.5770871",
"0.57564116",
"0.57510704",
"0.5750141",
"0.5742331",
"0.5738993",
"0.57357043",
"0.5734583",
"0.57261586",
"0.57134646",
"0.56979346",
"0.568469",
"0.56824076",
"0.5676895",
"0.567572",
"0.56714505",
"0.5662314",
"0.5661586",
"0.56597537",
"0.5656821",
"0.5655912",
"0.5650628",
"0.5642652",
"0.5639773",
"0.5637385",
"0.56155366",
"0.5609345",
"0.5607442",
"0.5606351",
"0.5603251",
"0.56010824",
"0.55998904",
"0.5597956",
"0.55962056"
] |
0.60024834
|
30
|
GET /insurances/new GET /insurances/new.json
|
def new
@breadcrumb = 'create'
@insurance = Insurance.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @insurance }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @life_insurance = LifeInsurance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @life_insurance }\n end\n end",
"def new\n @encounter = Encounter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @encounter }\n end\n end",
"def new\n @income = Income.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @income }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interest }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end",
"def new\n @inning = Inning.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inning }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interest }\n end\n end",
"def new\n @income_entry = IncomeEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @income_entry }\n end\n end",
"def new\n @inspiration = Inspiration.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inspiration }\n end\n end",
"def new\n @endurance = Endurance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @endurance }\n end\n end",
"def new\n @event_interest = EventInterest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_interest }\n end\n end",
"def new\n @incident = Incident.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incident }\n end\n end",
"def new\n @incident_kind = IncidentKind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incident_kind }\n end\n end",
"def new\n @incomestock = Incomestock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incomestock }\n end\n end",
"def new\n @illness = Illness.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @illness }\n end\n end",
"def new\n @insurer = Insurer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @insurer }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interest }\n end\n end",
"def new\n @institution = Institution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @institution }\n end\n end",
"def new\n @income = Income.new\n\n respond_to do |format|\n format.json { render json: @income }\n format.js\n end\n end",
"def new\n @refund = Refund.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @refund }\n end\n end",
"def new\n @refund = Refund.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @refund }\n end\n end",
"def create\n @breadcrumb = 'create'\n @insurance = Insurance.new(params[:insurance])\n @insurance.created_by = current_user.id if !current_user.nil?\n \n respond_to do |format|\n if @insurance.save\n format.html { redirect_to @insurance, notice: crud_notice('created', @insurance) }\n format.json { render json: @insurance, status: :created, location: @insurance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @title = \"Добавление типа страхования\"\n @insurance_type = InsuranceType.new\n\n respond_to do |format|\n if InsuranceType.all.length < 2\n format.html # new.html.erb\n format.json { render json: @insurance_type }\n end\n end\n end",
"def new\n @party = Party.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @party }\n end\n end",
"def new\n @person_interest = PersonInterest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person_interest }\n end\n end",
"def new\n @lookup = Lookup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lookup }\n end\n end",
"def new\n @impgen = Impgen.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @impgen }\n end\n end",
"def new\n @institucional = Institucional.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @institucional }\n end\n end",
"def create\n @life_insurance = LifeInsurance.new(params[:life_insurance])\n\n respond_to do |format|\n if @life_insurance.save\n format.html { redirect_to @life_insurance, notice: 'Life insurance was successfully created.' }\n format.json { render json: @life_insurance, status: :created, location: @life_insurance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @life_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @residence = Residence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @residence }\n end\n end",
"def new\n @intention = Intention.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intention }\n end\n end",
"def new\n @indicacao = Indicacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indicacao }\n end\n end",
"def new\n @opinion = Opinion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @opinion }\n end\n end",
"def new\n @opinion = Opinion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @opinion }\n end\n end",
"def new\n @finance = Finance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finance }\n end\n end",
"def new\n @interview = Interview.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interview }\n end\n end",
"def new\n @stundent = Stundent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stundent }\n end\n end",
"def create(params = {})\n wrapped_params = { insurance: params }\n @client.make_request(:post, 'insurances', MODEL_CLASS, wrapped_params)\n end",
"def new\n @constitution = Constitution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @constitution }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def new\n @investigation = Investigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @investigation }\n end\n end",
"def new\n @inschool = Inschool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inschool }\n end\n end",
"def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end",
"def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end",
"def new\n @insure_result = InsureResult.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @insure_result }\n end\n end",
"def new\n @historial = Historial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @historial }\n end\n end",
"def new\n @anniversary = Anniversary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def new\n @financial_institution = FinancialInstitution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @financial_institution }\n end\n end",
"def new\n @icome = Icome.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @icome }\n end\n end",
"def new\n @ins_company = InsCompany.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ins_company }\n end\n end",
"def new\n @apprentice = Apprentice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @apprentice }\n end\n end",
"def new\n @interesting = Interesting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interesting }\n end\n end",
"def new\n @incident_type = IncidentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incident_type }\n end\n end",
"def new\n @insurance_co = InsuranceCo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @insurance_co }\n end\n end",
"def new\n @exprience = Exprience.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exprience }\n end\n end",
"def new\n @indicativo = Indicativo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indicativo }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @interested = Interested.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interested }\n end\n end",
"def new\n @except = Except.new\n @policy = Policy.find(:all)\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @except }\n end\n end",
"def new\n @ingridient = Ingridient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingridient }\n end\n end",
"def new\n @census_count = CensusCount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @census_count }\n end\n end",
"def create\n @life_insurance = LifeInsurance.new(life_insurance_params)\n\n respond_to do |format|\n if @life_insurance.save\n format.html { redirect_to @life_insurance, notice: 'Life insurance was successfully created.' }\n format.json { render action: 'show', status: :created, location: @life_insurance }\n else\n format.html { render action: 'new' }\n format.json { render json: @life_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @ident = Ident.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ident }\n end\n end",
"def new\n @ingredients_name = IngredientsName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredients_name }\n end\n end",
"def new\n @visitation = Visitation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @visitation }\n end\n end",
"def new\n @clue = Clue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clue }\n end\n end",
"def new\n @clue = Clue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clue }\n end\n end",
"def new\n @bank = Bank.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bank }\n end\n end",
"def new\n @competency = Competency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency }\n end\n end",
"def new\n @correlation = Correlation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @correlation }\n end\n end",
"def new\n @ingredience = Ingredience.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ingredience }\n end\n end",
"def new\n @region = Region.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @region }\n end\n end",
"def new\n @finance_inflow = FinanceInflow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finance_inflow }\n end\n end",
"def new\n @issuer = Issuer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issuer }\n end\n end",
"def new\n @financial = Financial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @financial }\n end\n end",
"def new\n @early_pregnancy = EarlyPregnancy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @early_pregnancy }\n end\n end",
"def new\n @statement = Statement.find(params[:statement_id])\n @expense = Expense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expense }\n end\n end",
"def new\n @consensu = Consensu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @consensu }\n end\n end",
"def new\n @nail_salon = NailSalon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nail_salon }\n end\n end",
"def new\n #@getinvoicedatum = Getinvoicedatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @getinvoicedatum }\n end\n end",
"def new\n @situation = Situation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @situation }\n end\n end",
"def new\n @owner = Owner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @owner }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @interest }\n end\n end",
"def new\n @year_insurances = YearInsurance.active.joins(:family)\n @reimbursement = Reimbursement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reimbursement }\n end\n end",
"def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end",
"def new\n @insider_deal = InsiderDeal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @insider_deal }\n end\n end",
"def new\n @notice = @person.notices.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @notice }\n end\n end",
"def new\n @presence = Presence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @presence }\n end\n end",
"def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end",
"def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end",
"def new\r\n @attestation = Attestation.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @attestation }\r\n end\r\n end",
"def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loan }\n end\n end",
"def create\n @income = current_user.incomes.new(params[:income])\n\n respond_to do |format|\n if @income.save\n format.html { redirect_to incomes_path, notice: 'Income was successfully created.' }\n format.json { render json: @income, status: :created, location: @income }\n else\n format.html { render action: \"new\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @providerable, @name = find_polymorphic\n @provider = ProviderInsurance.new\n @title = @name.titleize + \" New Provider Insurance\"\n @all_insurance_company = InsuranceCompany.find(:all, :order => :name)\n @edit = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @situation = Situation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @situation }\n end\n end",
"def new\n @national_rank = NationalRank.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @national_rank }\n end\n end",
"def new\n @album_owned = AlbumOwned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album_owned }\n end\n end",
"def new\n @civilization = Civilization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @civilization }\n end\n end"
] |
[
"0.7366726",
"0.73468244",
"0.73156685",
"0.71787214",
"0.7176036",
"0.71592754",
"0.71096146",
"0.7084484",
"0.7068973",
"0.7048612",
"0.70114356",
"0.6992487",
"0.69218963",
"0.68838876",
"0.68780994",
"0.68759686",
"0.6850693",
"0.68302166",
"0.6823267",
"0.6812231",
"0.6812231",
"0.68086046",
"0.6799225",
"0.677569",
"0.6758871",
"0.67566943",
"0.6750725",
"0.6732786",
"0.67205304",
"0.6718037",
"0.6703293",
"0.66892344",
"0.6678873",
"0.6678873",
"0.66762686",
"0.66669714",
"0.6662096",
"0.6655214",
"0.66532946",
"0.66516453",
"0.66516453",
"0.6638043",
"0.66291684",
"0.6626911",
"0.6626911",
"0.6623075",
"0.6621177",
"0.66084474",
"0.65981036",
"0.6596809",
"0.6596586",
"0.6593975",
"0.6593884",
"0.6592323",
"0.65907735",
"0.6588525",
"0.6583298",
"0.6579007",
"0.6579007",
"0.65711987",
"0.65653634",
"0.65634865",
"0.6560131",
"0.655788",
"0.6542448",
"0.6533501",
"0.6532624",
"0.6531556",
"0.6531556",
"0.6529732",
"0.6521111",
"0.65167177",
"0.6514122",
"0.6509899",
"0.65098566",
"0.6507969",
"0.6507222",
"0.6504796",
"0.65020967",
"0.65014434",
"0.6500785",
"0.6498434",
"0.649749",
"0.64970165",
"0.649127",
"0.64888203",
"0.6483377",
"0.648025",
"0.64794",
"0.64749634",
"0.6462111",
"0.6462111",
"0.64613837",
"0.64606774",
"0.64606696",
"0.6460175",
"0.6459233",
"0.6458469",
"0.6456499",
"0.64547783"
] |
0.7853387
|
0
|
POST /insurances POST /insurances.json
|
def create
@breadcrumb = 'create'
@insurance = Insurance.new(params[:insurance])
@insurance.created_by = current_user.id if !current_user.nil?
respond_to do |format|
if @insurance.save
format.html { redirect_to @insurance, notice: crud_notice('created', @insurance) }
format.json { render json: @insurance, status: :created, location: @insurance }
else
format.html { render action: "new" }
format.json { render json: @insurance.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create(params = {})\n wrapped_params = { insurance: params }\n @client.make_request(:post, 'insurances', MODEL_CLASS, wrapped_params)\n end",
"def create\n #@incident = @quote.incidents.new(incident_params)\n logger.info params[:incident]\n params[:incident].each do |incident|\n @incident = @quote.incidents.new(incident)\n @incident.save\n end\n respond_to do |format|\n format.json { render :json => { :code => \"201\", :description => \"Created incidents\"} }\n end\n end",
"def create\n @insurancestatus = Insurancestatus.new(insurancestatus_params)\n\n respond_to do |format|\n if @insurancestatus.save\n format.html { redirect_to @insurancestatus, notice: 'Insurancestatus was successfully created.' }\n format.json { render :show, status: :created, location: @insurancestatus }\n else\n format.html { render :new }\n format.json { render json: @insurancestatus.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @income = current_user.incomes.new(params[:income])\n\n respond_to do |format|\n if @income.save\n format.html { redirect_to incomes_path, notice: 'Income was successfully created.' }\n format.json { render json: @income, status: :created, location: @income }\n else\n format.html { render action: \"new\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interest = Interest.new(params[:interest])\n \n respond_to do |format|\n if @interest.save\n format.json { render :json => @interest,\n :status => :created, :location => @interest }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @life_insurance = LifeInsurance.new(params[:life_insurance])\n\n respond_to do |format|\n if @life_insurance.save\n format.html { redirect_to @life_insurance, notice: 'Life insurance was successfully created.' }\n format.json { render json: @life_insurance, status: :created, location: @life_insurance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @life_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def all(params = {})\n @client.make_request(:get, 'insurances', MODEL_CLASS, params)\n end",
"def create\n @insurance_coverage = InsuranceCoverage.new(insurance_coverage_params)\n\n respond_to do |format|\n if @insurance_coverage.save\n format.html { redirect_to @insurance_coverage, notice: 'Insurance coverage was successfully created.' }\n format.json { render :show, status: :created, location: @insurance_coverage }\n else\n format.html { render :new }\n format.json { render json: @insurance_coverage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unemployment_insurance = UnemploymentInsurance.new(unemployment_insurance_params)\n\n respond_to do |format|\n if @unemployment_insurance.save\n format.html { redirect_to @unemployment_insurance, notice: 'Unemployment insurance was successfully created.' }\n format.json { render :show, status: :created, location: @unemployment_insurance }\n else\n format.html { render :new }\n format.json { render json: @unemployment_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(params[:user])\n @animal = Animal.find(params[:animal])\n @interest = Interest.new(user_id: @user.id, animal_id: @animal.id, date: Date.today)\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to :back, notice: 'You sent an interest to the animal' }\n format.json { head :no_content }\n else\n format.html { redirect_to animals_url, notice: @interest.errors.full_messages[0] }\n format.json { head :no_content }\n end\n end\n end",
"def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, :notice => 'Interest was successfully created.' }\n format.json { render :json => @interest, :status => :created, :location => @interest }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @infraction = Infraction.new(infraction_params)\n\n respond_to do |format|\n if @infraction.save\n format.html { redirect_to @infraction, notice: 'Infraction was successfully created.' }\n format.json { render :show, status: :created, location: @infraction }\n else\n format.html { render :new }\n format.json { render json: @infraction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, notice: 'Interest was successfully created.' }\n format.json { render json: @interest, status: :created, location: @interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @life_insurance = LifeInsurance.new(life_insurance_params)\n\n respond_to do |format|\n if @life_insurance.save\n format.html { redirect_to @life_insurance, notice: 'Life insurance was successfully created.' }\n format.json { render action: 'show', status: :created, location: @life_insurance }\n else\n format.html { render action: 'new' }\n format.json { render json: @life_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def insurance_params\n params.require(:insurance).permit(:number, :concluded, :valid_from, :applies_to, :pay, :insurance_lock, :note, :company_id, :inputWalls)\n end",
"def create\n @event_interest = EventInterest.new(params[:event_interest])\n\n respond_to do |format|\n if @event_interest.save\n format.html { redirect_to @event_interest, notice: 'Event interest was successfully created.' }\n format.json { render json: @event_interest, status: :created, location: @event_interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_and_invitation_studant(params = {})\n run(:post, \"/invitations\", [201,422], JSON.dump(params))\n end",
"def create\n @income = Income.new(income_params)\n\n respond_to do |format|\n if @income.save\n format.html { redirect_to @income, notice: 'Income was successfully created.' }\n format.json { render json: @income, status: :created, location: @income }\n else\n format.html { render action: \"new\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @issuance = Issuance.new(issuance_params)\n\n respond_to do |format|\n if @issuance.save\n format.html { redirect_to @issuance, notice: 'Issuance was successfully created.' }\n format.json { render :show, status: :created, location: @issuance }\n else\n format.html { render :new }\n format.json { render json: @issuance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @issuance = Issuance.new(issuance_params)\n\n respond_to do |format|\n if @issuance.save\n format.html { redirect_to @issuance, notice: 'Issuance was successfully created.' }\n format.json { render :show, status: :created, location: @issuance }\n else\n format.html { render :new }\n format.json { render json: @issuance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @income_entry = IncomeEntry.new(params[:income_entry])\n\n respond_to do |format|\n if @income_entry.save\n format.html { redirect_to \"/income\", notice: 'Income entry was successfully created.' }\n format.json { render json: @income_entry, status: :created, location: @income_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @income_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @insurer = Insurer.new(params[:insurer])\n\n respond_to do |format|\n if @insurer.save\n format.html { redirect_to @insurer, notice: 'Insurer was successfully created.' }\n format.json { render json: @insurer, status: :created, location: @insurer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @insurer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @injury = Injury.new(injury_params)\n\n respond_to do |format|\n if @injury.save\n format.html { redirect_to injuries_url, notice: 'Injury was successfully created.' }\n # format.json { render :show, status: :created, location: @injury }\n else\n format.html { render :new }\n format.json { render json: @injury.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @indivisual = Indivisual.new(indivisual_params)\n\n respond_to do |format|\n if @indivisual.save\n format.html { redirect_to @indivisual, notice: 'Indivisual was successfully created.' }\n format.json { render :show, status: :created, location: @indivisual }\n else\n format.html { render :new }\n format.json { render json: @indivisual.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @encounter = Encounter.new(params[:encounter])\n\n respond_to do |format|\n if @encounter.save\n format.html { redirect_to @encounter, notice: 'Encounter was successfully created.' }\n format.json { render json: @encounter, status: :created, location: @encounter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @encounter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @seance = Seances::UseCases::Create.new.call(params: seance_params)\n\n if @seance.valid?\n render jsonapi: @seance, status: :created\n else\n render jsonapi_errors: @seance.errors, status: :unprocessable_entity\n end\n end",
"def create\n @interest = Interest.new(interest_params)\n authorize @interest\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, notice: t('flash.notice.created') }\n format.json { render :show, status: :created, location: @interest }\n else\n format.html { render :new }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @endurance = Endurance.new(params[:endurance])\n\n respond_to do |format|\n if @endurance.save\n format.html { redirect_to @endurance, notice: 'Endurance was successfully created.' }\n format.json { render json: @endurance, status: :created, location: @endurance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @endurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @health_insurance = HealthInsurance.new(health_insurance_params)\n\n respond_to do |format|\n if @health_insurance.save\n format.html { redirect_to patient_path(@health_insurance.patient), notice: 'Health insurance was successfully created.' }\n format.json { render :show, status: :created, location: @health_insurance }\n else\n format.html { render :new }\n format.json { render json: @health_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def create\n \n @income = Income.new(params[:income])\n @income.user = current_user\n \n respond_to do |format|\n if @income.save\n format.json { render json: @income, status: :created, location: @income }\n format.js\n else\n format.json { render json: @income.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def create\n @insurance_co = InsuranceCo.new(params[:insurance_co])\n\n respond_to do |format|\n if @insurance_co.save\n format.html { redirect_to(@insurance_co, :notice => 'Insurance co was successfully created.') }\n format.xml { render :xml => @insurance_co, :status => :created, :location => @insurance_co }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @insurance_co.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @inciting_incident = IncitingIncident.new(inciting_incident_params)\n\n if @inciting_incident.save\n render json: @inciting_incident, status: :created, location: @inciting_incident\n else\n render json: @inciting_incident.errors, status: :unprocessable_entity\n end\n end",
"def create\n @insurance_type = InsuranceType.new(params[:insurance_type])\n\n respond_to do |format|\n if @insurance_type.save\n flash[:success] = \"Тип успешно добавлен.\"\n format.html { redirect_to @insurance_type }\n format.json { render json: @insurance_type, status: :created, location: @insurance_type }\n else\n flash.now[:error] = \"Тип с таким названием не может быть добавлен!\"\n format.html { render action: \"new\" }\n format.json { render json: @insurance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @insurance_facility = InsuranceFacility.new(insurance_facility_params)\n\n respond_to do |format|\n if @insurance_facility.save\n format.html { redirect_to @insurance_facility, notice: 'Insurance facility was successfully created.' }\n format.json { render :show, status: :created, location: @insurance_facility }\n else\n format.html { render :new }\n format.json { render json: @insurance_facility.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_interest = UserInterest.new(user_interest_params)\n\n respond_to do |format|\n if @user_interest.save\n format.html { redirect_to @user_interest, notice: 'User interest was successfully created.' }\n format.json { render :show, status: :created, location: @user_interest }\n else\n format.html { render :new }\n format.json { render json: @user_interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @insurance = Insurance.new(insurance_params)\n @insurance.user = current_user\n\n respond_to do |format|\n if @insurance.save\n @insurance.duplicate_all_data_from_last_rotation(params[:duplicate_insurance]) if (params[:duplicate_insurance]).present? # dodaj ostatnią rotację jezeli wykonujesz duplikat\n\n format.html { redirect_to @insurance, success: t('activerecord.messages.successfull.created', data: @insurance.number) }\n format.json { render :show, status: :created, location: @insurance }\n else\n format.html { render :new, locals: { duplicate_insurance: params[:duplicate_insurance]} }\n format.json { render json: @insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @involvement = Involvement.new(involvement_params)\n\n respond_to do |format|\n if @involvement.save\n format.html { redirect_to @involvement, notice: 'Involvement was successfully created.' }\n format.json { render :show, status: :created, location: @involvement }\n else\n format.html { render :new }\n format.json { render json: @involvement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if user_interest_params && @current_user.id == user_interest_params[:user_id].to_i #only create them if the current user = the parameter user\n \n @user_id = user_interest_params[:user_id]\n\n count = 1\n interests_to_add = does_interest_exist(user_interest_params) #only add interests that don't exist yet\n \n if interests_to_add.length >= 1 #only run this if there are interests to add\n interests_to_add.each do |interest|\n @user_interest = UserInterest.new(user_id: @user_id, interest_id: interest)\n \n if @user_interest.save\n if count == interests_to_add.length #show success only for the last one\n render json: { \n status: 200,\n message: \"Successfully added user interests\",\n user_interests: @user_interest\n }.to_json\n end\n else\n render json: {\n status: 500,\n message: \"Couldn't save user interests\",\n errors: @user_interest.errors\n }.to_json\n end\n count += 1\n end\n else #if there are no interests to add, state so.\n render json: {\n status: 200,\n message: \"No interests to add\"\n }.to_json\n end\n else\n render json: {\n status: 400,\n message: \"Invalid authentication\"\n }.to_json\n end\n end",
"def create\n @institucional = Institucional.new(params[:institucional])\n\n respond_to do |format|\n if @institucional.save\n format.html { redirect_to @institucional, notice: 'Institucional was successfully created.' }\n format.json { render json: @institucional, status: :created, location: @institucional }\n else\n format.html { render action: \"new\" }\n format.json { render json: @institucional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @inspiration = Inspiration.new(inspiration_params)\n\n respond_to do |format|\n if @inspiration.save\n format.html { redirect_to @inspiration, notice: 'Inspiration was successfully created.' }\n format.json { render action: 'show', status: :created, location: @inspiration }\n else\n format.html { render action: 'new' }\n format.json { render json: @inspiration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @breadcrumb = 'create'\n @insurance = Insurance.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @insurance }\n end\n end",
"def create\n @inspiration = Inspiration.new(params[:inspiration])\n \n respond_to do |format|\n if @inspiration.save\n format.html { redirect_to @inspiration, notice: 'Inspiration was successfully created.' }\n format.json { render json: @inspiration, status: :created, location: @inspiration }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inspiration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def insurance_params\n params.require(:insurance).permit(:primary_name, :primary_plocy_number, :primary_group_number, :primary_coverage_limits, \n :primary_deductible, :primary_copay, :primary_coinsurance, :primary_out_of_network_fee, \n :secondary_name, :secondary_plocy_number, :secondary_group_number, :secondary_coverage_limits, \n :secondary_deductible, :secondary_copay, :secondary_coinsurance, :secondary_out_of_network_fee, \n :tertiary_name, :tertiary_plocy_number, :tertiary_group_number, :tertiary_coverage_limits, \n :tertiary_deductible, :tertiary_copay, :tertiary_coinsurance, :tertiary_out_of_network_fee)\n end",
"def create\n #assign unpermitted parameter 'entries' to a variable\n entries = params[\"entries\"]\n @invoice = @user.invoices.build(invoice_params)\n #save entries\n @invoice.entries = entries\n if @invoice.save\n render json: @invoice, status: :created, location: api_v1_user_invoice_url(@user, @invoice)\n else\n render json: @invoice.errors, status: :unprocessable_entity\n end\n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @life_insurances }\n end\n end",
"def create\n @incident = Incident.new(incident_params)\n\n if @incident.save\n render json: @incident, status: :created, location: @incident\n else\n render json: @incident.errors, status: :unprocessable_entity\n end\n end",
"def create\n @connaissance = Connaissance.new(connaissance_params)\n\n respond_to do |format|\n if @connaissance.save\n format.html { redirect_to @connaissance, notice: 'Connaissance was successfully created.' }\n format.json { render :show, status: :created, location: @connaissance }\n else\n format.html { render :new }\n format.json { render json: @connaissance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n params[:refill_type] = params[:refill_type].to_i\n params[:status] = params[:status].to_i\n params[:cost_basis] = params[:cost_basis].to_i\n params[:other_coverage_code] = params[:other_coverage_code].to_i\n params[:reason_for_delay] = params[:reason_for_delay].to_i\n params[:partial_fill_status] = params[:partial_fill_status].to_i\n params[:reported_to_pmp] = params[:reported_to_pmp].to_i\n\n @dispense = Dispense.new(dispense_params)\n\n respond_to do |format|\n if @dispense.save\n format.html { redirect_to @dispense, notice: 'Dispense was successfully created.' }\n format.json { render :show, status: :created, location: @dispense }\n else\n format.html { render :new }\n format.json { render json: @dispense.errors, status: :unprocessable_entity }\n end\n end\n end",
"def retrieve(id)\n @client.make_request(:get, \"insurances/#{id}\", MODEL_CLASS)\n end",
"def create\n @surrender = @insurance.surrenders.new(surrender_params)\n\n respond_to do |format|\n if @surrender.save\n format.html { redirect_to [@surrender.insurance, @surrender], notice: 'Surrender was successfully created.' }\n format.json { render :show, status: :created, location: [@surrender.insurance, @surrender] }\n else\n format.html { render :new }\n format.json { render json: @surrender.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n @interest = Interest.new(interest_params)\n @interest.save\n end",
"def create\n @incidence = Incidence.new(incidence_params)\n\n respond_to do |format|\n if @incidence.save\n format.html { redirect_to @incidence, notice: 'Incidencia creada exitosamente.' }\n format.json { render :show, status: :created, location: @incidence }\n else\n format.html { render :new }\n format.json { render json: @incidence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stance = Stance.new(stance_params)\n @stance.participant = Participant.find_by(:session_id => session[:session_id])\n\n respond_to do |format|\n if @stance.save\n format.html { redirect_to ranking_path }\n format.json { render action: 'show', status: :created, location: @stance }\n else\n format.html { render action: 'new' }\n format.json { render json: @stance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reimbursement = Reimbursement.new(params[:reimbursement])\n @year_insurances = YearInsurance.active.joins(:family)\n respond_to do |format|\n if @reimbursement.save\n format.html { redirect_to reimbursements_path, notice: 'Reimbursement was successfully created.' }\n format.json { render json: @reimbursement, status: :created, location: @reimbursement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reimbursement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ingredience = Ingredience.new(params[:ingredience])\n respond_to do |format|\n if @ingredience.save\n flash[:notice] = 'Ingredience was successfully created.'\n #format.html { redirect_to(@ingredience) }\n format.xml { render :xml => @ingredience, :status => :created, :location => @ingredience }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ingredience.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @inning = Inning.new(params[:inning])\n\n respond_to do |format|\n if @inning.save\n format.html { redirect_to @inning, notice: 'Inning was successfully created.' }\n format.json { render json: @inning, status: :created, location: @inning }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inning.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @eventinterest = Eventinterest.new(eventinterest_params)\n\n respond_to do |format|\n if @eventinterest.save\n format.html { redirect_to @eventinterest, notice: 'Eventinterest was successfully created.' }\n format.json { render :show, status: :created, location: @eventinterest }\n else\n format.html { render :new }\n format.json { render json: @eventinterest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @incidentfollowup = Incidentfollowup.new(incidentfollowup_params)\n incident = @incidentfollowup.incident\n incident.status = @incidentfollowup.status\n incident.save\n respond_to do |format|\n if @incidentfollowup.save\n format.html { redirect_to @incidentfollowup.incident, notice: 'Incidentfollowup was successfully created.' }\n format.json { render :show, status: :created, location: @incidentfollowup }\n else\n format.html { render :new }\n format.json { render json: @incidentfollowup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @issuance = Issuance.new(issuance_params)\n respond_to do |format|\n if @issuance\n current_user.issuances << @issuance\n stk_id = params[:issuance][:stock_id]\n qtysb = params[:issuance][:qtysingleb]\n stock = Stock.find(stk_id)\n stock.update(:qtyreceived => qtysb)\n format.html { redirect_to issuances_path, notice: 'Issuance was successfully created.' }\n format.json { render :show, status: :created, location: @issuance }\n else\n format.html { render :new }\n format.json { render json: @issuance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def incarnation_params\n params.require(:incarnation).permit(:profile_id, :kind, :title, :name, :gender, :other_gender, :gold, :gems, :hitpoints, :max_hitpoints, :mana, :max_mana, :experience, :level, :turns, :location_id, :coroutine, :display)\n end",
"def create\n #Makes an innings associated with a given match\n @innings = Innings.new(innings_params)\n\n respond_to do |format|\n if @innings.save\n format.html { redirect_to match_path(@match), notice: 'Innings was successfully created.' }\n format.json { render :show, status: :created, location: @innings }\n else\n format.html { render :new }\n format.json { render json: @innings.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @house_interest_list = HouseInterestList.new(house_interest_list_params)\n @house_interest_list.user_id = session[:id]\n @house_interest_list.company_id = House.find(@house_interest_list.house_id).company_id\n \n respond_to do |format|\n if @house_interest_list.save\n format.html {redirect_to @house_interest_list, notice: 'House interest list was successfully created.'}\n format.json {render :show, status: :created, location: @house_interest_list}\n else\n format.html {render :new}\n format.json {render json: @house_interest_list.errors, status: :unprocessable_entity}\n end\n end\n end",
"def index\n @insurance_queries = InsuranceQuery.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @insurance_queries }\n end\n end",
"def index\n @insurancestatuses = Insurancestatus.all\n end",
"def create\n @incarnation = Incarnation.new(incarnation_params)\n\n respond_to do |format|\n if @incarnation.save\n format.html { redirect_to @incarnation, notice: 'Incarnation was successfully created.' }\n format.json { render :show, status: :created, location: @incarnation }\n else\n format.html { render :new }\n format.json { render json: @incarnation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @individual_int = IndividualInt.new(individual_int_params)\n\n respond_to do |format|\n if @individual_int.save\n format.html { redirect_to @individual_int, notice: 'Individual int was successfully created.' }\n format.json { render :show, status: :created, location: @individual_int }\n else\n format.html { render :new }\n format.json { render json: @individual_int.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interest = Interest.new(interest_params)\n @interest.user_id=current_user.id\n if(@interest.save)\n render json: {\"success\":true,\"message\":\"Done!\"}\n else\n render json: {\"success\":false,\"message\":@interest.errors}\n end\n # respond_to do |format|\n # if @interest.save\n # format.html { redirect_to @interest, notice: 'Interest was successfully created.' }\n # format.json { render :show, status: :created, location: @interest }\n # else\n # format.html { render :new }\n # format.json { render json: @interest.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @sigandanny = Sigandanny.new(sigandanny_params)\n\n respond_to do |format|\n if @sigandanny.save\n format.html { redirect_to @sigandanny, notice: 'Sigandanny was successfully created.' }\n format.json { render :show, status: :created, location: @sigandanny }\n else\n format.html { render :new }\n format.json { render json: @sigandanny.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @incomestock = Incomestock.new(params[:incomestock])\n\n respond_to do |format|\n if @incomestock.save\n format.html { redirect_to @incomestock, notice: 'Incomestock was successfully created.' }\n format.json { render json: @incomestock, status: :created, location: @incomestock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @incomestock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @inspection = Inspection.new(params[:inspection])\n\n respond_to do |format|\n if @inspection.save\n format.html { redirect_to inspections_path, notice: t(\"activerecord.models.inspection\") + t(\"message.created\") }\n format.json { render json: @inspection, status: :created, location: @inspection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inspection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @observance = Observance.new(observance_params)\n\n respond_to do |format|\n if @observance.save\n format.html { redirect_to @observance, notice: 'Observance was successfully created.' }\n format.json { render action: 'show', status: :created, location: @observance }\n else\n format.html { render action: 'new' }\n format.json { render json: @observance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student_interest = StudentInterest.new(student_interest_params)\n\n respond_to do |format|\n if @student_interest.save\n format.html { redirect_to @student_interest, notice: 'Student interest was successfully created.' }\n format.json { render action: 'show', status: :created, location: @student_interest }\n else\n format.html { render action: 'new' }\n format.json { render json: @student_interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @insurance_query = InsuranceQuery.new(params[:insurance_query])\n payer = Payer.find_by_id(params[:insurance_query][:payer_id])\n logger.debug \"#{params[:insurance_query]}\"\n @insurance_query.payer_code = payer.payer_code\n @insurance_query.payer_name = payer.payer_name\n\n respond_to do |format|\n if @insurance_query.save\n format.html { redirect_to @insurance_query, notice: \"Your query was successfully processed\"}\n format.json { render json: @insurance_query, status: :created, location: @insurance_query }\n else\n format.html { render action: \"new\" }\n format.json { render json: @insurance_query.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @health_insurances = HealthInsurance.all\n end",
"def create\n @invitation_request = InvitationRequest.new(invitation_request_params)\n\n respond_to do |format|\n if @invitation_request.save\n format.html { redirect_to root_path, notice: 'Invitation received. We will notify you soon!' }\n format.json { render :show, status: :created, location: @invitation_request }\n else\n @interests = Interest.all\n format.html { render :new }\n format.json { render json: @invitation_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_v1_mentorship_interest = Api::V1::MentorshipInterest.new(api_v1_mentorship_interest_params)\n\n respond_to do |format|\n if @api_v1_mentorship_interest.save\n format.html { redirect_to @api_v1_mentorship_interest, notice: 'Mentorship interest was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_mentorship_interest }\n else\n format.html { render :new }\n format.json { render json: @api_v1_mentorship_interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def health_insurance_params\n params.require(:health_insurance).permit(:company, :phone, :id_number, :group_number, :coverage, :copays, :patient_id)\n end",
"def create\n @infection = Infection.new(infection_params)\n\n respond_to do |format|\n if @infection.save\n format.html { redirect_to @infection, notice: 'Infection was successfully created.' }\n format.json { render :show, status: :created, location: @infection }\n else\n format.html { render :new }\n format.json { render json: @infection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @seihinn = Seihinn.new(seihinn_params)\n\n respond_to do |format|\n if @seihinn.save\n format.html { redirect_to @seihinn, notice: \"Seihinn was successfully created.\" }\n format.json { render :show, status: :created, location: @seihinn }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @seihinn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @instancium = Instancium.new(instancium_params)\n\n respond_to do |format|\n if @instancium.save\n format.html { redirect_to @instancium, notice: 'Instancium was successfully created.' }\n format.json { render :show, status: :created, location: @instancium }\n else\n format.html { render :new }\n format.json { render json: @instancium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @person_interest = PersonInterest.new(params[:person_interest])\n\n respond_to do |format|\n if @person_interest.save\n format.html { redirect_to @person_interest, notice: 'Person interest was successfully created.' }\n format.json { render json: @person_interest, status: :created, location: @person_interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @person_interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n successes = []\n (params[:invitations].split(',') || []).each do |name|\n name.strip!\n invitation = @game.invitations.build(:twitter_login => name, :invited_by => current_user)\n successes << name if invitation.save\n # TODO: send actual invitations as DMs from the user??\n # TODO: verify that the listed people are actually followers of the user?\n end\n flash[:notice] = \"Invitations have been sent to the #{successes.length} people you selected\"\n redirect_to(game_path(@game))\n end",
"def create\n @rankin = Rankin.new(rankin_params)\n\n if @rankin.save\n render json: @rankin, status: :created, location: api_v1_rankin_url(@rankin, format: :json)\n else\n render json: @rankin.errors, status: :unprocessable_entity\n end\n end",
"def create\n standard_create(Interest, interest_params)\n end",
"def innings_params\n params.require(:innings).permit(:id, :match_id, :hometeambatted, :byes, :legbyes, :penalties)\n end",
"def create\n @occurrence_bulletin = OccurrenceBulletin.new(occurrence_bulletin_params)\n\n respond_to do |format|\n if @occurrence_bulletin.save\n format.html { redirect_to @occurrence_bulletin, notice: 'Occurrence bulletin was successfully created.' }\n format.json { render :show, status: :created, location: @occurrence_bulletin }\n else\n format.html { render :new }\n format.json { render json: @occurrence_bulletin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_financials\n current_user.update(assets: params[:assets], average_annual_income: params[:average_annual_income], credit_score: params[:credit_score], total_debt: params[:total_debt])\n user_listings = current_user.listings\n render json: [current_user, user_listings]\n end",
"def create\n @interest = Interest.new(params[:interest])\n if @interest.save\n redirect_to interests_path\n else\n redirect_to new_interest_path\n end\n end",
"def interest_params\n params.require(:interest).permit(:user_id, :animal_id, :date)\n end",
"def create\n @inscripcion = Inscripcion.new(inscripcion_params)\n\n respond_to do |format|\n if @inscripcion.save\n format.html { redirect_to @inscripcion, notice: 'Inscripcion was successfully created.' }\n format.json { render :show, status: :created, location: @inscripcion }\n else\n format.html { render :new }\n format.json { render json: @inscripcion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @insure_result = InsureResult.new(params[:insure_result])\n\n respond_to do |format|\n if @insure_result.save\n format.html { redirect_to @insure_result, :notice => 'Insure result was successfully created.' }\n format.json { render :json => @insure_result, :status => :created, :location => @insure_result }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @insure_result.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def profile_params\n params.require(:profile).permit(:name, :bio, :country_id, :picture, interest_ids: [])\n end",
"def create\n @incident_kind = IncidentKind.new(params[:incident_kind])\n\n respond_to do |format|\n if @incident_kind.save\n format.html { redirect_to @incident_kind, notice: 'Incident kind was successfully created.' }\n format.json { render json: @incident_kind, status: :created, location: @incident_kind }\n else\n format.html { render action: \"new\" }\n format.json { render json: @incident_kind.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entrant = Entrant.new(params[:entrant])\n\n respond_to do |format|\n if @entrant.save\n format.html { redirect_to @entrant, notice: 'Entrant was successfully created.' }\n format.json { render json: @entrant, status: :created, location: @entrant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entrant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @insurer = Insurer.new(params[:insurer])\n\n respond_to do |format|\n if @insurer.save\n format.html { redirect_to(@insurer, :notice => 'Insurer was successfully created.') }\n format.xml { render :xml => @insurer, :status => :created, :location => @insurer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @insurer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @inspection = Inspection.new(inspection_params)\n @clients = @inspection.try(:appointment).try(:insp_request).try(:property).try(:clients)\n create_documents\n respond_to do |format|\n if @inspection.save\n format.html { redirect_to @inspection, notice: 'Inspection was successfully created.' }\n format.json { render json: @inspection }\n else\n format.html { render :new }\n format.json { render json: @inspection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_insurance_discount_using_post_with_http_info(insurance_discount, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InsuranceApi.create_insurance_discount_using_post ...'\n end\n # verify the required parameter 'insurance_discount' is set\n if @api_client.config.client_side_validation && insurance_discount.nil?\n fail ArgumentError, \"Missing the required parameter 'insurance_discount' when calling InsuranceApi.create_insurance_discount_using_post\"\n end\n # resource path\n local_var_path = '/insurance_discount'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(insurance_discount)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InsuranceDiscount')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: InsuranceApi#create_insurance_discount_using_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_insurance_coverage_using_post_with_http_info(insurance_coverage, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InsuranceApi.create_insurance_coverage_using_post ...'\n end\n # verify the required parameter 'insurance_coverage' is set\n if @api_client.config.client_side_validation && insurance_coverage.nil?\n fail ArgumentError, \"Missing the required parameter 'insurance_coverage' when calling InsuranceApi.create_insurance_coverage_using_post\"\n end\n # resource path\n local_var_path = '/insurance_coverage'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(insurance_coverage)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InsuranceCoverage')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: InsuranceApi#create_insurance_coverage_using_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @sigurances = Sigurance.all\n end"
] |
[
"0.7151013",
"0.6132172",
"0.59771764",
"0.59539306",
"0.5942133",
"0.59162223",
"0.5895912",
"0.5865056",
"0.579359",
"0.5790205",
"0.57873964",
"0.5753976",
"0.57309014",
"0.5715159",
"0.5672575",
"0.5667512",
"0.5647055",
"0.5643143",
"0.5633308",
"0.5633308",
"0.5629852",
"0.56276417",
"0.5621999",
"0.56194746",
"0.5592684",
"0.55765134",
"0.5564084",
"0.55518234",
"0.5544329",
"0.5519549",
"0.5519358",
"0.5516666",
"0.55147016",
"0.55000746",
"0.54975015",
"0.5497332",
"0.5496336",
"0.5486921",
"0.5463855",
"0.5454011",
"0.5452727",
"0.5442619",
"0.54418355",
"0.5438434",
"0.54193527",
"0.54019487",
"0.5388906",
"0.53873575",
"0.5378718",
"0.53743315",
"0.5372409",
"0.5367669",
"0.5361741",
"0.536076",
"0.5354461",
"0.53535736",
"0.5348843",
"0.53481174",
"0.5344731",
"0.53404385",
"0.53286976",
"0.5327396",
"0.53189194",
"0.5316771",
"0.53118974",
"0.52871114",
"0.528335",
"0.5279921",
"0.52756983",
"0.52732724",
"0.5270873",
"0.5257031",
"0.5254366",
"0.5249432",
"0.52456045",
"0.5245224",
"0.5235235",
"0.5217903",
"0.5215262",
"0.5212639",
"0.52046674",
"0.5202454",
"0.52018654",
"0.5199954",
"0.51977247",
"0.5191196",
"0.51764655",
"0.5175301",
"0.5172265",
"0.51708716",
"0.5168761",
"0.51608497",
"0.5155875",
"0.51553136",
"0.51526135",
"0.51515484",
"0.5143999",
"0.5143726",
"0.5141336",
"0.5139042"
] |
0.62235224
|
1
|
PUT /insurances/1 PUT /insurances/1.json
|
def update
@breadcrumb = 'update'
@insurance = Insurance.find(params[:id])
@insurance.updated_by = current_user.id if !current_user.nil?
respond_to do |format|
if @insurance.update_attributes(params[:insurance])
format.html { redirect_to @insurance,
notice: (crud_notice('updated', @insurance) + "#{undo_link(@insurance)}").html_safe }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @insurance.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @seance = Seances::UseCases::Update.new.call(id: params[:id], params: seance_params)\n\n if @seance.valid?\n render jsonapi: @seance\n else\n render jsonapi_errors: @seance.errors, status: :unprocessable_entity\n end\n end",
"def update\n @insurance = @case.insurance\n\n respond_to do |format|\n if @insurance.update(insurance_params)\n format.html { redirect_to case_insurances_path(@case), notice: 'insurance was successfully updated.' }\n format.json { render :show, status: :ok, location: @insurance }\n else\n format.html { render :edit }\n format.json { render json: @insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @insurance = load_insurance\n\n respond_to do |format|\n if @insurance.update(insurance_params)\n format.html { redirect_to @insurance, success: t('activerecord.messages.successfull.updated', data: @insurance.number) }\n format.json { render :show, status: :ok, location: @insurance }\n else\n format.html { render :edit }\n format.json { render json: @insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @life_insurance.update_attributes(params[:life_insurance])\n format.html { redirect_to @life_insurance, notice: 'Life insurance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @life_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n standard_update(Interest, params[:id], interest_params)\n end",
"def set_health_insurance\n @health_insurance = HealthInsurance.find(params[:id])\n end",
"def set_insurancestatus\n @insurancestatus = Insurancestatus.find(params[:id])\n end",
"def create(params = {})\n wrapped_params = { insurance: params }\n @client.make_request(:post, 'insurances', MODEL_CLASS, wrapped_params)\n end",
"def update\n @insurance_co = InsuranceCo.find(params[:id])\n\n respond_to do |format|\n if @insurance_co.update_attributes(params[:insurance_co])\n format.html { redirect_to(@insurance_co, :notice => 'Insurance co was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @insurance_co.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @issuance.update(issuance_params)\n format.html { redirect_to @issuance, notice: 'Issuance was successfully updated.' }\n format.json { render :show, status: :ok, location: @issuance }\n else\n format.html { render :edit }\n format.json { render json: @issuance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @issuance.update(issuance_params)\n format.html { redirect_to @issuance, notice: 'Issuance was successfully updated.' }\n format.json { render :show, status: :ok, location: @issuance }\n else\n format.html { render :edit }\n format.json { render json: @issuance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @issuance.update(issuance_params)\n format.html { redirect_to @issuance, notice: 'Issuance was successfully updated.' }\n format.json { render :show, status: :ok, location: @issuance }\n else\n format.html { render :edit }\n format.json { render json: @issuance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @insurancestatus.update(insurancestatus_params)\n format.html { redirect_to @insurancestatus, notice: 'Insurancestatus was successfully updated.' }\n format.json { render :show, status: :ok, location: @insurancestatus }\n else\n format.html { render :edit }\n format.json { render json: @insurancestatus.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @life_insurance.update(life_insurance_params)\n format.html { redirect_to @life_insurance, notice: 'Life insurance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @life_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @insurance_type = InsuranceType.find(params[:id])\n\n respond_to do |format|\n if @insurance_type.update_attributes(params[:insurance_type])\n flash[:success] = \"Тип успешно отредактирован.\"\n format.html { redirect_to @insurance_type }\n format.json { head :no_content }\n else\n flash.now[:error] = \"Введены неверные данные!\"\n format.html { render action: \"edit\" }\n format.json { render json: @insurance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @income = current_company.incomes.find(params[:id])\n\n respond_to do |format|\n if @income.update_attributes(params[:income])\n format.html { redirect_to incomes_path, notice: 'Income was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @incident = Incident.find(params[:id])\n\n if @incident.update(incident_params)\n head :no_content\n else\n render json: @incident.errors, status: :unprocessable_entity\n end\n end",
"def update\n\n respond_to do |format|\n if @insurer.update_attributes(params[:insurer])\n format.html { redirect_to @insurer, notice: 'Insurer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @insurer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event_interest = EventInterest.find(params[:id])\n\n respond_to do |format|\n if @event_interest.update_attributes(params[:event_interest])\n format.html { redirect_to @event_interest, notice: 'Event interest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, notice: 'Interest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @inciting_incident.update(inciting_incident_params)\n render json: @inciting_incident\n else\n render json: @inciting_incident.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @unemployment_insurance.update(unemployment_insurance_params)\n format.html { redirect_to @unemployment_insurance, notice: 'Unemployment insurance was successfully updated.' }\n format.json { render :show, status: :ok, location: @unemployment_insurance }\n else\n format.html { render :edit }\n format.json { render json: @unemployment_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, :notice => 'Interest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @incident_kind = IncidentKind.find(params[:id])\n\n respond_to do |format|\n if @incident_kind.update_attributes(params[:incident_kind])\n format.html { redirect_to @incident_kind, notice: 'Incident kind was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incident_kind.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @health_insurance.update(health_insurance_params)\n format.html { redirect_to patient_path(@health_insurance.patient), notice: 'Health insurance was successfully updated.' }\n format.json { render :show, status: :ok, location: @health_insurance }\n else\n format.html { render :edit }\n format.json { render json: @health_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @insurance_coverage.update(insurance_coverage_params)\n format.html { redirect_to @insurance_coverage, notice: 'Insurance coverage was successfully updated.' }\n format.json { render :show, status: :ok, location: @insurance_coverage }\n else\n format.html { render :edit }\n format.json { render json: @insurance_coverage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @income = Income.find(params[:id])\n\n respond_to do |format|\n if @income.update_attributes(income_params)\n format.html { redirect_to @income, notice: 'Income was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @income = Income.find(params[:id])\n\n respond_to do |format|\n if @income.update_attributes(params[:income])\n format.json { head :ok }\n format.js\n else\n format.json { render json: @income.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n respond_to do |format|\n if @income.update(income_params)\n format.html { redirect_to @income, notice: 'Income was successfully updated.' }\n format.json { render :show, status: :ok, location: @income }\n else\n format.html { render :edit }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @endurance = Endurance.find(params[:id])\n\n respond_to do |format|\n if @endurance.update_attributes(params[:endurance])\n format.html { redirect_to @endurance, notice: 'Endurance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @endurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @encounter = Encounter.find(params[:id])\n\n respond_to do |format|\n if @encounter.update_attributes(params[:encounter])\n format.html { redirect_to @encounter, notice: 'Encounter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @encounter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @inspiration = current_user.inspirations.find(params[:id])\n\n respond_to do |format|\n if @inspiration.update_attributes(params[:inspiration])\n format.html { redirect_to @inspiration.discussion, notice: 'Inspiration was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inspiration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_insurance_detail\n @insurance_detail = InsuranceDetail.find(params[:id])\n end",
"def set_life_insurance\n @life_insurance = LifeInsurance.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @sigurance.update(sigurance_params)\n format.html { redirect_to @sigurance, notice: 'Sigurance was successfully updated.' }\n format.json { render :show, status: :ok, location: @sigurance }\n else\n format.html { render :edit }\n format.json { render json: @sigurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @inspiration = Inspiration.find(params[:id])\n \n respond_to do |format|\n if @inspiration.update_attributes(params[:inspiration])\n format.html { redirect_to @inspiration, notice: 'Inspiration was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inspiration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @institucional = Institucional.find(params[:id])\n\n respond_to do |format|\n if @institucional.update_attributes(params[:institucional])\n format.html { redirect_to @institucional, notice: 'Institucional was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institucional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @issuance = Issuance.where(id: params[:id]).first\n @issuance.update_attributes(issuance_params)\n if @issuance.errors.empty?\n redirect_to issuance_path(@issuance)\n else\n render \"edit\"\n end\n end",
"def retrieve(id)\n @client.make_request(:get, \"insurances/#{id}\", MODEL_CLASS)\n end",
"def update\n respond_to do |format|\n if @incident.update(incident_params)\n format.json { head :no_content }\n else\n format.json { render json: @incident.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @interest.update(interest_params)\n format.html { redirect_to @interest, notice: 'Interest was successfully updated.' }\n format.json { render :show, status: :ok, location: @interest }\n else\n format.html { render :edit }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @indivisual.update(indivisual_params)\n format.html { redirect_to @indivisual, notice: 'Indivisual was successfully updated.' }\n format.json { render :show, status: :ok, location: @indivisual }\n else\n format.html { render :edit }\n format.json { render json: @indivisual.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_issuance\n @issuance = Issuance.find(params[:id])\n end",
"def create\n @issuance = Issuance.new(issuance_params)\n respond_to do |format|\n if @issuance\n current_user.issuances << @issuance\n stk_id = params[:issuance][:stock_id]\n qtysb = params[:issuance][:qtysingleb]\n stock = Stock.find(stk_id)\n stock.update(:qtyreceived => qtysb)\n format.html { redirect_to issuances_path, notice: 'Issuance was successfully created.' }\n format.json { render :show, status: :created, location: @issuance }\n else\n format.html { render :new }\n format.json { render json: @issuance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @observance.update(observance_params)\n format.html { redirect_to @observance, notice: 'Observance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @observance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @insurer = Insurer.find(params[:id])\n\n respond_to do |format|\n if @insurer.update_attributes(params[:insurer])\n format.html { redirect_to(@insurer, :notice => 'Insurer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @insurer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @individual_int.update(individual_int_params)\n format.html { redirect_to @individual_int, notice: 'Individual int was successfully updated.' }\n format.json { render :show, status: :ok, location: @individual_int }\n else\n format.html { render :edit }\n format.json { render json: @individual_int.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def update\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n if @incident.update_attributes(params[:incident])\n format.html { redirect_to @incident, notice: 'Incident was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incident.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n if @incident.update_attributes(params[:incident])\n format.html { redirect_to @incident, notice: 'Incident was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incident.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @interests = Interests.for_person(@person)[0]\n\n respond_to do |format|\n if @interests.update_attributes(params[:interests])\n flash[:notice] = 'Interests updated.'\n format.html { redirect_to(person_path(:id => @person)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @interests.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @insurance_card = @life_and_disability\n authorize @insurance_card\n @previous_share_with_ids = @insurance_card.share_with_contact_ids\n PolicyService.fill_life_policies(policy_params, @insurance_card)\n respond_to do |format|\n if validate_params && @insurance_card.update(life_params)\n PolicyService.update_shares(@insurance_card.id, @insurance_card.share_with_ids.map(&:to_i), @previous_share_with_ids, resource_owner)\n PolicyService.update_contacts(@insurance_card, policy_contact_params)\n @path = success_path(life_path(@insurance_card), life_and_disability_shared_view_path(shared_user_id: resource_owner.id, id: @insurance_card.id))\n format.html { redirect_to @path, flash: { success: 'Insurance was successfully updated.' } }\n format.json { render :show, status: :ok, location: @insurance_card }\n else\n error_path(:edit)\n format.html { render controller: @path[:controller], action: @path[:action], layout: @path[:layout] }\n format.json { render json: @insurance_card.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @seance = Seance.find(params[:id])\n\n respond_to do |format|\n if @seance.update_attributes(params[:seance])\n format.html { redirect_to(@seance, :notice => 'Seance was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @seance.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n @recipe.ingrediences = Ingredience.find(params[:ingredience_ids]) if params[:ingredience_ids] \n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n flash[:notice] = 'Recipe was successfully updated.'\n format.html { redirect_to(@recipe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @recipe.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @insurance_card = @property_and_casualty\n authorize @insurance_card\n @previous_share_with_ids = @insurance_card.share_with_contact_ids\n PolicyService.fill_property_and_casualty_policies(policy_params, @insurance_card)\n respond_to do |format|\n if validate_params && @insurance_card.update(property_and_casualty_params)\n PolicyService.update_shares(@insurance_card.id, @insurance_card.share_with_ids.map(&:to_i), @previous_share_with_ids, resource_owner)\n PolicyService.update_properties(@insurance_card, property_params)\n @path = success_path(property_path(@insurance_card), property_and_casualty_shared_view_path(shared_user_id: resource_owner.id, id: @insurance_card.id))\n format.html { redirect_to @path, flash: { success: 'Insurance was successfully updated.' } }\n format.json { render :show, status: :ok, location: @insurance_card }\n else\n error_path(:edit)\n format.html { render controller: @path[:controller], action: @path[:action], layout: @path[:layout] }\n format.json { render json: @insurance_card.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @interest\n respond_to do |format|\n if @interest.update(interest_params)\n format.html { redirect_to @interest, notice: t('flash.notice.updated.') }\n format.json { render :show, status: :ok, location: @interest }\n else\n format.html { render :edit }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ingredience = Ingredience.find(params[:id])\n\n respond_to do |format|\n if @ingredience.update_attributes(params[:ingredience])\n flash[:notice] = 'Ingredience was successfully updated.'\n format.html { redirect_to(@ingredience) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ingredience.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @income_entry = IncomeEntry.find(params[:id])\n\n respond_to do |format|\n if @income_entry.update_attributes(params[:income_entry])\n format.html { redirect_to @income_entry, notice: 'Income entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @income_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @insurance_facility.update(insurance_facility_params)\n format.html { redirect_to @insurance_facility, notice: 'Insurance facility was successfully updated.' }\n format.json { render :show, status: :ok, location: @insurance_facility }\n else\n format.html { render :edit }\n format.json { render json: @insurance_facility.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @interest.update(interest_params)\n format.html { redirect_to animals_url, notice: 'You sent an interest to the animal' }\n format.json { head :no_content }\n else\n format.html { redirect_to animals_url, notice: @interest.errors.full_messages[0] }\n format.json { head :no_content }\n end\n end\n end",
"def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n flash[:notice] = 'Interest was successfully updated.'\n format.html { redirect_to(@interest) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @involvement.update(involvement_params)\n format.html { redirect_to @involvement, notice: 'Involvement was successfully updated.' }\n format.json { render :show, status: :ok, location: @involvement }\n else\n format.html { render :edit }\n format.json { render json: @involvement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employer_liability_insurance.update(employer_liability_insurance_params)\n # format.html { redirect_to @employer_liability_insurance, notice: 'Accident insurance was successfully updated.' }\n format.html { redirect_to insurances_url, notice: 'Insurance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @employer_liability_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_issuance\n @issuance = Issuance.find(params[:id])\n end",
"def set_issuance\n @issuance = Issuance.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @injury.update(injury_params)\n format.html { redirect_to injuries_url, notice: 'Injury was successfully updated.' }\n # format.json { render :show, status: :ok, location: @injury }\n else\n format.html { render :edit }\n format.json { render json: @injury.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @initiative = Initiative.find(params[:id])\n @initiative.phase_id=params[:phase_id]\n\n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n format.html { render :nothing => true }\n #format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bruschettum = Bruschettum.find(params[:id])\n @bruschettum.ingredients.clear\n params[:ingredient].each{|ingr|\n @bruschettum.ingredients << Ingredient.find_by_name(ingr)\n }\n\n respond_to do |format|\n if @bruschettum.update_attributes(params[:bruschettum])\n format.html { redirect_to @bruschettum, notice: 'Bruschettum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bruschettum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @inquiry\n\n if @inquiry.update(inquiry_params)\n head :no_content\n else\n render json: {errors:@inquiry.errors.messages}, status: :unprocessable_entity\n end\n\n end",
"def update\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, :notice => 'Интересот е успешно ажуриран.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @inspection = Inspection.find(params[:id])\n\n respond_to do |format|\n if @inspection.update_attributes(params[:inspection])\n format.html { redirect_to inspections_path, notice: t(\"activerecord.models.inspection\") + t(\"message.updated\") }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inspection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_insint\n @insint = Insint.find(params[:id])\n end",
"def set_insurance_coverage\n @insurance_coverage = InsuranceCoverage.find(params[:id])\n end",
"def update\n @inning = Inning.find(params[:id])\n\n respond_to do |format|\n if @inning.update_attributes(params[:inning])\n format.html { redirect_to @inning, notice: 'Inning was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inning.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @insurance_query = InsuranceQuery.find(params[:id])\n\n respond_to do |format|\n if @insurance_query.update_attributes(params[:insurance_query])\n payer = Payer.find_by_id(@insurance_query.payer_id)\n @insurance_query.update_attributes(payer_name: payer.payer_name, payer_code: payer.payer_code)\n \n format.html { redirect_to @insurance_query, notice: 'Insurance query was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @insurance_query.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe.ingredients.clear\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n\n @recipe.update(recipe_params)\n redirect_to @recipe\n end",
"def update\n respond_to do |format|\n if @incarnation.update(incarnation_params)\n format.html { redirect_to @incarnation, notice: 'Incarnation was successfully updated.' }\n format.json { render :show, status: :ok, location: @incarnation }\n else\n format.html { render :edit }\n format.json { render json: @incarnation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @given_circumstance.update(given_circumstance_params)\n render json: @given_circumstance\n else\n render json: @given_circumstance.errors, status: :unprocessable_entity\n end\n end",
"def create\n @insurancestatus = Insurancestatus.new(insurancestatus_params)\n\n respond_to do |format|\n if @insurancestatus.save\n format.html { redirect_to @insurancestatus, notice: 'Insurancestatus was successfully created.' }\n format.json { render :show, status: :created, location: @insurancestatus }\n else\n format.html { render :new }\n format.json { render json: @insurancestatus.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @insurance_master = InsuranceMaster.find(params[:id])\n\n respond_to do |format|\n if @insurance_master.update_attributes(params[:insurance_master])\n format.html { redirect_to(\"/insurance_masters/new?user_id=#{params[:user_id]}\", :notice => 'InsuranceMaster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @insurance_master.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative_update.update(api_v1_initiative_update_params)\n format.html { redirect_to @api_v1_initiative_update, notice: 'Initiative update was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative_update }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative_update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @intervention.update(intervention_params)\n format.html { redirect_to index_url, notice: \"Intervention was successfully updated.\" }\n format.json { render :show, status: :ok, location: @intervention }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @intervention.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @involvement = Involvement.find(params[:id])\n\n respond_to do |format|\n if @involvement.update_attributes(params[:involvement])\n flash[:notice] = 'Involvement was successfully updated.'\n format.html { redirect_to(@involvement) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @involvement.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @income = current_user.incomes.new(params[:income])\n\n respond_to do |format|\n if @income.save\n format.html { redirect_to incomes_path, notice: 'Income was successfully created.' }\n format.json { render json: @income, status: :created, location: @income }\n else\n format.html { render action: \"new\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @inspiration.update(inspiration_params)\n format.html { redirect_to @book, notice: 'Inspiration was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @inspiration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @eventinterest.update(eventinterest_params)\n format.html { redirect_to @eventinterest, notice: 'Eventinterest was successfully updated.' }\n format.json { render :show, status: :ok, location: @eventinterest }\n else\n format.html { render :edit }\n format.json { render json: @eventinterest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @individual.update(individual_params)\n format.html { redirect_to @individual, notice: 'Individual was successfully updated.' }\n format.json { render :show, status: :ok, location: @individual }\n else\n format.html { render :edit }\n format.json { render json: @individual.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interest = Interest.new(params[:interest])\n \n respond_to do |format|\n if @interest.save\n format.json { render :json => @interest,\n :status => :created, :location => @interest }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @income.update(income_params)\n redirect_to settings_path\n end",
"def update\n @interest = Interest.find(params[:id])\n if @interest.update_attributes(params[:interest])\n redirect_to interests_path\n else\n redirect_to :action => 'edit', :id => @interest.id\n end\n end",
"def update\n @opinion = Opinion.find(params[:id])\n\n respond_to do |format|\n if @opinion.update_attributes(params[:opinion])\n format.html { redirect_to @opinion, notice: 'Opinion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @incomestock = Incomestock.find(params[:id])\n\n respond_to do |format|\n if @incomestock.update_attributes(params[:incomestock])\n format.html { redirect_to @incomestock, notice: 'Incomestock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incomestock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @incidence.update(incidence_params)\n format.html { redirect_to @incidence, notice: 'Incidencia actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: @incidence }\n else\n format.html { render :edit }\n format.json { render json: @incidence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end",
"def update\n respond_to do |format|\n if @influencer.update(influencer_params)\n get_user_social\n format.html { redirect_to root_path, notice: 'Influencer was successfully updated.' }\n format.json { render :root, status: :ok, location: @influencer }\n else\n format.html { render :edit }\n format.json { render json: @influencer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n @therapist_consent = TherapistConsent.find(params[:id])\n respond_to do |format|\n format.html { render action: 'edit' }\n format.json { render :status => 200, :json => { action: 'edit', therapist_consent: @therapist_consent}}\n end\n end"
] |
[
"0.62293655",
"0.6171783",
"0.61701",
"0.610971",
"0.6035267",
"0.6000996",
"0.5981027",
"0.5976915",
"0.5976347",
"0.597185",
"0.5932742",
"0.5932742",
"0.5932742",
"0.5914886",
"0.58653986",
"0.5851972",
"0.58408606",
"0.58258003",
"0.5822766",
"0.5820761",
"0.5815371",
"0.5813203",
"0.5798377",
"0.57895255",
"0.5757341",
"0.57542497",
"0.5746931",
"0.57448804",
"0.57284445",
"0.57011616",
"0.57004726",
"0.56794786",
"0.56729007",
"0.56636244",
"0.5643863",
"0.5641227",
"0.561999",
"0.5611969",
"0.5585214",
"0.55783045",
"0.5576353",
"0.5572829",
"0.55523443",
"0.5539981",
"0.553241",
"0.551807",
"0.5517176",
"0.55145264",
"0.551173",
"0.5508497",
"0.5508446",
"0.5507929",
"0.5497635",
"0.5497635",
"0.5496821",
"0.549596",
"0.5492742",
"0.5480922",
"0.5478009",
"0.5477943",
"0.5476793",
"0.54760647",
"0.54711485",
"0.5465695",
"0.54481447",
"0.54474133",
"0.54350775",
"0.5428907",
"0.5428907",
"0.542678",
"0.54259074",
"0.5423577",
"0.54179806",
"0.54178315",
"0.5417784",
"0.5414456",
"0.54136664",
"0.5410458",
"0.54014134",
"0.5399642",
"0.5396967",
"0.53835243",
"0.5382427",
"0.53804386",
"0.5368748",
"0.53662574",
"0.53567517",
"0.53532356",
"0.53527653",
"0.53523743",
"0.5351689",
"0.5351146",
"0.53504795",
"0.5347332",
"0.5346687",
"0.53454363",
"0.53395116",
"0.5337942",
"0.5334977",
"0.5332262"
] |
0.61889255
|
1
|
DELETE /insurances/1 DELETE /insurances/1.json
|
def destroy
@insurance = Insurance.find(params[:id])
respond_to do |format|
if @insurance.destroy
format.html { redirect_to insurances_url,
notice: (crud_notice('destroyed', @insurance) + "#{undo_link(@insurance)}").html_safe }
format.json { head :no_content }
else
format.html { redirect_to insurances_url, alert: "#{@insurance.errors[:base].to_s}".gsub('["', '').gsub('"]', '') }
format.json { render json: @insurance.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @life_insurance.destroy\n\n respond_to do |format|\n format.html { redirect_to life_insurances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @life_insurance.destroy\n respond_to do |format|\n format.html { redirect_to life_insurances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health_insurance.destroy\n respond_to do |format|\n format.html { redirect_to health_insurances_url, notice: 'Health insurance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @insurancestatus.destroy\n respond_to do |format|\n format.html { redirect_to insurancestatuses_url, notice: 'Insurancestatus was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @insurance_query = InsuranceQuery.find(params[:id])\n @insurance_query.destroy\n\n respond_to do |format|\n format.html { redirect_to insurance_queries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @income = Income.find(params[:id])\n @income.destroy\n\n respond_to do |format|\n format.html { redirect_to incomes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @insurance_co = InsuranceCo.find(params[:id])\n @insurance_co.destroy\n\n respond_to do |format|\n format.html { redirect_to(insurance_cos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @insurance_coverage.destroy\n respond_to do |format|\n format.html { redirect_to insurance_coverages_url, notice: 'Insurance coverage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @institucional = Institucional.find(params[:id])\n @institucional.destroy\n\n respond_to do |format|\n format.html { redirect_to institucionals_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end \n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def destroy\n @incidence.destroy\n respond_to do |format|\n format.html { redirect_to incidences_url, notice: 'Incidencia eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @insurance_type = InsuranceType.find(params[:id])\n @insurance_type.destroy\n\n respond_to do |format|\n flash[:success] = \"Тип успешно удален.\"\n format.html { redirect_to insurance_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @endurance = Endurance.find(params[:id])\n @endurance.destroy\n\n respond_to do |format|\n format.html { redirect_to endurances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @income = current_company.incomes.find(params[:id])\n @income.destroy\n\n respond_to do |format|\n format.html { redirect_to incomes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @income.destroy\n respond_to do |format|\n format.html { redirect_to incomes_url, notice: 'Income was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @income_entry = IncomeEntry.find(params[:id])\n @income_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to income_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inhabitant = Inhabitant.find_by_id(params[:id])\n @inhabitant.destroy\n\n respond_to do |format|\n format.html { redirect_to inhabitants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sigurance.destroy\n respond_to do |format|\n format.html { redirect_to sigurances_url, notice: 'Sigurance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inden_usage.destroy\n respond_to do |format|\n format.html { redirect_to inden_usages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @observance.destroy\n respond_to do |format|\n format.html { redirect_to observances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inspiration.destroy\n respond_to do |format|\n format.html { redirect_to inspirations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.html { redirect_to interests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_interest = EventInterest.find(params[:id])\n @event_interest.destroy\n\n respond_to do |format|\n format.html { redirect_to event_interests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inspiration.destroy\n render json: @inspiration\n end",
"def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.html { redirect_to interests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @ingredience = Ingredience.find(params[:id])\n @ingredience.destroy\n\n respond_to do |format|\n format.html { redirect_to(ingrediences_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @refund_request = RefundRequest.find(params[:id])\n @refund_request.destroy\n\n respond_to do |format|\n format.html { redirect_to refund_requests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @api_v1_initiative.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_initiatives_url, notice: 'Initiative was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @encounter = Encounter.find(params[:id])\n @encounter.destroy\n\n respond_to do |format|\n format.html { redirect_to encounters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @infraction.destroy\n respond_to do |format|\n format.html { redirect_to infractions_url, notice: 'Infraction was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident.destroy\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident.destroy\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @initiative = Initiative.find(params[:id])\n @initiative.destroy\n\n respond_to do |format|\n format.html { redirect_to initiatives_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unemployment_insurance.destroy\n respond_to do |format|\n format.html { redirect_to unemployment_insurances_url, notice: 'Unemployment insurance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stance.destroy\n respond_to do |format|\n format.html { redirect_to stances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stance.destroy\n respond_to do |format|\n format.html { redirect_to stances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @insurance_facility.destroy\n respond_to do |format|\n format.html { redirect_to insurance_facilities_url, notice: 'Insurance facility was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interest.destroy\n\n respond_to do |format|\n format.html { redirect_to interests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @indivisual.destroy\n respond_to do |format|\n format.html { redirect_to indivisuals_url, notice: 'Indivisual was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @occasion = Occasion.find(params[:id])\n @occasion.destroy\n\n respond_to do |format|\n format.html { redirect_to occasions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @refund = Refund.find(params[:id])\n @refund.destroy\n\n respond_to do |format|\n format.html { redirect_to refunds_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @refund = Refund.find(params[:id])\n @refund.destroy\n\n respond_to do |format|\n format.html { redirect_to refunds_url }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n @entry_instrument.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_instruments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @inning = Inning.find(params[:id])\n @inning.destroy\n\n respond_to do |format|\n format.html { redirect_to innings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @income_and_deduction = IncomeAndDeduction.find(params[:id])\n @income_and_deduction.destroy\n\n respond_to do |format|\n format.html { redirect_to(income_and_deductions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asistence = Asistence.find(params[:id])\n @asistence.destroy\n\n respond_to do |format|\n format.html { redirect_to asistences_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @historial = Historial.find(params[:id])\n @historial.destroy\n\n respond_to do |format|\n format.html { redirect_to historials_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @individual_int.destroy\n respond_to do |format|\n format.html { redirect_to individual_ints_url, notice: 'Individual int was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @income = Income.find(params[:id])\n @income_id = @income.id\n @income.destroy\n\n respond_to do |format|\n format.json { head :ok }\n format.js\n end\n end",
"def destroy\n @initiative = Initiative.find(params[:id])\n @initiative.destroy\n\n respond_to do |format|\n format.html { render :nothing => true }\n #format.html { redirect_to initiatives_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @stundent = Stundent.find(params[:id])\n @stundent.destroy\n\n respond_to do |format|\n format.html { redirect_to stundents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interesting = Interesting.find(params[:id])\n @interesting.destroy\n\n respond_to do |format|\n format.html { redirect_to interestings_url }\n format.json { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @interest.destroy\n respond_to do |format|\n format.html { redirect_to interests_url, notice: 'Interest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interest.destroy\n respond_to do |format|\n format.html { redirect_to interests_url, notice: 'Interest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incidentfollowup.destroy\n respond_to do |format|\n format.html { redirect_to incidentfollowups_url, notice: 'Incidentfollowup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inspiration = Inspiration.find(params[:id])\n @inspiration.destroy\n \n respond_to do |format|\n format.html { redirect_to inspirations_url }\n format.json { head :no_content }\n end\n end",
"def remove_interest\n @interest = Interest.where(\"user_id = ? and property_id= ?\",params[:user_id],params[:property_id])\n @interest.first.destroy\n\n respond_to do |format|\n format.html { redirect_to interests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @insurance_master = InsuranceMaster.find(params[:id])\n @insurance_master.destroy\n\n respond_to do |format|\n format.html { redirect_to(insurance_masters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @continent = Continent.find(params[:id])\n @continent.destroy\n\n respond_to do |format|\n format.html { redirect_to continents_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @infection.destroy\n respond_to do |format|\n format.html { redirect_to infections_url, notice: 'Infection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @issuance.destroy\n respond_to do |format|\n format.html { redirect_to issuances_url, notice: 'Issuance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @issuance.destroy\n respond_to do |format|\n format.html { redirect_to issuances_url, notice: 'Issuance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_sanatorium = Ref::Sanatorium.find(params[:id])\n @ref_sanatorium.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_sanatoria_url }\n format.json { head :ok }\n end\n end",
"def destroy\n return if auth(\"website_administrator\")\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @income_type.destroy\n respond_to do |format|\n format.html { redirect_to income_types_url, notice: 'Income type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ingredients_nutrient.destroy\n respond_to do |format|\n format.html { redirect_to ingredients_nutrients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @individual.destroy\n respond_to do |format|\n format.html { redirect_to individuals_url, notice: 'Individual was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ubication = Ubication.find(params[:id])\n @ubication.destroy\n\n respond_to do |format|\n format.html { redirect_to ubications_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @insure_result = InsureResult.find(params[:id])\n @insure_result.destroy\n\n respond_to do |format|\n format.html { redirect_to insure_results_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @studnet = Studnet.find(params[:id])\n @studnet.destroy\n\n respond_to do |format|\n format.html { redirect_to studnets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident_kind = IncidentKind.find(params[:id])\n @incident_kind.destroy\n\n respond_to do |format|\n format.html { redirect_to incident_kinds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incarnation.destroy\n respond_to do |format|\n format.html { redirect_to incarnations_url, notice: 'Incarnation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @one_reg_institution = OneRegInstitution.find(params[:id])\n @one_reg_institution.destroy\n\n respond_to do |format|\n format.html { redirect_to one_reg_institutions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prof_inspection = ProfInspection.find(params[:id])\n @prof_inspection.destroy\n\n respond_to do |format|\n format.html { redirect_to client_prof_inspections_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @exprience = Exprience.find(params[:id])\n @exprience.destroy\n\n respond_to do |format|\n format.html { redirect_to expriences_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inward.destroy\n respond_to do |format|\n format.html { redirect_to inwards_url, notice: 'Inward was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @intervention.destroy\n respond_to do |format|\n format.html { redirect_to index_url, notice: \"Intervention was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.html { redirect_to(interests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @residence = Residence.find(params[:id])\n @residence.destroy\n\n respond_to do |format|\n format.html { redirect_to residences_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @intervention.destroy\n respond_to do |format|\n format.html { redirect_to interventions_url, notice: 'Intervention was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @involvement = Involvement.find(params[:id])\n @involvement.destroy\n\n respond_to do |format|\n format.html { redirect_to(involvements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @intervention.destroy\n respond_to do |format|\n format.html { redirect_to interventions_url, notice: 'Intervention was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @individual\n @individual.destroy\n respond_to do |format|\n format.html { redirect_to individuals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @intervention.destroy\n respond_to do |format|\n format.html { redirect_to interventions_url, notice: \"Intervention was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @insurer.destroy\n\n respond_to do |format|\n format.html { redirect_to insurers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @illness = Illness.find(params[:id])\n @illness.destroy\n\n respond_to do |format|\n format.html { redirect_to illnesses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @income_payment.destroy\n respond_to do |format|\n format.html { redirect_to income_income_payments_url(@income), notice: 'Income payment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stadium.destroy\n respond_to do |format|\n format.html { redirect_to stadia_url, notice: 'Stadium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.71100616",
"0.7077459",
"0.70683455",
"0.6939351",
"0.6922878",
"0.6885303",
"0.68708",
"0.6869441",
"0.6843698",
"0.68238616",
"0.68226284",
"0.6805097",
"0.67878634",
"0.67263293",
"0.67127156",
"0.67000693",
"0.66888183",
"0.6681663",
"0.66482884",
"0.6630567",
"0.66302776",
"0.66215104",
"0.66082937",
"0.6602213",
"0.65963596",
"0.65955997",
"0.6591049",
"0.65882325",
"0.6587037",
"0.6587037",
"0.6579137",
"0.6576315",
"0.65727025",
"0.6570934",
"0.6564911",
"0.6564911",
"0.65634173",
"0.6559912",
"0.65596133",
"0.65596133",
"0.6557181",
"0.65444684",
"0.6543163",
"0.6511163",
"0.6509326",
"0.6503128",
"0.64917064",
"0.6488851",
"0.6487985",
"0.6485364",
"0.6482337",
"0.6482129",
"0.64814967",
"0.6480695",
"0.6477878",
"0.6470632",
"0.6469947",
"0.64678353",
"0.64658767",
"0.64658767",
"0.64655447",
"0.6465449",
"0.64640677",
"0.64580864",
"0.645585",
"0.64526296",
"0.6449339",
"0.64484704",
"0.64484704",
"0.6446112",
"0.6437333",
"0.6435612",
"0.6428251",
"0.64276165",
"0.64263314",
"0.6423547",
"0.64190155",
"0.6411669",
"0.64092445",
"0.6404305",
"0.64011085",
"0.63990456",
"0.6398113",
"0.6388152",
"0.63810873",
"0.6367278",
"0.6366856",
"0.6365874",
"0.6365462",
"0.6362596",
"0.6362413",
"0.6360997",
"0.6360731",
"0.6360687",
"0.63600385",
"0.6359442",
"0.6357456",
"0.6356951",
"0.635617",
"0.635617"
] |
0.6987206
|
3
|
Returns an array all the paintings by an artist
|
def paintings
Painting.all.select{|painting_instance| painting_instance.artist == self}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def artists\n paintings.map do |painting|\n painting.artist\n end\n end",
"def paintings\n Painting.all.select {|p| p.artist == self}\n end",
"def artists\n paintings.collect do |p|\n p.artist \n end\n end",
"def artists\n self.paintings.map do |painting|\n painting.artist\n end.uniq\n end",
"def artists\n paintings.map{|art| art.artist.name}\n\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings()\n Painting.all.select { | painting | painting.artist == self }\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.find_all do |pi|\n pi.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting_instance|\n painting_instance.artist == self\n end\n end",
"def list_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def all_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def all_my_paintings\n Painting.all.select{|picture| picture.artist == self}\n end",
"def all_artists_by_gallery\n paintings = Painting.all.select { |painting| painting.gallery == self }\n # paintings.map { |painting| painting.artist }\n end",
"def all_artists\n match = Painting.all.select{|painting| painting.gallery == self}\n match.map{|painting| painting.artist}\nend",
"def paintings\n Painting.all.select do |p|\n p.artist == self \n end\nend",
"def find_photographs_by_artist(artist)\n artist_photos = []\n @photographs.each do |photograph|\n if photograph[:artist_id] == artist[:id]\n artist_photos << photograph\n end\n end\n artist_photos\n end",
"def all_paintings\n artist_paintings = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n artist_paintings.map do |painting_ob|\n painting_ob.title\n end\nend",
"def artist_names #return array of the names of all artists that have a painting in a gallery\n artists.name #pull array from artists method and call reader to get their name\n end",
"def all_galleries\n gallery_arr = Painting.all.select do |painting_ob|\n painting_ob.artist == self\n end\n gallery_arr.map do |painting_ob|\n painting_ob.gallery.name\n end\nend",
"def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end",
"def artists\n @songs.map { |m| m.artist }.uniq\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n songs.map {|song| song.artist}\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect{|song| song.artist}.uniq\n end",
"def artists\n @songs.collect do |song| #<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">\n song.artist ##<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 ...>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">]>\n end\n end",
"def show\n @paintings = @artist.paintings\n end",
"def artists\n self.songs.map {|song| song.artist}\n end",
"def artists\n songs.collect do |song|\n song.artist\n end\n .uniq #does not return duplicate artists if the genre has more than one song by a particular artist (genre has many artists through songs)\n end",
"def artists\n self.songs.collect{|song| song.artist}\n end",
"def show \n @artist = Artist.find(params[:id])\n @paintings = @artist.paintings\n end",
"def artists\n artists = []\n self.songs.each do |song|\n artists << song.artist\n end\n artists.uniq\n end",
"def artists_with_multiple_photographs\n artists = []\n @artists.each do |artist|\n @photographs.each do |photo|\n if artist[:id] == photo[:artist_id]\n artists << artist\n end\n end\n end\n artists\n end",
"def gal_artist\n beef = paintings.map{|exp| exp.artist.years_active} #accesing artist object in paintings method(mentioned above) and years_active instance_method\n tot = beef.inject{|sum, n| sum + n} #sum of all\n # avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def artists\n genre_artists = []\n Song.all.each {|song|\n if song.genre == self &&\n !genre_artists.include?(song.artist)\n genre_artists << song.artist\n end\n }\n genre_artists\n end",
"def artists\n songs.collect do |song|\n song.artist\n\n end\nend",
"def all_artist_names_by_gallery\n all_artists_by_gallery.map do |artist|\n # artist.name == Painting.artist.name\n artist.name\n end\n end",
"def gallaries\n paintings.map{|paint| paint.gallery}\n\n end",
"def artist()\n sql = \"SELECT * FROM artists WHERE id = $1\"\n values = [@artist_id]\n artists = SqlRunner.run(sql, values)\n result = artists.map {|artist| Artist.new(artist)}\n return result\n end",
"def find_artists\n album_ids = []\n album_results = CONNECTION.execute(\"SELECT * FROM albums_styles WHERE style_id = #{@id};\")\n album_results.each do |hash|\n album_ids << hash[\"album_id\"]\n end\n artist_ids = []\n artist_results = CONNECTION.execute(\"SELECT * FROM albums_artists WHERE album_id IN (#{album_ids.join(\",\")})\")\n artist_results.each do |hash|\n artist_ids << hash[\"artist_id\"]\n end\n \n Artist.find_many(artist_ids)\n end",
"def paintings # Get a list of all the paintings by a specific(keywrod for instance method) artists\n Painting.all.select{|list| list.gallery == self}\n # binding.pry\n end",
"def artists\n songs.map do |song|\n song.artist\n # binding.pry\n end\n end",
"def artist_images\n ArtistImage.find_by_artist_id(self.id)\n end",
"def galleries\n paintings.map {|painting| painting.gallery}\n end",
"def artists\n beef = Artist.all.map{|exp| exp.years_active} #all artist\n beef_tot = beef.inject{|sum, n| sum + n} #sum of all\n avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def photographs_taken_by_artist_from(country)\n artists_match_country = @artists.find_all do |artist|\n artist.country == country\n end\n photos = []\n @photographs.each do |photo|\n artists_match_country.each do |artist|\n if photo.artist_id == artist.id\n photos << photo\n end\n end\n end\n photos\n end",
"def artist_names\n artists.map do |artist|\n artist.name\n end\n end",
"def galleries\n paintings.map{|painting| painting.gallery}.uniq\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def artists\n self.songs.collect {|song| song.artist}\nend",
"def photographs_taken_by_artist_from(country)\n photos_by_country = []\n @photographs.each do |photo|\n @artists.each do |artist|\n if photo[:artist_id] == artist[:id] && artist[:country] == country\n photos_by_country << photo\n end\n end\n end\n photos_by_country\n end",
"def cities\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery.city\n end\n end.compact.uniq\n end",
"def track_artists\n @tracks.collect{ |t| t.artist }.compact.uniq\n end",
"def galleries()\n self.paintings().map { | painting | painting.gallery }.uniq\n end",
"def all_cities\n city_arr = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n city_arr.map do |painting_ob|\n painting_ob.gallery.city\n end\nend",
"def artists\nSong.all.collect{|x| x.artist}\nend",
"def paintings\n Painting.all.select do |painting|\n painting.gallery == self\n end\n end",
"def galleries\n paintings.map {|p| p.gallery}\n end",
"def list_artists\n all_artists = artist_data[\"artists\"][\"items\"]\n all_artists.each do | artist |\n artist_name = artist[\"name\"]\n artists[artist_name] ||= {}\n artists[artist_name][:popularity] = artist[\"popularity\"]\n end\n artists\n end",
"def paintings\n Painting.all.select do |a|\n a.gallery == self\n end\n end",
"def artist_names\n self.artists.map do |artist|\n artist.name\n end\n end",
"def artists\n # - this method will show the connection between songs and artists \n self.songs.collect do |f| \n f.artist\n end\n end",
"def galleries\n galleries_array = paintings.map {|painting| painting.gallery}\n galleries_array.uniq\n end",
"def get_guitarists(artist)\n #get their names out only if they play guitar\n #\n artist.each_with_object([]) do |person, names|\n if person[:instrument].include?('guitar')\n names << person[:name]\n end\n names\n #names always gets returns but if there is no guitar then it will be zippo\n end\n\n private\n\n def privvy\n end\n\n #object is an array as defined. loop over it once and don'thave to compact\nend",
"def bookmarked_artists\n doc = request(@user, \"favoriteartists\")\n artists = []\n doc.xpath('//rss/channel/item').each do |node|\n artists << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :artist => node.xpath('mm:Artist/dc:title').text.strip,\n :station => node.xpath('pandora:stationLink').text.strip }\n end\n artists\n end",
"def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end",
"def artist_names\n self.artists.collect do |n|\n n.name \n end\n end",
"def all_artists\n (track_artists() + artist()).compact.uniq\n end",
"def galleries\n paintings.map do |p|\n p.gallery\n end\n end",
"def songs\n Song.all_by_artist(self)\n end",
"def artworksIn\n\tlistback = []\n\t@art = Artwork.all\n\t@artcreated = ArtworkCreatedBy.all\n\t@art.each do |a|\n\t\t@artcreated.each do |ac|\n\t\t\tif self.artist_id == ac.artist_id\n\t\t\t\tif a.art_id == ac.art_id\n\t\t\t\t\tlistback << a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\tlistback\nend",
"def all_galleries\n self.all_paintings.map do |painting|\n painting.gallery\n end.uniq\n end",
"def albums\n sql = \"SELECT * FROM albums WHERE artist_id = #{@id};\"\n #Select all from albums when the id of the artist we are working on matched the artist_id in albums\n album_list = SqlRunner.run( sql )\n # Save the array to a varibale\n return album_list.map { |album| Album.new(album) }\n # Map the array to a hash.\n end",
"def artists\n @artists ||= artists_raw.map {|a| @session.artist.build(:name => a) }\n end",
"def artists(artist)\n if song.artist = nil || !Artist.find_by_name(name)\n song.artist = artist \n Artist.all << artist \n end \n end",
"def retrieve_artists_by_label\n artistMap = Hash.new(nil)\n Artist.all.each do |rapper|\n if artistMap[rapper.label] == nil\n newArtistArr = []\n newArtistArr << rapper\n artistMap[rapper.label] = newArtistArr\n else\n existingArtistArr = artistMap[rapper.label]\n existingArtistArr << rapper\n end\n end\n artistMap\n end",
"def genres\n songs.map{|song| song.genre} # giving back all the genres under that particular artist. artists can have nmany genres and calling of theirmany genres.\n # Song.all.map{|ind_song| ind_song.genre} #giving back all the different genres from the collection of song array. giving back all the genres of the songs\n # binding.pry\n end",
"def songs \n Song.all.select do |e|\n e.artist == self\n end\n end",
"def all_artist_names\n self.artists.map do |artist|\n artist.name\n end\nend",
"def galleries\n galleries = self.paintings.map do |pi|\n pi.gallery\n end\n galleries.uniq\n end",
"def genres\n @new_array_of_genres = []\n @songs.each do |song| #iterate through each song to find the genre\n if @new_array_of_genres.include?(song.genre) #does not return duplicate genres\n nil\n else\n @new_array_of_genres << song.genre #collects genres through its songs\n end\n end\n @new_array_of_genres #returns a collection of genres for all of the artists songs\n end",
"def photographs_taken_by_artists_from(country)\n country_by_artist = @artists.find_all do |artist|\n artists.first[:country] == country\n end\n @photographs.find_all do |photos|\n photos[:id] == country_by_artist[:id]\n end\n # require 'pry'; binding.pry\n end",
"def list_artist\n Artist.all.each.with_index(1) {|artist, i| puts \"#{i}. #{artist.name}\"}\n end",
"def songs\n Song.all.select {|s| s.artist == self}\n end",
"def artists\n if RESPONSE.code == 200\n # Return data to page\n JSON.parse(RESPONSE.to_s)['topartists']['artist']\n else\n # print error message\n \"Error Code #{RESPONSE.code}\"\n end\n end",
"def list_galleries\n list_paintings.map do |gallery_painting|\n gallery_painting.gallery\n end\n end",
"def songs\n Song.all.select do |song_instance|\n song_instance.artist == self\n end\n end",
"def songs\n Song.all.select {|songs| songs.artist == self}\n end",
"def artists_hash\n parse(get_artists)\n end",
"def genres \n songs.collect{ |s| s.genre }.uniq #returns collection of genres for all of the artist's songs/ does not return duplicate genres/ collects genres\n end"
] |
[
"0.827806",
"0.81666404",
"0.81208044",
"0.8116716",
"0.79862124",
"0.7891409",
"0.7891409",
"0.7891409",
"0.785834",
"0.7849424",
"0.7828021",
"0.7819714",
"0.7819714",
"0.7804246",
"0.7754258",
"0.77372795",
"0.77140296",
"0.7609196",
"0.75375074",
"0.72383255",
"0.71266925",
"0.6963731",
"0.68831825",
"0.6812504",
"0.67434585",
"0.672974",
"0.6687487",
"0.6658012",
"0.6658012",
"0.6633576",
"0.6559928",
"0.6559928",
"0.6555547",
"0.6527581",
"0.65239376",
"0.6512018",
"0.64776343",
"0.6439735",
"0.64213383",
"0.6365474",
"0.633314",
"0.63323987",
"0.6331696",
"0.62847555",
"0.62653834",
"0.6220229",
"0.62033707",
"0.6182255",
"0.61156434",
"0.6081986",
"0.60557914",
"0.60320735",
"0.6018335",
"0.6000516",
"0.60002697",
"0.59922916",
"0.59717023",
"0.59717023",
"0.59717023",
"0.5965205",
"0.5963436",
"0.5944452",
"0.5932512",
"0.59004116",
"0.58989733",
"0.5884957",
"0.5846756",
"0.58386075",
"0.5833418",
"0.5820099",
"0.5793931",
"0.57916754",
"0.578925",
"0.57829773",
"0.57590145",
"0.5750015",
"0.5746477",
"0.5739547",
"0.5732629",
"0.57036585",
"0.57022774",
"0.56795084",
"0.56774056",
"0.5654716",
"0.5649751",
"0.56238514",
"0.56128323",
"0.56006926",
"0.55911404",
"0.5577951",
"0.55700517",
"0.5555213",
"0.55299944",
"0.5518349",
"0.55172217",
"0.5515473",
"0.5513698",
"0.5494586",
"0.54934245",
"0.54841644"
] |
0.78368473
|
10
|
Returns an array of all the galleries that an artist has paintings in
|
def galleries
Painting.all.map do |painting_instance|
if painting_instance.artist == self
painting_instance.gallery
end
end.compact.uniq
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def galleries\n paintings.map {|p| p.gallery}\n end",
"def galleries\n paintings.map {|painting| painting.gallery}\n end",
"def all_artists_by_gallery\n paintings = Painting.all.select { |painting| painting.gallery == self }\n # paintings.map { |painting| painting.artist }\n end",
"def galleries\n paintings.map{|painting| painting.gallery}.uniq\n end",
"def galleries\n galleries = self.paintings.map do |pi|\n pi.gallery\n end\n galleries.uniq\n end",
"def galleries()\n self.paintings().map { | painting | painting.gallery }.uniq\n end",
"def galleries\n galleries_array = paintings.map {|painting| painting.gallery}\n galleries_array.uniq\n end",
"def all_galleries\n self.all_paintings.map do |painting|\n painting.gallery\n end.uniq\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def all_galleries\n gallery_arr = Painting.all.select do |painting_ob|\n painting_ob.artist == self\n end\n gallery_arr.map do |painting_ob|\n painting_ob.gallery.name\n end\nend",
"def galleries\n paintings.map do |p|\n p.gallery\n end\n end",
"def list_galleries\n list_paintings.map do |gallery_painting|\n gallery_painting.gallery\n end\n end",
"def all_galleries_featured_in\n my_galleries = self.all_my_paintings.map{|picture| picture.gallery}.uniq\n end",
"def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end",
"def all_artists\n match = Painting.all.select{|painting| painting.gallery == self}\n match.map{|painting| painting.artist}\nend",
"def gallaries\n paintings.map{|paint| paint.gallery}\n\n end",
"def galleries\n galleries = self.paintings.map do |p|\n p.gallery\n end\n galleries.uniq\nend",
"def paintings\n Painting.all.select do |a|\n a.gallery == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.gallery == self\n end\n end",
"def artists\n self.paintings.map do |painting|\n painting.artist\n end.uniq\n end",
"def artists\n paintings.collect do |p|\n p.artist \n end\n end",
"def paintings\n Painting.all.select {|p| p.artist == self}\n end",
"def all_artist_names_by_gallery\n all_artists_by_gallery.map do |artist|\n # artist.name == Painting.artist.name\n artist.name\n end\n end",
"def artists\n paintings.map do |painting|\n painting.artist\n end\n end",
"def artists\n paintings.map{|art| art.artist.name}\n\n end",
"def artist_names #return array of the names of all artists that have a painting in a gallery\n artists.name #pull array from artists method and call reader to get their name\n end",
"def paintings()\n Painting.all.select { | painting | painting.artist == self }\n end",
"def paintings\n Painting.all.select{|painting_instance| painting_instance.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def all_my_paintings\n Painting.all.select{|picture| picture.artist == self}\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select do |painting_instance|\n painting_instance.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.find_all do |pi|\n pi.artist == self\n end\n end",
"def all_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def list_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def galleries\n galleries = []\n Dir.glob(\"#{@options.cache_dir}/*\").each do |path| \n name = path.split('/').last\n puts name\n gallery = {}\n gallery[:title] = name.gsub(/[_]/, ' ').capitalize\n puts (gallery[:path] = \"gallery/#{name}\")\n thumb = Dir.glob(\"#{path}/*/thumb.*\").first\n thumb = Dir.glob(\"#{path}/*/*.*\").first unless thumb # else take the first image.\n thumb = thumb.split('/').last\n puts (gallery[:thumb] = \"image/m/#{name}/#{thumb}\")\n galleries << gallery\n end\n galleries\n end",
"def artists\n genre_artists = []\n Song.all.each {|song|\n if song.genre == self &&\n !genre_artists.include?(song.artist)\n genre_artists << song.artist\n end\n }\n genre_artists\n end",
"def showGalleries\n @galleries = Gallery.uniq.joins(:arts).where('arts.uploader = ?', current_user.id.to_s)\n end",
"def artists_with_multiple_photographs\n artists = []\n @artists.each do |artist|\n @photographs.each do |photo|\n if artist[:id] == photo[:artist_id]\n artists << artist\n end\n end\n end\n artists\n end",
"def paintings # Get a list of all the paintings by a specific(keywrod for instance method) artists\n Painting.all.select{|list| list.gallery == self}\n # binding.pry\n end",
"def find_photographs_by_artist(artist)\n artist_photos = []\n @photographs.each do |photograph|\n if photograph[:artist_id] == artist[:id]\n artist_photos << photograph\n end\n end\n artist_photos\n end",
"def artists\n songs.collect do |song|\n song.artist\n end\n .uniq #does not return duplicate artists if the genre has more than one song by a particular artist (genre has many artists through songs)\n end",
"def items()\n data['galleries']\n end",
"def artists\n @songs.map { |m| m.artist }.uniq\n end",
"def get_galleries_names_on_page(_browser = @browser)\n Log.logger.info(\"Getting gallery link-names on the page\")\n i = 1\n galleries_list = []\n galleries_xpath = \"//div[contains(@class, 'media-gallery-collection')]/div\"\n nog = Integer(_browser.find_elements(:xpath => galleries_xpath).size)\n Log.logger.info(\"Found #{nog} galleries\")\n while i <= nog\n JQuery.wait_for_events_to_finish(_browser)\n gal_name = _browser.find_element(:xpath => \"//div[contains(@class, 'media-gallery-collection')]/div[#{i}]\").attribute(\"about\")\n gal_name.gsub!(/\\/content\\//,'')\n i += 1\n galleries_list << gal_name\n end\n return galleries_list\n end",
"def artists\n artists = []\n self.songs.each do |song|\n artists << song.artist\n end\n artists.uniq\n end",
"def artists\n @songs.collect{|song| song.artist}.uniq\n end",
"def genres\n @new_array_of_genres = []\n @songs.each do |song| #iterate through each song to find the genre\n if @new_array_of_genres.include?(song.genre) #does not return duplicate genres\n nil\n else\n @new_array_of_genres << song.genre #collects genres through its songs\n end\n end\n @new_array_of_genres #returns a collection of genres for all of the artists songs\n end",
"def artists\n songs.map {|song| song.artist}\n end",
"def list_presenting_artists(gallery)\n gallery.artist_name.each.with_index(1) {|artist, i| puts \"#{i}. #{artist}\"}\n end",
"def show\n @images = @galleries_album.galleries\n end",
"def artists\n self.songs.collect{|song| song.artist}\n end",
"def artists\n self.songs.map {|song| song.artist}\n end",
"def paintings\n Painting.all.select do |p|\n p.artist == self \n end\nend",
"def artist_images\n ArtistImage.find_by_artist_id(self.id)\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song| #<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">\n song.artist ##<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 ...>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">]>\n end\n end",
"def gal_artist\n beef = paintings.map{|exp| exp.artist.years_active} #accesing artist object in paintings method(mentioned above) and years_active instance_method\n tot = beef.inject{|sum, n| sum + n} #sum of all\n # avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def galleries\n @galleries ||= Fotolia::Galleries.new(self)\n end",
"def cities\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery.city\n end\n end.compact.uniq\n end",
"def show\n @arts = Array.new()\n @gallery.art_ids.each do |aid|\n @arts << Art.find(aid)\n end\n\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def genres \n songs.collect{ |s| s.genre }.uniq #returns collection of genres for all of the artist's songs/ does not return duplicate genres/ collects genres\n end",
"def gallery\n @galleries = Gallery.all\n end",
"def artists\n songs.collect do |song|\n song.artist\n\n end\nend",
"def list_gallery\n Galleries.all.each.with_index(1) { |gallery, i| puts \"#{i}. #{gallery.name}\"}\n end",
"def photographs_taken_by_artist_from(country)\n artists_match_country = @artists.find_all do |artist|\n artist.country == country\n end\n photos = []\n @photographs.each do |photo|\n artists_match_country.each do |artist|\n if photo.artist_id == artist.id\n photos << photo\n end\n end\n end\n photos\n end",
"def all_paintings\n artist_paintings = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n artist_paintings.map do |painting_ob|\n painting_ob.title\n end\nend",
"def build_galleries\n galleries = []\n root_dir = AutodropGallery.new('/', @options, @session)\n\n # For each directory in that dir\n root_dir.directory.ls.each do |d|\n # is this dir valid? then add to a list of dirs\n # else, continue, without adding to the list of dirs\n gallery = AutodropGallery.new(d.path, @options, @session) if d.directory?\n gallery.build_gallery\n galleries << gallery if gallery.valid?\n end\n\n # return the list of dirs, even if it is an empty list.\n return galleries\n end",
"def find_artists\n album_ids = []\n album_results = CONNECTION.execute(\"SELECT * FROM albums_styles WHERE style_id = #{@id};\")\n album_results.each do |hash|\n album_ids << hash[\"album_id\"]\n end\n artist_ids = []\n artist_results = CONNECTION.execute(\"SELECT * FROM albums_artists WHERE album_id IN (#{album_ids.join(\",\")})\")\n artist_results.each do |hash|\n artist_ids << hash[\"artist_id\"]\n end\n \n Artist.find_many(artist_ids)\n end",
"def genres\n songs.map{|song| song.genre} # giving back all the genres under that particular artist. artists can have nmany genres and calling of theirmany genres.\n # Song.all.map{|ind_song| ind_song.genre} #giving back all the different genres from the collection of song array. giving back all the genres of the songs\n # binding.pry\n end",
"def artists\n self.songs.collect {|song| song.artist}\nend",
"def artists\n beef = Artist.all.map{|exp| exp.years_active} #all artist\n beef_tot = beef.inject{|sum, n| sum + n} #sum of all\n avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def genres\n self.songs.map do |artist_song|\n artist_song.genre\n end\n end",
"def genres\n all_genres = []\n Song.all.each do |x|\n if x.artist == self\n all_genres << x.genre\n end\n end\nall_genres\nend",
"def genres\n songs.collect do |song|\n song.genre\n end\n .uniq #does not return duplicate genres if the artist has more than one song of a particular genre (artist has many genres through songs)\n end",
"def genres\n songs.map {|song| song.genre }\n end",
"def artists\nSong.all.collect{|x| x.artist}\nend",
"def artworksIn\n\tlistback = []\n\t@art = Artwork.all\n\t@artcreated = ArtworkCreatedBy.all\n\t@art.each do |a|\n\t\t@artcreated.each do |ac|\n\t\t\tif self.artist_id == ac.artist_id\n\t\t\t\tif a.art_id == ac.art_id\n\t\t\t\t\tlistback << a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\tlistback\nend",
"def photographs_taken_by_artist_from(country)\n photos_by_country = []\n @photographs.each do |photo|\n @artists.each do |artist|\n if photo[:artist_id] == artist[:id] && artist[:country] == country\n photos_by_country << photo\n end\n end\n end\n photos_by_country\n end",
"def genres\n\t\t@songs.collect {|g| g.genre}\n\tend",
"def songs\n Song.all_by_artist(self)\n end",
"def genres\n songs.map {|song| song.genre}\n end",
"def albums\n sql = \"SELECT * FROM albums WHERE artist_id = #{@id};\"\n #Select all from albums when the id of the artist we are working on matched the artist_id in albums\n album_list = SqlRunner.run( sql )\n # Save the array to a varibale\n return album_list.map { |album| Album.new(album) }\n # Map the array to a hash.\n end",
"def artists\n # - this method will show the connection between songs and artists \n self.songs.collect do |f| \n f.artist\n end\n end",
"def all_cities\n city_arr = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n city_arr.map do |painting_ob|\n painting_ob.gallery.city\n end\nend",
"def all_artists\n (track_artists() + artist()).compact.uniq\n end",
"def genres\n songs.map{|song|song.genre}.uniq\n end",
"def genres\n songs.collect{|song| song.genre}.uniq\n end",
"def get_figures\n get(FIGURES)\n end",
"def artists\n songs.map do |song|\n song.artist\n # binding.pry\n end\n end"
] |
[
"0.846802",
"0.8272418",
"0.82534474",
"0.82506865",
"0.82282174",
"0.8226531",
"0.8224111",
"0.8136808",
"0.8120395",
"0.8120395",
"0.8120395",
"0.8095459",
"0.8080331",
"0.8023666",
"0.7893244",
"0.75780237",
"0.756971",
"0.7534802",
"0.738552",
"0.7238986",
"0.7216759",
"0.71723557",
"0.7114243",
"0.71059746",
"0.7080736",
"0.70197314",
"0.69677657",
"0.692956",
"0.6925072",
"0.6905144",
"0.68871886",
"0.68871886",
"0.68871886",
"0.6879936",
"0.6861715",
"0.6852349",
"0.68344647",
"0.68344647",
"0.6756245",
"0.6754527",
"0.66866624",
"0.6684078",
"0.664756",
"0.6647496",
"0.65765244",
"0.6565072",
"0.6559995",
"0.65158284",
"0.64946014",
"0.64135766",
"0.639342",
"0.6375167",
"0.63666904",
"0.6330568",
"0.63186395",
"0.63125414",
"0.62905324",
"0.62405324",
"0.6225069",
"0.62189484",
"0.62135565",
"0.61986136",
"0.6181942",
"0.6181942",
"0.61494863",
"0.61196625",
"0.6114574",
"0.6106675",
"0.61009717",
"0.60916525",
"0.60916525",
"0.6060744",
"0.6049106",
"0.60389835",
"0.6023681",
"0.5999334",
"0.5940719",
"0.59356695",
"0.592746",
"0.58915174",
"0.5841626",
"0.58282554",
"0.58177525",
"0.58141226",
"0.57920355",
"0.57893556",
"0.57887423",
"0.578193",
"0.57590497",
"0.5756408",
"0.5748843",
"0.5744828",
"0.5737687",
"0.5737223",
"0.5729674",
"0.5726567",
"0.5724093",
"0.5711736",
"0.56906956",
"0.5688054"
] |
0.86001194
|
0
|
Return an array of all cities that an artist has paintings in
|
def cities
Painting.all.map do |painting_instance|
if painting_instance.artist == self
painting_instance.gallery.city
end
end.compact.uniq
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all_cities\n city_arr = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n city_arr.map do |painting_ob|\n painting_ob.gallery.city\n end\nend",
"def cities\n galleries.map {|g| g.city}\n end",
"def cities \n galleries.map{|g| g.city}.uniq\n end",
"def cities\n galleries.map do |c|\n c.city\n end\n end",
"def cities\n gallaries.map{|place| place.city}\n\n end",
"def cities\n galleries.map{|gallery| gallery.city}.uniq\n end",
"def cities()\n self.galleries().map { | gallery | gallery.city }.uniq\n end",
"def getAllCities\r\n result = []\r\n @vertex.each_value do |city|\r\n result << city.name\r\n end\r\n return result\r\n end",
"def cities\n galleries.map {|gallery| gallery.city}\n end",
"def cities\n galleries.map {|gallery| gallery.city}\n end",
"def all_cities\n self.all_galleries.map do |gallery|\n gallery.city\n end.uniq\n end",
"def cities\n self.galleries.map do |gi|\n gi.city\n end\n end",
"def cities\n galleries.map do |gallery|\n gallery.city\n end\n end",
"def cities\n galleries.map do |gallery|\n gallery.city\n end\n end",
"def cities\n self.galleries.map{|painitng| painitng.city}\n end",
"def artists\n self.paintings.map do |painting|\n painting.artist\n end.uniq\n end",
"def cities\n Gallery.all.map{|list| list.city}\n end",
"def cities\n galleries.map do |gallery| \n gallery.city \n end\n end",
"def artists\n paintings.map do |painting|\n painting.artist\n end\n end",
"def find_all_visited_cities()\n all_cities = cities()\n visited_cities = []\n for city in all_cities\n if city.visited == 1\n visited_cities.push(city)\n end\n end\n return visited_cities\nend",
"def artists\n paintings.collect do |p|\n p.artist \n end\n end",
"def all_cities\n self.all.map do |gallery|\n gallery.city.uniq\n end\n end",
"def all_featured_cities\n cities_featured = self.all_galleries_featured_in.map{|gallery| gallery.city}\n end",
"def list_cities\n list_galleries.map do |gallery|\n gallery.city\n end\n end",
"def artists\n paintings.map{|art| art.artist.name}\n\n end",
"def cities\n galleries.map do |gallery|\n gallery.city\n end\n #undefined method `city' for \"New York\":String\n end",
"def cities\n self.galleries.map do |g|\n g.city\n end\nend",
"def cities()\n sql = \"SELECT cities.* FROM cities WHERE country_id = $1;\"\n values = [@id]\n city_list = SqlRunner.run(sql, values)\n return city_list.map{|city| City.new(city)}\n end",
"def cities()\n sql=\"SELECT * FROM cities WHERE country_id = $1\"\n values = [@id]\n cities = SqlRunner.run(sql, values)\n return cities.map{|city| City.new(city)}\n end",
"def all_organisations_in_city(city)\n sparql = \"\n SELECT DISTINCT ?uri ?label\n WHERE \n {\n VALUES ?city { \\\"#{city}\\\" }\n GRAPH <http://data.artsapi.com/graph/organisations> {\n ?uri <http://data.artsapi.com/def/arts/locationCity> ?city .\n ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label .\n }\n }\n \"\n\n results = User.current_user.within { Tripod::SparqlClient::Query.select(sparql) }\n\n results.map { |r| [r[\"uri\"][\"value\"], r[\"label\"][\"value\"]] }\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def cities\n CS.get :us, :ca\n end",
"def cities()\n sql = \"SELECT cities.* FROM cities WHERE country_id = $1\"\n values = [@id]\n cities = SqlRunner.run(sql, values)\n result = City.map_items(cities)\n return result\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings()\n Painting.all.select { | painting | painting.artist == self }\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select {|p| p.artist == self}\n end",
"def paintings\n Painting.all.select{|painting_instance| painting_instance.artist == self}\n end",
"def maps\n @cities = Art.joins(:galleries).where(\"galleries.show = true and arts.city <> '' \").pluck(\"city\").uniq!\n\n if params[:city].to_s != \"\"\n @city= params[:city].to_s== \"oa\" ? \"\" : params[:city].to_s\n search = \"galleries.show = true and arts.city = '\"+@city+\"'\"\n @galleries = Gallery.joins(:arts).where(search.to_s).distinct\n return\n end\n @galleries = Gallery.where(show: true).order('id DESC')\n end",
"def all_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting_instance|\n painting_instance.artist == self\n end\n end",
"def cities\n Enumerator.new do |iter|\n CITIES.each_key { |ro_key| iter << RegionalOffice.new(ro_key) }\n end\n end",
"def stay_city\n # cities = Country.all.map{|country|country.cities}\n # cities.map{|city|city.name}\n end",
"def get_list_cities\n City.get_all_cities\n end",
"def city_list\n self.cities.collect do |city|\n city.name\n end.join(\", \")\n end",
"def find_city_list\n sql = \"SELECT * FROM cities WHERE country_id = $1\"\n values = [@id]\n cities = SqlRunner.run(sql, values)\n return cities.map {|city| City.new(city)}\n end",
"def all_species\n return species if species.present?\n Species.joins(:geo_entities).where(geo_entities: { id: countries.map(&:id) })\n end",
"def cities()\n \n url = \"http://servicos.cptec.inpe.br/XML/listaCidades\"\n \n cities = Array.new\n \n request ||= requestXml(url)\n \n request.xpath('//cidades/cidade').each do |cidadePath|\n \n cidade = Hash.new\n \n cidade[:id] = cidadePath.at_xpath('id').text.strip\n cidade[:uf] = cidadePath.at_xpath('uf').text.strip\n cidade[:nome] = cidadePath.at_xpath('nome').text.strip\n \n cities << cidade\n \n end\n \n cities\n \n end",
"def artists\n @songs.collect{|song| song.artist}.uniq\n end",
"def city_names\n cities.pluck(:name).join(\", \")\n end",
"def cities_helper\n [\n ['基隆市', '基隆市'],\n ['台北市', '台北市'],\n ['新北市', '新北市'],\n ['桃園縣', '桃園縣'],\n ['新竹市', '新竹市'],\n ['新竹縣', '新竹縣'],\n ['苗栗縣', '苗栗縣'],\n ['台中市', '台中市'],\n ['彰化縣', '彰化縣'],\n ['南投縣', '南投縣'],\n ['雲林縣', '雲林縣'],\n ['嘉義市', '嘉義市'],\n ['嘉義縣', '嘉義縣'],\n ['台南市', '台南市'],\n ['高雄市', '高雄市'],\n ['屏東縣', '屏東縣'],\n ['台東縣', '台東縣'],\n ['花蓮縣', '花蓮縣'],\n ['宜蘭縣', '宜蘭縣'],\n ['澎湖縣', '澎湖縣'],\n ['金門縣', '金門縣'],\n ['連江縣', '連江縣']\n ]\n end",
"def artists\n @songs.map { |m| m.artist }.uniq\n end",
"def all_artists\n match = Painting.all.select{|painting| painting.gallery == self}\n match.map{|painting| painting.artist}\nend",
"def compile_artists(location)\n Artist.where(\"state = ? and city = ?\", \"#{location.state}\", \"#{location.city}\" )\n end",
"def list_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def all_unique_city_values\n sparql = \"\n SELECT DISTINCT ?city\n WHERE \n {\n GRAPH <http://data.artsapi.com/graph/organisations> {\n ?org <http://data.artsapi.com/def/arts/locationCity> ?city .\n }\n }\"\n\n results = User.current_user.within { Tripod::SparqlClient::Query.select(sparql) }\n\n results.map { |r| r[\"city\"][\"value\"] }\n end",
"def list_of_continents\n\n hash_continents = {}\n @query.get_graph.each_key do |city|\n continent = get_city_info(city, \"continent\")\n if not hash_continents.has_key?(continent)\n hash_continents[continent] = []\n end\n hash_continents[continent] << get_city_info(city,\"name\")\n end\n\n return hash_continents\n\n end",
"def favorite_place_coords\n res = []\n stories.includes(:places => [{:place_categories => :parent}, :location]).each do |s|\n s.places.each do |p|\n next unless p.name.present?\n base_cat = p.get_parent_categories.first ? p.get_parent_categories.first.name : 'other'\n res << {name: p.name, base_category: base_cat, place_url: '/places/' + p.id.to_s, lat: p.location.lat, lng: p.location.lng}\n # binding.pry\n end\n end\n res\n end",
"def all_paintings\n artist_paintings = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n artist_paintings.map do |painting_ob|\n painting_ob.title\n end\nend",
"def artists\n songs.map {|song| song.artist}\n end",
"def all_artists_by_gallery\n paintings = Painting.all.select { |painting| painting.gallery == self }\n # paintings.map { |painting| painting.artist }\n end",
"def paintings\n Painting.all.find_all do |pi|\n pi.artist == self\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def get_favorite_locations_array\n favorite_locations = StartLocation.all.select do |start_location|\n start_location.favorite == true\n end.map {|favorite_location| favorite_location.name }\n\n EndLocation.all.select do |end_location|\n favorite_locations << end_location.name if end_location.favorite == true\n end\n favorite_locations.uniq\nend",
"def all_artists\n (track_artists() + artist()).compact.uniq\n end",
"def districts\n self.projects.collect do |proj|\n proj.locations\n end.flatten.uniq\n end",
"def find_all_non_visited_cities\n all_cities = cities()\n non_visited = []\n for city in all_cities\n if city.visited == 0\n non_visited.push(city)\n end\n end\n return non_visited\n end",
"def get_countries\n countries=[]\n @locations.each do |loc|\n countries << loc.country.capitalize if loc.country\n end\n countries.uniq\n end",
"def paintings\n Painting.all.select do |p|\n p.artist == self \n end\nend",
"def colonies\n # 1. for one specific Planet, find all the Colonies that belong to that planet\n Colony.all.select do |colony_instance|\n # look for the colonies that belong to this alien species\n colony_instance.planet == self\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def all_my_paintings\n Painting.all.select{|picture| picture.artist == self}\n end",
"def artists\n songs.collect do |song|\n song.artist\n end\n .uniq #does not return duplicate artists if the genre has more than one song by a particular artist (genre has many artists through songs)\n end",
"def photographs_taken_by_artist_from(country)\n photos_by_country = []\n @photographs.each do |photo|\n @artists.each do |artist|\n if photo[:artist_id] == artist[:id] && artist[:country] == country\n photos_by_country << photo\n end\n end\n end\n photos_by_country\n end",
"def artists\n songs.collect do |song|\n song.artist\n\n end\nend",
"def artists\n artists = []\n self.songs.each do |song|\n artists << song.artist\n end\n artists.uniq\n end",
"def artists\n self.songs.map {|song| song.artist}\n end",
"def artists\n self.songs.collect{|song| song.artist}\n end",
"def planets\n # go through my colonies\n self.colonies.map do |my_colony|\n # get the information about each planet the colony is on\n my_colony.planet\n end\n end",
"def employeeLocationsByCity()\n locations = Hash.new\n \n employeesList = (RawData.new(\"employee_details\").getMnoData())['content']['employees']\n \n employeesList.each do | employee |\n # extract the city/country information from the 'address' field\n address = employee['address']\n location = employee['address'].gsub(/\\ \\d+/, \"\")\n location = location.split(/\\s*[,;]\\s*/x).from(-2).join(', ')\n \n # Add to locations records\n occurrence = locations.fetch(location, nil)\n \n if !occurrence\n locations[location] = Array.new\n end \n \n locations[location].push(address)\n \n #puts locations\n end\n\n return locations\n end",
"def photographs_taken_by_artist_from(country)\n artists_match_country = @artists.find_all do |artist|\n artist.country == country\n end\n photos = []\n @photographs.each do |photo|\n artists_match_country.each do |artist|\n if photo.artist_id == artist.id\n photos << photo\n end\n end\n end\n photos\n end",
"def print_city_list\n\n # simply call the print_vertices function of the graph API\n @query.get_graph.each_key { |city| puts \"#{get_city_info(city,\"name\")}\"}\n\n end",
"def artists\n genre_artists = []\n Song.all.each {|song|\n if song.genre == self &&\n !genre_artists.include?(song.artist)\n genre_artists << song.artist\n end\n }\n genre_artists\n end",
"def colonies\n # look at the single src of truth for the colonies\n Colony.all.select do |colony_instance|\n # pick the ones that belong to me\n colony_instance.alien_species == self\n end\n end",
"def unit_citizens\n world.units.active.find_all { |u| \n unit_iscitizen(u)\n }\n end",
"def city_loop\n\t#loop through cities\n\t@cities.each do |t|\n\t\tputs \"#{t} is a town in Scotland\"\n\tend\n\nend",
"def employees\n employee_array = []\n locations.each do |location|\n location.employees.each do |employee|\n employee_array << employee\n end\n end\n employee_array\n end",
"def cities\n @topCities = City.includes(:country).where(\"cities.top='t'\").order(\"cities.name\")\n @topCountries = Country.where(\"name='United States'\").order(\"top desc\")\n end",
"def just_visited()\n all_visited_cities = Country.visited_cities\n all_visited_cities.each {|city| City.new(city) }\n end",
"def artists\nSong.all.collect{|x| x.artist}\nend",
"def track_artists\n @tracks.collect{ |t| t.artist }.compact.uniq\n end",
"def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end",
"def city\n fetch('world_cup.cities')\n end",
"def locations\n unless defined?(@locations)\n @locations=[]\n for loc in Location.order(\"id ASC\").includes(:bottom_right_coordinate, :top_left_coordinate)\n @locations << loc if do_overlap_with?(loc.area)\n end \n end \n @locations\n end"
] |
[
"0.7432719",
"0.7427216",
"0.71981937",
"0.71691334",
"0.7162481",
"0.71181685",
"0.7106441",
"0.70468307",
"0.7043161",
"0.7043161",
"0.68992716",
"0.68612635",
"0.68456364",
"0.68456364",
"0.6780894",
"0.6775067",
"0.67725056",
"0.6625553",
"0.6616456",
"0.6600691",
"0.6587096",
"0.656657",
"0.65162224",
"0.6485557",
"0.64684016",
"0.64526147",
"0.64351845",
"0.6315727",
"0.62539643",
"0.6237726",
"0.6157628",
"0.6157628",
"0.6157628",
"0.6149879",
"0.61474127",
"0.61453766",
"0.6144224",
"0.6124357",
"0.6106649",
"0.6106649",
"0.6072383",
"0.60711735",
"0.6057459",
"0.60425115",
"0.6014194",
"0.60102624",
"0.60008293",
"0.59818053",
"0.5974654",
"0.596305",
"0.596116",
"0.5958888",
"0.5908063",
"0.5904549",
"0.59041816",
"0.58805054",
"0.58783966",
"0.58764064",
"0.58672124",
"0.5857067",
"0.58328587",
"0.58104897",
"0.5809335",
"0.5798994",
"0.5783959",
"0.57780117",
"0.57688195",
"0.57688195",
"0.5761196",
"0.5747939",
"0.5727495",
"0.5716284",
"0.5687128",
"0.56725967",
"0.5671919",
"0.56656444",
"0.56656444",
"0.56581056",
"0.5646745",
"0.5624539",
"0.5622647",
"0.56134075",
"0.5589304",
"0.557387",
"0.5569014",
"0.55623394",
"0.55616754",
"0.5535399",
"0.55324244",
"0.55075186",
"0.5492228",
"0.5488861",
"0.54703194",
"0.5462707",
"0.54604703",
"0.54535306",
"0.5429995",
"0.54051274",
"0.5393488",
"0.53932273"
] |
0.8210998
|
0
|
Given the arguments of title, price and gallery, creates a new painting belonging to that artist
|
def create_painting(title, price, gallery)
Painting.new(title, price, gallery, self)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_painting(title, price, gallery) #(title, price, artist, gallery)\n Painting.new(title, price, self, gallery)\n end",
"def create_painting(title, price, gallery)\n Painting.new(title, price, self, gallery)\n end",
"def create_painting(title, price, gallery)\n Painting.new(title, price, self, gallery)\n end",
"def create_painting(title, price, gallery)\n Painting.new(title, price, self, gallery)\n end",
"def create_painting(title, price, gallery)\n Painting.new(self, title, price, gallery)\n end",
"def create_painting(title, price, gallery)\n Painting.new(self, title, price, gallery)\n end",
"def create_painting(title, price, gallery) #works\n Painting.new(title, price, self, gallery)\n end",
"def create_painting\n Painting.new(title, price, self, gallery)\n end",
"def create\n @painting = @gallery.paintings.create(painting_params)\n @painting.gallery_id = @gallery.id \n \n if @painting.save\n \n flash[:notice] = \"Successfully created painting.\"\n redirect_to gallery_path(@gallery)\n \n \n else\n render :action => 'new'\n end\n \n end",
"def create\n #unsere art_ids sind leider nicht uniq, darum kümmern wir uns hier\n mod_params = gallery_params\n unless gallery_params[\"art_ids\"].is_a? String\n mod_params[\"art_ids\"] = gallery_params[\"art_ids\"].uniq!\n end\n\n if gallery_params[\"thumbUrl\"].to_s == \"\"\n #Wenn kein Thumb gewählt worden ist, nehmen wir einfach das erste Bild\n if mod_params[\"thumbArt\"].to_s.chars.length == 0\n mod_params[\"thumbArt\"] = Art.find(mod_params[\"art_ids\"].first.to_i).id\n end\n end\n #galleryeintrag erzeugen\n @gallery = Gallery.new(mod_params)\n @gallery.user = current_user.id.to_s\n if @gallery.save\n redirect_to galleries_url, notice: 'Gallery was successfully created.'\n else\n render :new\n end\n end",
"def create\n @artist = Artist.find_or_create_by(artist_name: artist_params[:artist_name])\n @artist.update(artist_params)\n gon.artist = @artist\n end",
"def addNewProduceToStore(store_name_string, produce_name_string, color_string, category_string, quantity_integer)\n k = self.newProduce(produce_name_string, color_string, category_string)\n ProduceToStore(store_name_string, k, quantity_integer)\n end",
"def initialize(painting_url, museum)\n @painting_url = \"http://www.the-athenaeum.org/art/#{painting_url}\"\n build_profile\n @painting = Painting.new(:name => @name,\n :museum => museum,\n :image => @image,\n :artist => @artist,\n :athenaeum_id => athenaeum_id\n )\n if @painting.save\n puts \"added painting #{painting.name}\"\n else\n @painting.errors.each {|error, reason| puts \"#{error} #{reason}\"}\n end\n delete_image\n end",
"def create\n @gallery = Gallery.new(gallery_params)\n @gallery.thumbUrl = @gallery.arts.first.image.thumb('400x200').url\n respond_to do |format|\n if @gallery.save\n format.html { redirect_to @gallery, notice: 'Gallery was successfully created.' }\n format.json { render :show, status: :created, location: @gallery }\n else\n format.html { render :new }\n format.json { render json: @gallery.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(painter, title, style, year, gallery)\n @painter = painter\n @style = style\n @title = title\n @year = year\n @gallery = gallery\n\n @@all << self\n end",
"def create\n @artpiece = Artpiece.new(params[:artpiece])\n @artist = Artist.find(params[:artpiece][:artist_id])\n @artist.artpieces << @artpiece\n\n if @artpiece.save\n @image_name = \"#{sprintf(\"%03d\", @artpiece.id)}.jpg\"\n @directory = \"public/images/artcat/pieces\"\n # create the file path\n @path = File.join(@directory, @image_name)\n # write the file\n File.open(@path, \"wb\") { |f| f.write(params[:picture].read) }\n redirect_to(@artist, :notice => 'Artpiece was successfully created.')\n end\n end",
"def create\n new_album = Album.new\n new_album.title = params[:title]\n new_album.artist = params[:artist]\n new_album.year = params[:year]\n new_album.album_art = params[:album_art]\n new_album.save\n end",
"def painting_params\n params.require(:painting).permit(:name, :gallery_id, :photo, :photo_remote_url )\n end",
"def new_song name, genre\n Song.new name, self, genre\n end",
"def new_song(name, genre)\n # who is the artist it belongs to?\n # since I'm in an instance method, it should be the instance that called it\n # this should be yourself, and to get access to yourself, you use self\n Song.new(name, self, genre) # the artist == self\n end",
"def add(title, artist)\n payload = [{\n action: 'update',\n item: {\n item_id: \"#{title} - #{artist}\",\n song_id: get_song_id(title, artist),\n play_count: 1\n # favorite: true\n }\n }]\n\n ECHONEST.post '/catalog/update', id: id, data: payload.to_json\n end",
"def create\n @gallery_piece = GalleryPiece.new(gallery_piece_params)\n\n respond_to do |format|\n if @gallery_piece.save\n format.html { redirect_to @gallery_piece, notice: 'Gallery piece was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gallery_piece }\n else\n format.html { render action: 'new' }\n format.json { render json: @gallery_piece.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\nend",
"def new_product(image_url)\n \tProduct.new(title: \"My Book Title\",\n \t\t\t\tdescription: \"yyy\",\n \t\t\t\tprice: 1,\n \t\t\t\timage_url: image_url)\n end",
"def new_product(image_url)\n Product.new(\n :title => 'My book title',\n :description => 'yyy',\n :price => 1,\n :image_url => image_url\n )\n end",
"def create_product(store:, name:, id_from_provider:, category:, url:)\n product = Product.find_by store: store, name: name\n\n return product if product\n\n Product.create store: store, name: name, id_from_provider: id_from_provider, category: category, url: url\nend",
"def painting_params\n params.require(:painting).permit(:name, :artist, :museum, :image)\n end",
"def create\n parms = ski_params\n parms[:color] = parms[:color].split(', ') if parms[:color]\n @ski = Ski.new(parms)\n @ski.manufacturer_id ||= Manufacturer.where(name: 'не указан', category: 'ski').first_or_create.id\n respond_to do |format|\n if @ski.save\n if params[:images]\n @ski.gallery ||= Gallery.new\n params[:images].each do |image|\n @ski.gallery.images.create(image: image)\n end\n unless @ski.image_file_size\n @ski.update(image: @ski.gallery.images.first.image)\n end\n end\n format.html { redirect_to @ski, notice: 'Ski was successfully created.' }\n format.json { render :show, status: :created, location: @ski }\n else\n format.html { render :new }\n format.json { render json: @ski.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_product(image_url)\n Product.new(title: \"My Book Title\", description: \"yyy\", price: 1, image_url: image_url)\n end",
"def create \n artist = Artist.create(artist_params)\n redirect_to artist #rails knows to go to the show page you need to just reference the correct object\n end",
"def new_product_with_title(title)\n Product.new(:title => title,\n :description => products(:ruby).description,\n :price => products(:ruby).price,\n :image_url => products(:ruby).image_url)\n end",
"def create\n @gallery = Gallery.find(params[\"gallery_id\"])\n @collection = @gallery.collections.build(collection_params)\n @collection.thumbnail = 9999\n\n respond_to do |format|\n if @collection.save\n format.html { redirect_to @collection, notice: 'Collection was successfully created.' }\n format.json { render :show, status: :created, location: @collection }\n else\n format.html { render :new }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def make_painting(title, style)\n Painting.new(title, style, self, nil)\n end",
"def new_product(url)\n\t\tProduct.new(\n\t\t\t:title => 'alala',\n\t\t\t:description => 'dddd',\n\t\t\t:price=> 1,\n\t\t\t:image_url => url,\n :cover_image_type => 'image/png',\n :cover_image => 'myfake_png_data'\n)\n\tend",
"def create\n @new_artwork = NewArtwork.new(new_artwork_params)\n\n respond_to do |format|\n if @new_artwork.save\n format.html { redirect_to @new_artwork, notice: 'New artwork was successfully created.' }\n format.json { render :show, status: :created, location: @new_artwork }\n else\n format.html { render :new }\n format.json { render json: @new_artwork.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_song_by_name(name) #takes in argument name of (song)\n song = Song.new(name) #creating a new instance of a song\n song.artist = self #Right here all we're doing is associating the objects its that simple\n end",
"def new_product(image_url)\n Product.new(title: \"Book Title\", description: \"My Description\", price: 100, image_url: image_url\n )\n end",
"def create\n ## S3\n\n uploaded_io = params[:gallery][:thumbnail]\n filename = sanitize_filename(uploaded_io.original_filename)\n filepath = \"galleries/pic\" + Time.now.to_i.to_s + filename\n AWS::S3::S3Object.store(filepath, uploaded_io.read, @@BUCKET, :access => :public_read)\n url = AWS::S3::S3Object.url_for(filepath, @@BUCKET, :authenticated => false)\n \n params[:gallery][:thumbnail] = url\n @gallery = Gallery.new(params[:gallery])\n\n respond_to do |format|\n if @gallery.save\n format.html { redirect_to @gallery, :notice => 'Gallery was successfully created.' }\n format.json { render :json => @gallery, :status => :created, :location => @gallery }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @gallery.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n \n @album = Album.new(params[:album])\n #params[:artist] if statement\n params[\"artistnames\"].each do |each|\n if each.empty? == false\n @artistexists = Artist.find_by_name(each)\n if @artistexists.nil? == true\n @album.artists.build(:name => each)\n else\n @album.artists << Artist.find_by_name(each)\n end\n end\n end\n params[\"sourcenames\"].each do |each|\n if each.empty? == false\n @artistexists = Source.find_by_name(each)\n if @artistexists.nil? == true\n @album.sources.build(:name => each)\n else\n @album.sources << Source.find_by_name(each)\n end\n end\n end\n \n if params[:album][:catalognumber].blank? == true \n url = params[:album][:reference]\n if url.split('/')[2] == \"vgmdb.net\"\n doc = Nokogiri::HTML(open(url))\n @catalognum = doc.xpath(\"//table[@id='album_infobit_large']//tr[1]//td[2]\").text\n @album.catalognumber = @catalognum.split(' ')[0]\n end\n end\n \n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, :notice => 'Album was successfully created.' }\n format.json { render :json => @album, :status => :created, :location => @album }\n if params[:title] == \"new\"\n format.js { js_redirect_to(album_path(@album))}\n else\n format.js {} \n end\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @album.errors, :status => :unprocessable_entity }\n format.js {}\n end\n end\n end",
"def create_picture\n\t@artwork = Artwork.find(params[:id])\n\t# @picture = @artwork.pictures.create(image: image)\n\tif params[:images]\n\t\tparams[:images].each { |image| \n\t\t\t@artwork.pictures.create(image: image)\n\t\t}\n\tend\n\t@artwork.save\n\t@pictures = @artwork.pictures\n\t# render :action => :show\n\tredirect_to @artwork\nend",
"def new_song(name, genre)\n #creates new song\n Song.new(name, self, genre)\n end",
"def new_book(image_url)\n Book.new(\n title: \"My book title\",\n author: \"Ipsum\",\n description: \"Lorum\",\n price: 1,\n image_url: image_url)\n end",
"def new_song(name, genre)\n song = Song.new(name, self, genre)\n @songs << song\n song\n end",
"def make_painting(title, width, height)\n # **QUIZ** What is self in this line?\n Painting.new(title, width, height, self)\n end",
"def add_song_by_name(song_name)\n # Create a new song called \"song\" with argument passed in.\n song = Song.new(song_name)\n # Associate it with the artist\n song.artist = self\n end",
"def create\n artist = Artist.new(name:\"MyArtist\", )\n artist.build_instrument(name: \"guitar\")\n artist.save\n end",
"def create_new_product(default_img_loc:'/assets/another_title.jpg', \n default_title: 'Another Title')\n # Removed:(input='/assets/another_title.jpg')\n product = Product.new(title: default_title,\n year: 2000,\n materials: 'pen on paper',\n width: 6.00,\n height: 9.00,\n price: 1.50, # Initial price - overwritten in individual tests\n img_sml_loc: default_img_loc)\n #'/assets/another_title.jpg')\n end",
"def add_listing(db, seller, make_id, model, year, price)\n db.execute(\"INSERT INTO cars (seller, make_id, model, year, price) VALUES (?, ?, ?, ?, ?)\", [seller, make_id, model, year, price])\nend",
"def add_artwork artwork\n ArtworksCatalogs.where(artwork_id: artwork.id, catalog_id: self.id)\n .first_or_create(artwork_id: artwork.id, catalog_id: self.id)\n end",
"def create\n @photogallery = Photogallery.new(photogallery_params)\n\n respond_to do |format|\n if @photogallery.save\n format.html { redirect_to @photogallery, notice: 'Photogallery was successfully created.' }\n format.json { render :show, status: :created, location: @photogallery }\n else\n format.html { render :new }\n format.json { render json: @photogallery.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_song_by_name(name)\nartist = Song.new(name)\nadd_song(artist)\nend",
"def create\n @egallery = Egallery.new(params[:egallery])\n\n respond_to do |format|\n if @egallery.save\n format.html { redirect_to([:admin, @egallery], :notice => 'Egallery was successfully created.') }\n format.xml { render :xml => @egallery, :status => :created, :location => @egallery }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @egallery.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\n end",
"def create\n\n return unless parent.preview.exists?\n\n self.thumbs.each_pair do |name, thumb|\n thumb.create\n end\n end",
"def create\n\n artist_id = artist_exist_or_new(params[:artist_name])\n\n album_id = album_exist_or_new(params[:album_name], params[:genre], artist_id)\n\n @song = Song.new(song_params)\n @song.album_id = album_id\n\n respond_to do |format|\n if @song.save\n format.html { render '/shared/created'}\n format.json { render action: 'show', status: :created, location: @song }\n else\n format.html { render action: 'new' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create # instantiate artist instance with its name and bio attributes mass assigned from strong params hash\n @artist = Artist.new(artist_params) # argument is strong params hash, returned by calling #artist_params private method\n @artist.save # save artist instance to DB by inserting its row representation into artists table\n redirect_to artist_url(@artist) # redirect to show page that displays the artist just created\n end",
"def create_specific_event(user:, title:, venue:, category:, number:, datetime:)\n event = Event.new(\n title: title,\n description: \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\",\n datetime: datetime,\n venue: venue,\n capacity: 5,\n category: category,\n )\n url = \"app/assets/images/dine_#{number}.jpg\"\n file = File.open(url)\n event.photo.attach(io: file, filename: \"#{event.title}.png\", content_type: 'image/png')\n event.end_time = event.datetime + rand(1..3).hours\n event.user = user\n event.save\nend",
"def create_dish(name, price)\n\t\tmenu << {name: name, price: price}\n\tend",
"def add_song(song)\n self.songs << song\n new_song = Song.new(song)\n new_song.artist = self\n end",
"def drake_made_this\n drake = Artist.find_or_create_by(name: \"Drake\")\n self.artist = drake\n end",
"def create\n @artwork = Artwork.new(artwork_params)\n\n respond_to do |format|\n if @artwork.save\n format.html { redirect_to @artwork, notice: 'Konstverket uppdaterat.' }\n format.json { render action: 'show', status: :created, location: @artwork }\n else\n format.html { render action: 'new' }\n format.json { render json: @artwork.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n songs = get_kexp_songs()\n idx = 0\n\n while idx < songs['results'].length\n if songs['results'][idx]['playtype']['name'] != \"Media play\"\n idx += 1\n next\n end\n song_title = songs['results'][idx]['track']['name']\n song_artist = songs['results'][idx]['artist']['name']\n \n if !songs['results'][idx]['release']\n song_album = \"\"\n song_release_year = 0\n song_album_img = \"https://cdn.pixabay.com/photo/2019/04/04/18/50/cassette-4103530_1280.jpg\"\n else\n if song_album_img = songs['results'][idx]['release']['largeimageuri'] == nil\n song_album_img = \"https://cdn.pixabay.com/photo/2019/04/04/18/50/cassette-4103530_1280.jpg\"\n else\n song_album_img = songs['results'][idx]['release']['largeimageuri']\n end\n song_album = songs['results'][idx]['release']['name']\n song_release_year = songs['results'][idx]['releaseevent']['year'].to_i\n end\n \n song_is_local = songs['results'][idx]['artist']['islocal']\n #if song|artist|album don't exist -> create \n if Album.find_by(title: song_album) == nil\n song_artist = song_artist.split('feat.')[0]\n mod_artist = song_artist.strip().gsub(/[^0-9a-z ]/i, '').split(' ').join('+')\n parsed_response = get_song_genre(mod_artist)\n \n #if bad status code -> query by song instead\n if parsed_response[\"status_code\"] > 299 || parsed_response[\"status_code\"] < 200 || parsed_response[\"genre\"] == \"\"\n mod_song = song_title.strip().gsub(/[^0-9a-z ]/i, '').split(' ').join('+')\n parsed_response = get_song_genre(mod_song)\n end\n @album = Album.new(title: song_album, album_img: song_album_img, year: song_release_year, genre: parsed_response[\"genre\"])\n @album.save()\n else \n @album = Album.find_by(title: song_album)\n end\n\n if Artist.find_by(name: song_artist) == nil\n @artist = Artist.new(name: song_artist, is_local?: song_is_local, album: @album)\n @artist.save()\n else \n @artist = Artist.find_by(name: song_artist)\n @artist.update(album: @album)\n end\n if Song.find_by(title: song_title) == nil\n @song = Song.new(title: song_title, artist: @artist)\n @song.save()\n else \n @song = Song.find_by(title: song_title)\n @song.update(artist: @artist)\n end\n idx += 1\n end\n redirect_to songs_path\n end",
"def create_dessert(db, dessert_name, dessert_description)\n db.execute(\"INSERT INTO dessert (dessert_name, dessert_description) VALUES (?, ?)\", [dessert_name, dessert_description])\nend",
"def create\n artist = Artist.new({\n name: params[:artist][:name],\n first_name: params[:artist][:first_name],\n age: params[:artist][:age],\n alive: params[:artist][:alive]\n })\n\n artist.save\n redirect_to '/artists'\n end",
"def new_song(name, artist)\n Song.new(name, artist, self)\n end",
"def new_song(name, artist)\n Song.new(name, artist, self)\n end",
"def new_song(name, artist)\n Song.new(name, artist, self)\n end",
"def create\n \n params, setlist_songs, media = prepare_params()\n \n optimize_images(params)\n \n @gig = Gig.new(params)\n \n if @gig.save\n\n if setlist_songs.present?\n @gig.gigsets.create(setlist_songs)\n end\n\n if media.present?\n @gig.gigmedia.create(media)\n end\n \n redirect_to(@gig)\n \n else\n # This line overrides the default rendering behavior, which\n # would have been to render the \"create\" view.\n render \"new\"\n end\n\n end",
"def create\n @gallery = Gallery.new(gallery_params)\n\n \n if @gallery.save\n redirect_to action: 'index'\n else\n redirect_to action: 'new'\n end\n \n end",
"def setup_catalog\n [\n {product_name: 'bamba', photo_url: 'dummy_url1', barcode: 'xxx1', sku: 111, price: 2.23, producer: 'Nestle'},\n {product_name: 'apple', photo_url: 'dummy_url2', barcode: 'xxx2', sku: 555, price: 4.66, producer: 'WFM'},\n {product_name: 'tapu chepse', photo_url: 'dummy_url3', barcode: 'xxx3', sku: 1111444, price: 7.33, producer: 'Nestle'}\n ].each do |data|\n Catalog.create(data)\n end\n end",
"def create_new_exercise(exercise, muscle_group)\n Exercise.create(name: exercise, muscle_group: muscle_group)\n puts \"Thank you for sharing!\"\n end",
"def new_product(image_url)\n Product.new(title: 'Nokia',\n description: 'Connecting people.',\n price: 1,\n image_url: image_url)\n end",
"def create\n @artwork = Artwork.unpublished.new(new_artwork_params)\n @artwork.artist = Artist.find_or_initialize_by name: artist_params[:artist_name]\n\n #add transaction if needed\n respond_to do |format|\n if @artwork.save\n format.html { redirect_to @artwork, notice: 'Artwork was successfully created.' }\n format.json { render :show, status: :created, location: @artwork }\n else\n format.html { render :new }\n format.json { render json: @artwork.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gallery = Gallery.new(gallery_params)\n\n respond_to do |format|\n if @gallery.save\n format.html { redirect_to @gallery, notice: 'Gallery was successfully created.' }\n format.json { render :show, status: :created, location: @gallery }\n else\n format.html { render :new }\n format.json { render json: @gallery.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gallery = Gallery.new(gallery_params)\n\n respond_to do |format|\n if @gallery.save\n format.html { redirect_to @gallery, notice: 'Gallery was successfully created.' }\n format.json { render :show, status: :created, location: @gallery }\n else\n format.html { render :new }\n format.json { render json: @gallery.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gallery = Gallery.new(gallery_params)\n\n respond_to do |format|\n if @gallery.save\n format.html { redirect_to @gallery, notice: 'Gallery was successfully created.' }\n format.json { render json: @gallery, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @gallery.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_song_by_name(title)\n new_song = Song.new(title)\n #tell the song it belongs to a specific artist\n add_song(new_song) #invoking previously written method\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\n end",
"def add_ingredient_to_recipe quantity, measure, food_item_name, recipe \n food_item = FoodItem.new(:name => food_item_name, :price => nil)\n ingredient = Ingredient.new(:food_item => food_item, :quantity => quantity, :measure => measure, :recipe_id => recipe.id)\n recipe.ingredients << ingredient\n end",
"def new_artist_or_nah(request_artist)\n artist = Artist.find_by name: request_artist\n if artist == nil\n Artist.create(name: request_artist)\n else\n artist\n end \n end",
"def create\n @gallery = Gallery.new(gallery_params)\n \n respond_to do |format|\n if @gallery.save\n format.html { redirect_to galleries_path, notice: 'Gallery was successfully created.' }\n format.json { render json: @gallery, status: :created, location: @gallery }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gallery.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @title = 'Gallery'\n @gallery = current_user.galleries.build(params[:gallery])\n if @gallery.save\n redirect_to @gallery\n else\n render :action => 'new'\n end\n end",
"def create\n @gallery = Gallery.new(params[:gallery])\n\n respond_to do |format|\n if @gallery.save\n flash[:notice] = 'Gallery was successfully created.'\n format.html { redirect_to(@gallery) }\n format.xml { render :xml => @gallery, :status => :created, :location => @gallery }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gallery.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @gallery = Gallery.new(params[:gallery])\n\n respond_to do |format|\n if @gallery.save\n flash[:notice] = 'Gallery was successfully created.'\n format.html { redirect_to(@gallery) }\n format.xml { render :xml => @gallery, :status => :created, :location => @gallery }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gallery.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @gallery = Gallery.new(params[:gallery])\n\n respond_to do |format|\n if @gallery.save\n flash[:notice] = 'Gallery was successfully created.'\n format.html { redirect_to(@gallery) }\n format.xml { render :xml => @gallery, :status => :created, :location => @gallery }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gallery.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sportgood = Sportgood.new(sportgood_params)\n @sportgood.manufacturer_id ||= Manufacturer.where(name: 'не указан', category: 'sportgood').first_or_create.id\n respond_to do |format|\n if @sportgood.save\n if params[:images]\n @sportgood.gallery ||= Gallery.new\n params[:images].each do |image|\n @sportgood.gallery.images.create(image: image)\n end\n unless @sportgood.image_file_size\n @sportgood.update(image: @sportgood.gallery.images.first.image)\n end\n end\n format.html { redirect_to @sportgood, notice: 'Sportgood was successfully created.' }\n format.json { render :show, status: :created, location: @sportgood }\n else\n format.html { render :new }\n format.json { render json: @sportgood.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_artist_object_to_album_object!(album_object, artist_object)\n album_object.artist_id = artist.id\n end",
"def new_song(name, genre)\n song = Song.new(name,self, genre)\n \n end",
"def create\n @gallery_item = GalleryItem.new(params[:gallery_item])\n\n respond_to do |format|\n if @gallery_item.save\n format.html { redirect_to(@gallery_item, :notice => 'Gallery item was successfully created.') }\n format.xml { render :xml => @gallery_item, :status => :created, :location => @gallery_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gallery_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n \n Book.create(\n title: params[:book][:title],\n author: params[:book][:author],\n description: params[:book][:description],\n image_url: params[:book][:image_url]\n )\n\n redirect_to books_path\n end",
"def create\n @artist = Artist.new(artist_params)\n\t@artist.total_donation = 0\n\tif @artist.photo.empty? || @artist.photo.nil?\n\t\t@artist.photo = \"no_image.png\"\n\tend\n\t\n respond_to do |format|\n if @artist.save\n format.html { redirect_to @artist, notice: 'Artist was successfully created.' }\n format.json { render :show, status: :created, location: @artist }\n else\n format.html { render :new }\n format.json { render json: @artist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n redirect_to new_album_path, alert: \"You have to select at least one artist.\" and return if params[:album][:album_artists].size == 1 && params[:album][:album_artists][0].empty? # TODO: Find a better way to do this, it does not play nicely with json and xml\n @album = Album.new(album_params)\n album_artists\n album_cover if params[:search_online]\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n format.xml { render xml: @album, status: :created }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n format.xml { render xml: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.find_by email: current_user.email\n\n price_quote = PriceQuote.create(description: params[:description], photographer_id: params[:photographer_id], client_id: @client.id, status: :aberto)\n if price_quote\n flash[:notice] = 'Orçamento enviado'\n redirect_to :back\n end\n end",
"def create_drink(category, table_name, name, price, max_price, min_price, current_price, price_difference, bio)\n @bar.drinks.create(name: name, price: price, max_price: max_price, min_price: min_price, current_price: current_price, price_difference: price_difference, bio: bio, category: category,\n table_name: table_name)\n end",
"def skapa_produkt(params, userid)\n val = validate_create(params)\n if val == false\n return {\n error: true,\n message: \"something empty\"\n }\n end\n titel = params[\"titel\"]\n description = params[\"description\"]\n price = params[\"price\"]\n image = params[\"img\"]\n type = image[\"type\"].split(\"/\")[-1]\n new_name = SecureRandom.uuid + \".\" + type\n db = connect()\n\n FileUtils.cp(image[\"tempfile\"].path, 'public/uploads/' + new_name)\n\n db.execute(\"INSERT INTO Product (titel,description,price,userid,img) VALUES (?,?,?,?,?)\",titel,description,price,userid,new_name)\n end",
"def create\n @category = Category.find(params[:category_id])\n @gallery = @category.galleries.build(params[:gallery])\n @licenses = License.all\n\n respond_to do |format|\n if @gallery.save\n flash[:notice] = 'Gallery was successfully created.'\n format.html { redirect_to [:admin, @gallery] }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n # Hack? How to do this better...\n params[:song][:genre] = Genre.find(params[:song][:genre_id])\n params[:song].delete(:genre_id)\n params[:song][:artist] = @artist\n @song = Song.new(params[:song])\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to [@artist, @song], notice: 'Song was successfully created.' }\n format.json { render json: @song, status: :created, location: @song }\n else\n format.html { render action: \"new\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.8097651",
"0.77111065",
"0.77111065",
"0.77111065",
"0.76426256",
"0.7638961",
"0.74456036",
"0.67176205",
"0.64623165",
"0.61592746",
"0.58460253",
"0.5822008",
"0.58090883",
"0.5790757",
"0.55937755",
"0.55582625",
"0.5497374",
"0.5484345",
"0.5483693",
"0.54761773",
"0.5474997",
"0.54748183",
"0.54293877",
"0.54185236",
"0.5418463",
"0.5415988",
"0.5415834",
"0.5409893",
"0.5386572",
"0.5372155",
"0.5362938",
"0.53594154",
"0.5351771",
"0.532552",
"0.5313676",
"0.53070116",
"0.5290113",
"0.5285087",
"0.5283592",
"0.5281796",
"0.52744895",
"0.52225167",
"0.5217418",
"0.5194642",
"0.5188832",
"0.51869655",
"0.5182306",
"0.5181662",
"0.5179241",
"0.51705563",
"0.51540715",
"0.51533204",
"0.5148958",
"0.5148958",
"0.51431245",
"0.5141745",
"0.5134866",
"0.5127108",
"0.51237875",
"0.51208425",
"0.51190287",
"0.51168305",
"0.5116262",
"0.51145154",
"0.51140106",
"0.5110831",
"0.5110831",
"0.5110831",
"0.51036584",
"0.5094331",
"0.5091413",
"0.5081686",
"0.50761276",
"0.5071472",
"0.50706494",
"0.50706494",
"0.50612116",
"0.50603545",
"0.5059812",
"0.50587994",
"0.5046215",
"0.504276",
"0.50368524",
"0.5030122",
"0.5030122",
"0.5030122",
"0.50297433",
"0.50292313",
"0.5026876",
"0.5026182",
"0.5025297",
"0.5019965",
"0.5017983",
"0.5014637",
"0.5008021",
"0.50046605",
"0.50023824",
"0.5000662"
] |
0.76302224
|
6
|
The cycle helpers need to store the cycles in a place
|
def get_cycle(name)
@_cycles = Hash.new unless defined?(@_cycles)
return @_cycles[name]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def next_cycle\n pre_cycle\n user_cycle\n after_cycle\n end",
"def cycles\n @cycles ||= 5\n end",
"def create_cycle\r\n return if @head == nil # don't do anything if the linked list is empty\r\n\r\n # navigate to last node\r\n cursor = @head\r\n while cursor.next != nil\r\n cursor = cursor.next\r\n end\r\n\r\n cursor.next = @head # make the last node link to first node\r\n end",
"def create_cycle\r\n return if @head == nil # don't do anything if the linked list is empty\r\n\r\n # navigate to last node\r\n current = @head\r\n while current.next != nil\r\n current = current.next\r\n end\r\n\r\n current.next = @head # make the last node link to first node\r\n # now it's 1 giant loop!\r\n end",
"def get_cycle(name); end",
"def create_cycle\r\n return if @head == nil # don't do anything if the linked list is empty\r\n \r\n # navigate to last node\r\n current = @head\r\n while current.next != nil\r\n current = current.next\r\n end\r\n \r\n current.next = @head # make the last node link to first node\r\n end",
"def create_cycle\r\n return if @head == nil # don't do anything if the linked list is empty\r\n\r\n # navigate to last node\r\n current = @head\r\n while current.next != nil\r\n current = current.next\r\n end\r\n\r\n current.next = @head # make the last node link to first node\r\n end",
"def create_cycle\n return if @head == nil # don't do anything if the linked list is empty\n\n # navigate to last node\n current = @head\n while current.next != nil\n current = current.next\n end\n\n current.next = @head # make the last node link to first node\n end",
"def create_cycle\n return if @head == nil # don't do anything if the linked list is empty\n\n # navigate to last node\n current = @head\n while current.next != nil\n current = current.next\n end\n\n current.next = @head # make the last node link to first node\n end",
"def cycle object\n execute object, @cycle unless @cycle.nil?\n end",
"def cycle(node)\n if(!@cycleProc.nil?)\n\t@cycleProc.call([node]) ;\n else\n\tdefaultCycle(node) ;\n end\n end",
"def after_cycle; end",
"def detect_cycles\n cycles = Array.new\n\n self.courses.each do |course|\n courses = Hash.new\n stack = Array.new\n add_course(course, course, courses, cycles, stack) unless courses.has_key?(course.id)\n end\n\n return cycles\n end",
"def get_cycle(name)\n @_cycles = Hash.new unless defined?(@_cycles)\n @_cycles[name]\n end",
"def after_cycle\n end",
"def test_0610_cycle\n @@log.debug \"test_0610_cycle starts\" if @@log.debug?\n assert_respond_to(@list, :cycle, \"test_0610_cycle_respond\")\n # Type check\n enum = @list.cycle\n result = enum.is_a? Enumerator\n assert(result,\"test_0610_cycle_class\") \n # One cycle\n assert_equal([@aen, @bsb, @cab, @dad], @list.cycle(1).to_a, \"test_0610_cycle_once\")\n # Two cycles\n assert_equal([@aen, @bsb, @cab, @dad, @aen, @bsb, @cab, @dad], \n @list.cycle(2).to_a, \"test_0610_cycle_twice\") \n @@log.debug \"test_0610_cycle ends\" if @@log.debug?\n end",
"def all_cycles\n cycles = []\n start = adj_lists.first.name\n visited = [start] # stack\n previous = {}\n adj_lists.each {|v| previous[v.name] = nil}\n # each cycle may not be bigger than biggest SCC (strongly connected component)\n if max_cycle_length > 1\n answer = all_cycles_dfs(visited, previous, cycles)\n else\n return \"NO CYCLES EXIST\"\n end\n print \"Cycles: #{answer}\\n\\n\"\n answer\n end",
"def cycle?\n #...\n end",
"def current_cycle(name = T.unsafe(nil)); end",
"def find_cycle\n first = @people_prefs.index{|i| i.size > 1}\n cycle_crawl(first)\n end",
"def cycle\n TflApi::Client::Cycle.new(self)\n end",
"def eulerian_cycle(graph)\n <<-DOC\n EULERIANCYCLE(Graph)\n form a cycle Cycle by randomly walking in Graph (don't visit the same edge twice!)\n while there are unexplored edges in Graph\n select a node newStart in Cycle with still unexplored edges\n form Cycle’ by traversing Cycle (starting at newStart) and then randomly walking \n Cycle ← Cycle’\n return Cycle\n\n http://www.ms.uky.edu/~lee/ma515fa10/euler.pdf\n\n This is an algorithm to find an Eulerian circuit in a connected graph in which every vertex has even degree.\n 1. Choose any vertex v and push it onto a stack. Initially all edges are unmarked.\n 2. While the stack is nonempty, look at the top vertex, u, on the stack. \n If u has an unmarked incident edge, say, to a vertex w, then push w onto the stack \n and mark the edge uw. On the other hand, if u has no unmarked incident edge, then pop u off the stack and print it.\n \n When the stack is empty, you will have printed a sequence of vertices that correspond to an Eulerian circuit.\n\n DOC\n\n node = graph.keys[0]\n stack = [node]\n cycle = []\n while (not stack.empty?)\n node = stack[-1]\n if graph.has_key?(node)\n new_node = graph[node][0]\n # puts \"New node:\" + new_node\n stack << new_node\n if graph[node].length > 1\n graph[node].delete(new_node)\n else\n graph.delete(node)\n end\n else\n cycle.unshift(stack.pop)\n # puts stack.join(\" \")\n end\n end\n\n # return cycle.join(\"->\")\n return cycle\n\n end",
"def stripe_cycle\n cycle('odd', 'even')\n end",
"def expanded_cycles(cycles)\n cycles.collect {|cycle|\n all_rotations(cycle).map {|cycle| cycle +[cycle.first]}\n }.flatten(1)\n end",
"def has_cycle\r\n raise NotImplementedError\r\n end",
"def has_cycle\n raise NotImplementedError, \"Please implement has_cycle\"\n end",
"def cycle_detector(&block)\n return self.class.new(self, :cycle_detector) unless block_given?\n seen = ::Array.new\n self.each do |vertex, edge, depth|\n found = seen.index(vertex)\n raise \"Cycle detected at #{vertex} along #{edge} at depth #{found} and #{depth}\" if found && (found < depth)\n seen[depth] = vertex\n yield vertex, edge, depth\n end\n end",
"def each\n cycles_found = []\n\n @graph.keys.each do |start_node|\n @ticker.tick\n next if cycles_found.include?(start_node)\n\n find_cycles(start_node).each do |cycle|\n unless cycles_found.include?(cycle.node)\n cycles_found << cycle.node\n yield cycle.node\n end\n end\n end\n end",
"def create_next\n old_cycles = Maintenance::Cycle::CYCLE_TYPES.map { |type| Maintenance::Cycle.current(type) }.select{ |cycle| cycle && cycle.is_over? }\n cycles = []\n for old_cycle in old_cycles\n cycles << Maintenance::Cycle.generate_next_cycle( old_cycle.cycle_type )\n end\n flash[:sticky_messages] = []\n render json: cycles.map{|cycle| {cycle_number: cycle.ordinality_number, cycle_type: cycle.cycle_type_desc, year: cycle.year } }.to_json\n end",
"def set_cycle(cycle)\n @cycle=cycle\n if !@se.nil?\n @se.set_cycle(cycle)\n end\n end",
"def detect_cycle_in_graph(edges)\nend",
"def cycle\n (@isodd = !@isodd) ? 'even' : 'odd'\n end",
"def set_cycle\n @cycle = Cycle.find(params[:id])\n end",
"def set_cycle\n @cycle = Cycle.find(params[:id])\n end",
"def testCycleReordering\n executeSimpleTest(\n [ [ 'T1', 'R2', 500, 2, ['T2'], '=='],\n [ 'T2', 'R1', 1100, 2, [], ' =='],\n [ 'T3', 'R1', 100, 5, ['T2'], '====='],\n [ 'T4', 'R4', 200, 1, ['T5'], '='],\n [ 'T5', 'R2', 600, 2, [], ' =='],\n [ 'T6', 'R2', 800, 4, ['T7'], ' ===='],\n [ 'T7', 'R3', 1000, 2, [], ' =='] ] )\n end",
"def pin_cycle(args)\n # set default repeats and timeset\n repeat_count = 1\n tset = 0\n if args =~ /,/\n parsedargs = args.split(',')\n args = parsedargs.pop\n parsedargs.each do |arg|\n if arg =~ /repeat/\n repeat_count = arg.sub(/repeat/, '').to_i\n elsif arg =~ /tset/\n tset = arg.sub(/tset/, '').to_i\n end\n end\n end\n\n message = ''\n # load pattern cycle data into pin objects\n @pinmap.each_value { |p| p.load_pattern_data(args) }\n cycle_failure = false\n\n 0.upto(repeat_count - 1) do |count|\n # process timing events\n @cycletiming[tset]['events'].each do |event|\n # process drive events\n if @cycletiming[tset]['drive_event_pins'].key?(event)\n @cycletiming[tset]['drive_event_pins'][event].each_index do |i|\n @cycletiming[tset]['drive_event_pins'][event][i].each do |p|\n p.process_event(:drive, @cycletiming[tset]['drive_event_data'][event][i])\n end\n end\n end\n\n # process compare events\n if @cycletiming[tset]['compare_event_pins'].key?(event)\n @cycletiming[tset]['compare_event_pins'][event].each_index do |i|\n @cycletiming[tset]['compare_event_pins'][event][i].each do |p|\n p.process_event(:compare, @cycletiming[tset]['compare_event_data'][event][i])\n end\n end\n end\n end # event\n\n # build response message\n message += ' ' unless count == 0\n\n @patternorder.each do |p|\n message += @pinmap[p].response\n cycle_failure = true if @pinmap[p].cycle_failure\n end\n end # count\n if cycle_failure\n rtnmsg = 'F:' + message + ' Expected:' + args\n else\n rtnmsg = 'P:' + message\n end\n rtnmsg\n end",
"def cycle\n LazyList.new do\n next self if empty?\n Cons.new(head, tail.append(cycle))\n end\n end",
"def test_cycles\n all(QTest::TestCycle, project: @project.id, test_cycle: @id)\n end",
"def run_dependency_breaking_cycle\n progressed = false\n\n @jstream.each do |rec|\n uri = rec['uri']\n\n next if @logical_urls[uri]\n\n missing_dependencies = @dependencies[uri].reject {|d| @logical_urls[d]}\n\n rec.keys.each do |k|\n if !extract_logical_urls(rec[k], missing_dependencies).empty?\n @limbs_for_reattaching[uri] ||= []\n @limbs_for_reattaching[uri] << [k, rec[k]]\n rec.delete(k)\n end\n end\n\n # Create the cut down record (which might fail)\n created_uri = do_create(rewrite(rec, @logical_urls), true)\n\n if created_uri\n # It worked!\n @logical_urls[uri] = created_uri\n\n progressed = true\n break\n end\n end\n\n raise \"Can't progress any further. Freaking out!\" if !progressed\n end",
"def cycle name=nil, options={}, &block\n _state = nil\n if name.is_a?(Hash) && options.empty?\n options = name\n name = nil\n end\n if _state = options.delete(:state)\n valid_unless_nested(\"when :state is supplied\")\n else\n _state = state_or_event\n valid_in_context( State, \"unless :state is supplied\" )\n end\n\n name ||= options.delete :on\n name ||= \"cycle_#{_state.to_sym}\"\n evt = define_event( name, options, &block )\n evt.from _state\n evt.to _state\n evt\n end",
"def cycle!\n Logger.info \"Cycling Started...\"\n\n packages = yaml_load.unshift(package)\n cycled_packages = []\n\n if keep.is_a?(Date) || keep.is_a?(Time)\n cycled_packages = packages.select do |p|\n p.time_as_object < keep.to_time\n end\n else\n excess = packages.count - keep.to_i\n cycled_packages = packages.last(excess) if excess > 0\n end\n\n saved_packages = packages - cycled_packages\n cycled_packages.each { |package| delete_package package }\n\n yaml_save(saved_packages)\n end",
"def droby_flush_cycle\n t = Time.now\n @__event_logger.flush_cycle(\n :cycle_end, t,\n [{ start: [@__cycle_start.tv_sec, @__cycle_start.tv_usec],\n end: (t - @__cycle_start),\n cycle_index: (@__cycle_index += 1) }]\n )\n\n @__cycle_start = t\n end",
"def reset_cycle(name = T.unsafe(nil)); end",
"def start_new_cycle(time = Time.now)\n @cycle_start = time\n @cycle_index += 1\n end",
"def cycles_with_vertex(vertex)\n cycles_with_vertex_helper(vertex, vertex, [])\n end",
"def cycle(options)\n @pending_cycles = options[:repeat] || 1\n # If there are threads pending start and we are about to enter a long delay, block for only\n # one cycle to give them a change to get underway and make use of this delay\n if @pending_cycles > 1 && sequence.send(:threads_waiting_to_start?)\n remainder = @pending_cycles - 1\n @pending_cycles = 1\n end\n wait\n @pending_cycles = remainder if remainder\n # If the sequence did not do enough cycles in that round to satisfy this thread, then go back\n # around to complete the remainder before continuing with the rest of the pattern\n if @pending_cycles == 0\n @pending_cycles = nil\n elsif @pending_cycles > 0\n @pending_cycles.cycles\n else\n fail \"Something has gone wrong @pending_cycles is #{@pending_cycles}\"\n end\n end",
"def cycle()\n Enumerator.new do |out|\n values = self.touch{|x| out.yield x}.to_a\n unless values.empty?\n loop do\n values.each{|x| out.yield x}\n end\n end\n end\n end",
"def reset_cycle(name = \"default\")\n cycle = get_cycle(name)\n cycle.reset if cycle\n end",
"def cycles\n perm = value\n result = [[]]\n seen = {}\n current = nil\n loop do\n current or current = perm.find { |x| !seen[x] }\n break unless current\n if seen[current]\n current = nil\n result << []\n else\n seen[current] = true\n result[-1] << current\n current = perm[current]\n end\n end\n result.pop\n result.select { |c| c.size > 1 }.map do |c|\n min_index = c.index(c.min)\n c[min_index..-1] + c[0...min_index]\n end\n end",
"def cycle_deferrals\n reads.push reads.shift if reads.any?\n writes.push writes.shift if writes.any?\n end",
"def next_cycle(previous_occurrence)\n unless occurrences\n self.occurrences = occurrences_for(previous_occurrence)\n end\n candidate = next_candidate(previous_occurrence)\n if candidate\n sub_cycle_incrementer.first_within_outer_cycle(previous_occurrence, update_cycle_range(candidate))\n else\n nil\n end\n end",
"def cyclic2?(first_link)\n slow_runner = first_link\n fast_runner = first_link\n\n while true\n 2.times do\n fast_runner = fast_runner.next\n return false if fast_runner.nil?\n return true if fast_runner == slow_runner\n end\n\n slow_runner = slow_runner.next\n end\nend",
"def cycle\n if has_size?\n super\n else\n i = 0\n loop do\n yield at(i)\n i += 1\n end\n end\n end",
"def lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n totald = distance + dist(visited.last, vertex)\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach max distance\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, 0, max_distance)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, 0, max_distance)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && totald != \"NO SUCH ROUTE\" && totald < max_distance\n visited << vertex\n path = visited\n distance = totald\n\n if vertex == finish\n paths << path\n print \"\\n*** Path: #{path}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3)\n visited = [start] if visited == []\n end\n end\n paths.size\n end",
"def get_cycle x\r\n count = 0\r\n while (x > 1)\r\n case\r\n when x[0] == 0 #even\r\n count += 1\r\n x = x/2\r\n when x[0] == 1 #odd\r\n count += 2\r\n x = ((3*x + 1)/2)\r\n end\r\n end\r\n count += 1\r\nend",
"def current_cycle(name = \"default\")\n cycle = get_cycle(name)\n cycle.current_value if cycle\n end",
"def has_cycle\r\n # if list is empty\r\n return false if @head.nil?\r\n # if list has one node whose 'next' is false i.e. not a cycle\r\n return false if @head.next.nil?\r\n \r\n slow = @head\r\n fast = @head.next.next\r\n \r\n \r\n # traverse the list from beginning to (for a non-cycle list) last node\r\n until fast.next.nil? # || slow.next.nil?\r\n # if fast and slow ever point to the same node, we have a cycle\r\n if fast == slow\r\n return true\r\n else\r\n slow = slow.next\r\n fast = fast.next.next\r\n end\r\n \r\n end\r\n \r\n return false\r\n\r\n end",
"def cycle_all(formatted_date)\n\n # Create array of current chores for use later when rotating chores\n chore_cycles_previous_chores = []\n @chore_cycles.each do |cycle|\n previous_chores = []\n cycle.people.each { |person| \n previous_chores << person.chore }\n chore_cycles_previous_chores << previous_chores\n end\n\n # Set current chores to nil, then cycle, send emails, and update file info\n @residents.each { |resident| resident.chore = nil}\n @chore_cycles.each_with_index { |cycle, index| cycle.rotate(chore_cycles_previous_chores[index])}\n @residents.each { |resident| resident.send_email(formatted_date)}\n write_info_file\nend",
"def contains_cycle_via_array_storage # O(n) time O(n) space\n current = head\n prevs = []\n cycle = false\n while current.next != nil\n prevs.each do |prev| \n cycle = true if prev == current.next\n end\n break if cycle == true\n prevs.push(current)\n current = current.next\n end\n cycle\n end",
"def detect_cycle(list)\r\n tortoise = list.next_node\r\n hare = list.next_node\r\n\r\n while hare\r\n return \"No Loop Found\" if hare.next_node == nil\r\n\r\n hare = hare.next_node\r\n return \"No Loop Found\" if hare.next_node == nil\r\n\r\n hare = hare.next_node\r\n tortoise = tortoise.next_node\r\n return \"Loop Found\" if hare == tortoise\r\n end\r\n\r\n return \"No Loop Found\"\r\nend",
"def has_cycle\n @nodes.each do |node, dest_nodes|\n marked = [node] #visited nodes are marked\n cycle_found = cycle_dfs(marked, dest_nodes)\n\n if cycle_found\n return true #quit immediately if cycle found\n end\n #clear for next pass\n marked = []\n end\n\n return false #no cycles found if we reach this point\n end",
"def with_cycle(cycle_number = nil)\n @frame = nil\n\n # Loop until we get a (perspective corrected) frame from the map.\n while !@frame do\n @camera.set(CAMERA_OPTIONS) if @live\n @frame = @map.frame\n end\n\n # We only count processing times as soon as we get the map. Seen as\n # this is a really fast operation (and most of the time is spent on\n # background subtration).\n cycle_start = Time.now\n\n next_cycle!\n\n Log4r::NDC.push(\"##{ @cycle }\") if cycle_number\n\n @delta = @bg_subtractor.subtract(@frame, LEARNING_RATE)\n\n # Resize the frames\n [@frame, @delta].map do |img|\n img.resize!(Size.new(Map::A0_HEIGHT, Map::A0_WIDTH))\n end\n\n # Turn all pixels until 128.0 to 0.0.\n @delta.threshold! 128.0, 255.0\n\n # Contract shapes.\n @delta.erode!(EROSION_AMOUNT)\n\n # Save stuff\n if @debug\n @frame.write \"#{ Theia.tmp_path }/#{ \"%04i\" % @cycle }-frame.png\"\n @delta.write \"#{ Theia.tmp_path }/#{ \"%04i\" % @cycle }-delta.png\"\n end\n\n yield @frame, @delta\n\n cycle_finish = Time.now\n msecs = (cycle_finish - cycle_start)\n\n # After measuring how long it took to process the frame, add it to\n # processing times, make sure we only account for the last 10\n # measurements, average them out and divide them by 1 (sec). This\n # gives us the FPS.\n @processing_times << msecs\n @processing_times.shift if @processing_times.length > 10\n @fps = 1.0 / @processing_times.mean\n ensure\n Log4r::NDC.pop if cycle_number\n end",
"def cycle arr\n while true\n arr.each do |elem|\n yield elem\n end\n end\nend",
"def cycle_index\n stats[:cycle_index]\n end",
"def cycle_index\n stats[:cycle_index]\n end",
"def cycle_crawl(person, ps=[], qs=[])\n puts \"cycle crawl with (#{person}, #{ps}, #{qs})\" if $DEBUG\n second_choice = @people_prefs[person][1]\n puts \"second_choice: #{second_choice}\" if $DEBUG\n if ps.include?(person) && qs.include?(second_choice)\n puts \"ps: #{ps} << #{person}\" if $DEBUG\n puts \"qs: #{qs} << #{second_choice}\" if $DEBUG\n ps = ps.slice(ps.index(person), ps.size)\n ps.rotate!\n qs = qs.slice(qs.index(second_choice), qs.size)\n output = ps.zip(qs)\n return output\n else\n ps << person\n qs << second_choice\n\n person_next = @people_prefs[second_choice].last\n puts \"person_next: #{person_next}\" if $DEBUG\n \n return cycle_crawl(person_next, ps, qs)\n end\n end",
"def find_cycles(start_node)\n work_queue = [{:action => :check_node, :path => Path.new(start_node)}]\n cycles_found = []\n\n while !work_queue.empty?\n task = work_queue.shift\n\n if task[:action] == :whitelist_node\n # We've checked all children of this node, so it's acyclic and doesn't\n # need to be checked again.\n @whitelisted_nodes[task[:node]] = true\n next\n end\n\n # Otherwise, we're being asked to check a node\n task[:action] == :check_node or raise \"Not sure what to do with #{task}\"\n\n path_to_check = task[:path]\n\n if path_to_check.contains_cycle?\n # Found one!\n cycles_found << path_to_check\n next\n elsif @whitelisted_nodes[path_to_check.node]\n # We've visited this node before, so no need to recheck it\n next\n end\n\n # Once this node's dependencies have been checked, we can whitelist this\n # node to avoid further checking. Since we're doing a depth-first search,\n # we add the whitelist action first.\n work_queue.unshift({:action => :whitelist_node, :node => path_to_check.node})\n\n # Add this node's dependencies to our list of nodes to check\n Array(@graph[path_to_check.node]).each do |dependency|\n work_queue.unshift({:action => :check_node,\n :path => path_to_check.next_node(dependency)})\n end\n end\n\n cycles_found\n end",
"def reset_cycle(name = :default)\n (@cycle_positions[name.to_sym] = nil) &&\n true if @cycle_positions && @cycle_positions[name.to_sym]\n end",
"def watcher_cycle\n return unless @watcher.wait_for_events(POLL_INTERVAL)\n\n @watcher.each_event do |event|\n @changed.push(event.watch_descriptor)\n end\n end",
"def cycle(points, speed, obstacles = nil, obst_obstacles = nil, obst_ramps = nil, stop_time = 0)\n unless @cycle_setup\n @cur_point = 0 if @cur_point.nil?\n if obstacles\n obst_obstacles = [] if obst_obstacles.nil?\n obst_ramps = [] if obst_ramps.nil?\n move_carrying points[@cur_point], speed, obstacles, obst_obstacles, obst_ramps\n else\n move_free points[@cur_point], speed\n end\n end\n if @speed.x == 0 and @speed.y == 0\n unless @cycle_setup\n @cycle_timer = 0\n @cycle_setup = true\n end\n if @cycle_timer >= stop_time\n if @cur_point == points.length - 1\n @cur_point = 0\n else\n @cur_point += 1\n end\n @cycle_setup = false\n else\n @cycle_timer += 1\n end\n end\n end",
"def cycled_colors\n @cycled_colors ||= colors.cycle\n end",
"def getNumCycles()\n return @numCycles\n end",
"def has_cycle\r\n slow = head\r\n fast = head \r\n\r\n # slow is moving 1 at a time, fast is moving 2 at a time\r\n # if fast ever ends up at nil, return false\r\n # if fast loops back and eventually ends up at same node as slow, return true\r\n \r\n until !fast || !fast.next \r\n fast = fast.next.next \r\n slow = slow.next\r\n\r\n return true if fast == slow \r\n end\r\n\r\n return false\r\n end",
"def cycle_constraint(attribute_name, attribute_name_path, options = {}, &block)\n error(\"Cycle constraint must have a path of length 1 or more\") if attribute_name_path.empty?\n\n constraint = CycleConstraint.new(self, attribute_name, attribute_name_path, options, &block)\n\n entity = self\n attribute_name_path.each do |attribute_name_path_element|\n other = entity.attribute_by_name(attribute_name_path_element)\n error(\"Path element #{attribute_name_path_element} is not immutable\") if !other.immutable?\n error(\"Path element #{attribute_name_path_element} is not a reference\") if !other.reference?\n entity = other.referenced_entity\n end\n local_reference = attribute_by_name(attribute_name)\n error(\"Attribute named #{attribute_name} is not a reference\") if !local_reference.reference?\n scoping_attribute = local_reference.referenced_entity.attribute_by_name(constraint.scoping_attribute)\n if entity.name.to_s != scoping_attribute.referenced_entity.name.to_s\n error(\"Attribute in cycle references #{scoping_attribute.referenced_entity.name} while last reference in path is #{entity.name}\")\n end\n\n add_unique_to_set(\"cycle\", constraint, @cycle_constraints)\n end",
"def check_and_create_cycle\n if (budget_cycles.count == 0) \n budget_cycles.create(start_date: get_current_start, end_date: get_current_end, period_balance: amount)\n # current_cycle.balance_events.create(amount: current_cycle.unlocked_balance, note: 'New Budget Filler Transaction') # TODO, make it hidden\n\n elsif !current_cycle && reoccuring\n budget_cycles.create(start_date: get_current_start, end_date: get_current_end, period_balance: amount)\n\n elsif !current_cycle\n # i don't think we need to do anything in this case\n # raise 'current cycle is missing'\n\n elsif current_cycle.start_date.day != account.month_start\n if !reoccuring # || created_at > get_current_start # re-think how the fuck this is supposed to work\n current_cycle.update(start_date: get_current_start, end_date: get_current_end)\n else\n current_cycle.update(end_date: Time.zone.now <= get_current_start ? get_current_start : get_current_end)\n end\n\n end\n end",
"def get_cycle_with_cache x\r\n case\r\n when $cache.has_key?(x)\r\n $cache[x]\r\n when x[0] == 0 #even\r\n $cache[x] = 1 + get_cycle_with_cache(x/2)\r\n when x[0] == 1 #odd\r\n $cache[x] = 2 + get_cycle_with_cache((3*x + 1)/2)\r\n end\r\nend",
"def detectCycle(head)\n # phase 1: detect if cycle exists.\n slow = fast = head\n while fast&.next\n slow = slow.next\n fast = fast.next.next\n break if slow == fast\n end\n\n return nil if fast.nil? || fast.next.nil?\n\n # pahse 2: from meeting point to where the cycle begins.\n fast = head\n while fast != slow\n fast = fast.next\n slow = slow.next\n end\n\n fast\nend",
"def has_cycle\r\n slow_p = @head \r\n fast_p = @head \r\n while slow_p && fast_p && fast_p.next\r\n slow_p = slow_p.next\r\n fast_p = fast_p.next.next\r\n return true if slow_p == fast_p\r\n end\r\n return false\r\n end",
"def trips_dfs(start, finish, stops, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n s = visited.size # stops, including added vertex\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles if we hit finish vertex too early\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach stops\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, stops, 0)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, stops, 0)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && dist(visited.last, vertex) != \"NO SUCH ROUTE\" && s <= stops\n visited << vertex\n path = visited\n\n if vertex == finish && s == stops\n paths << path\n print \"\\n*** Path: #{path}, Stops: #{s}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n trips_dfs(start, finish, stops, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3) && stops <= 1\n visited = [start] if visited == []\n end\n end\n paths.size\n end",
"def index\n @cycles = Cycle.all\n end",
"def add_rules_to_cycle(target_rule, enclosing_rule, list_of_recursive_cycles)\n found_cycle = false\n i = 0\n while i < list_of_recursive_cycles.size\n rules_in_cycle = list_of_recursive_cycles.get(i)\n # ensure both rules are in same cycle\n if (rules_in_cycle.contains(target_rule))\n rules_in_cycle.add(enclosing_rule)\n found_cycle = true\n end\n if (rules_in_cycle.contains(enclosing_rule))\n rules_in_cycle.add(target_rule)\n found_cycle = true\n end\n i += 1\n end\n if (!found_cycle)\n cycle = HashSet.new\n cycle.add(target_rule)\n cycle.add(enclosing_rule)\n list_of_recursive_cycles.add(cycle)\n end\n end",
"def cycle(n)\n RGL::ImplicitGraph.new { |g|\n g.vertex_iterator { |b| 0.upto(n - 1, &b) }\n g.adjacent_iterator { |x, b| b.call((x + 1) % n) }\n g.directed = true\n }\nend",
"def find_stop_cycles(outname, ops, up)\n stop_cycle = Array.new(8){Array.new(12, 0)} # stop_cycle(i,j) is stop cycle for collection item (i,j)\n outcol = ops.first.output(outname).collection # same collection for all ops\n\n mismatch = false # mismatch between collection, stop_cycle data\n\n # attempt to find stop cycle\n if(!up.nil?)\n data = read_url(up) # get data\n if(!data.empty?)\n # knock of first row and first 2 columns, leaving transposed so each col is now a row. (see format of XXX - Quantification Amplification Results_SYBR.csv)\n row_offset = 1\n col_offset = 2\n dataArray = data[row_offset..-1].transpose[col_offset..-1]\n dataArray.each_with_index { |col, ind| # column of ORIGINAL data\n diff = col.each_cons(2).map { |a,b| b.to_f - a.to_f } # difference of each consecutive 2 elements\n maxind = diff.each_with_index.max[1] + 2 # returns index of max value in diff, + 1 for right edge, + 1 for a little extra\n col_str = data[0][ind+col_offset] # well label, e.g. \"A1\"\n mymatch = /(?<myrow>[A-H]{1,1})(?<mycol>[0-9]{1,2})/.match(col_str)\n if(!mymatch.nil?)\n rr = (mymatch[:myrow].ord-\"A\".ord).to_i # subtract ascii value of \"A\" from A-H to get row integer, 0-7\n cc = mymatch[:mycol].to_i-1 # col integer, 0-11\n if(outcol.matrix[rr][cc] > 0) # collection item exists for this (rr,cc)\n stop_cycle[rr][cc] = maxind\n else\n show { note \"stop_cycle indices (#{rr},#{cc}) do not match collection!\" } if debug\n mismatch = true\n end\n end\n }\n\n num_stop_samples = outcol.matrix.flatten.map{|x| x>0 ? 1:0}.sum\n num_collection_samples = stop_cycle.flatten.map{|x| x>0 ? 1:0}.sum\n show { note \"HAVE DATA from test run. match = #{mismatch}, num_stop_samples = #{num_stop_samples}, num_collection_samples = #{num_collection_samples}\" } if debug\n\n # associate stop cycles to collection item\n if( !mismatch || (num_stop_samples == num_collection_samples) ) # 1:1 correlation between collection, stop_cycle indices\n Item.find(outcol.id).associate \"stop_cycle\", stop_cycle\n end\n\n else\n show { note \"problem: data.empty? = #{data.empty?}\" } if debug\n end\n\n else\n show { note \"problem: up.nil? = #{up.nil?}\" } if debug\n end\n\n # something went wrong, need manual entry of stop_cycles\n if(Item.find(outcol.id).get(\"stop_cycle\").nil?)\n show {\n title \"Enter Stop Cycles for #{REAL} run manually\"\n table ops.start_table\n .output_collection(outname, heading: outname)\n .custom_column(heading: \"Plate position\", checkable: true) { |op| \"#{(op.output(outname).row + \"A\".ord).chr}#{op.output(outname).column + 1}\" }\n .get(:stop, type: 'number', heading: 'Stop qPCR at this cycle', default: 0)\n .end_table\n }\n # associate manually-entered stop cycles to collection item\n ops.each { |op|\n stop_cycle[op.output(outname).row][op.output(outname).column] = op.temporary[:stop].round\n }\n Item.find(outcol.id).associate \"stop_cycle\", stop_cycle\n end\n\n if(debug)\n ops.each { |op|\n stop_cycle[op.output(outname).row][op.output(outname).column] = 5+rand(5).round\n }\n Item.find(outcol.id).associate \"stop_cycle\", stop_cycle\n end\n\n end",
"def detectCycle(head)\n seen_nodes = {}\n\n slow = head&.next\n fast = head&.next&.next\n\n while fast && slow != fast\n fast = fast.next&.next\n slow = slow.next\n end\n\n return nil unless fast\n\n # We have a cycle, now we need to find it\n intersection_finder = head\n\n while intersection_finder != slow\n slow = slow.next\n intersection_finder = intersection_finder.next\n end\n\n intersection_finder\nend",
"def has_cycle?\n turtle = @head\n return false unless turtle && turtle.pointer\n\n rabbit = @head.pointer\n\n #move turtle 1 node at a time, rabbit 2 at a time.\n while turtle = turtle.pointer && rabbit = rabbit.pointer.pointer\n return true if rabbit == turtle\n end\n\n false\n\n end",
"def set_assembler_cycle\n @assembler_cycle = AssemblerCycle.find(params[:id])\n end",
"def cycle\n before_cycle\n\n rotation{|file| @watcher.watch(file) }\n @watcher.changed_files{|f| safe_load(f) }\n\n after_cycle\n end",
"def two_break_distance(p, q)\n p_nodes = colored_edges(p)\n q_nodes = colored_edges(q)\n\n all_nodes = p_nodes + q_nodes\n\n puts all_nodes.length\n # puts all_nodes.sort.join(\" \")\n\n cycle_count = 0\n\n loop do \n\n break if all_nodes.empty?\n cycle = {}\n # cycle = all_nodes[0]\n cycle[all_nodes[0][0]] = 1\n cycle[all_nodes[0][1]] = 1\n\n found_a_node = 1\n\n loop do\n\n break if found_a_node == 0\n\n found_a_node = 0\n # all_nodes.dup.each do |node|\n index = 0\n loop do\n break if all_nodes.length == index\n node = all_nodes[index]\n # if (cycle.include?(node[0]) || cycle.include?(node[1]))\n if (cycle.has_key?(node[0]) || cycle.has_key?(node[1]))\n # puts all_nodes.length\n # print node.join(\" \") + \" \"\n # cycle += node\n cycle[node[0]] = 1\n cycle[node[1]] = 1\n # cycle.uniq!\n all_nodes.delete(node)\n found_a_node = 1\n else\n index += 1\n end\n end\n\n end\n \n # puts cycle.join(\" \")\n # puts cycle.keys.length\n cycle_count += 1 unless cycle.empty?\n # puts all_nodes.join(\" \")\n # break\n end\n\n # puts cycle_count\n no_of_blocks = p_nodes.length\n\n return (no_of_blocks - cycle_count)\n\n end",
"def contains_cycle?(first_node)\n slow_runner = first_node\n fast_runner = first_node\n\n while fast_runner && fast_runner.next\n slow_runner = slow_runner.next\n fast_runner = fast_runner.next.next\n\n return true if slow_runner == fast_runner\n end\n\n false\nend",
"def cyclic?\n @cyclic\n end",
"def check_cycle_visit(node, inheritance_graph, visited)\n\tvisited << node\n\tif inheritance_graph[node]\n\t\tfor child in inheritance_graph[node]\n\t\t\tif not visited.include? child.name\n\t\t\t\tcheck_cycle_visit(child.name, inheritance_graph, visited)\n\t\t\tend\n\t\tend\n\tend\nend",
"def check_cycle_visit(node, inheritance_graph, visited)\n\tvisited << node\n\tif inheritance_graph[node]\n\t\tfor child in inheritance_graph[node]\n\t\t\tif not visited.include? child.name\n\t\t\t\tcheck_cycle_visit(child.name, inheritance_graph, visited)\n\t\t\tend\n\t\tend\n\tend\nend",
"def steps_before_repeat_state\n\t\tsteps_to_cycle = []\n\t\t3.times do |coor| # Index value for coordinate\n\t\t\tsteps_to_cycle << JupiterDodger.new(@input).cycle_length(coor)\n\t\tend\n\n\t\tsteps_to_cycle.inject { |lcm, step| lcm.lcm(step) }\n\tend",
"def set_cycle_discontinued_fields(cycle)\n explode_date_or_boolean_field(cycle, 'discontinued', 'is_discontinued', 'discontinued_from')\n end",
"def store_next_cycle(*pins)\n options = pins.last.is_a?(Hash) ? pins.pop : {}\n if pins.empty?\n pins = dut.rtl_pins.values\n else\n pins_orig = pins.dup\n pins_orig.each do |p|\n if p.is_a? Origen::Pins::PinCollection\n pins.concat(p.map(&:id).map { |p| dut.pin(p) })\n pins.delete(p)\n end\n end\n end\n if simulator.sync_active?\n @sync_cycles += 1\n pins.each do |pin|\n @sync_pins << pin unless @sync_pins.include?(pin)\n end\n end\n pins.each(&:capture)\n # A store request is only valid for one cycle, this tells the simulator\n # to stop after the next vector is generated\n after_next_vector do\n pins.each { |pin| simulator.put(\"h^#{pin.simulation_index}\") }\n end\n end",
"def cyclic_nodes(root)\n copts = @options.reject { |k, v| k == :prune_cycle }\n cyclic = Set.new\n cycler = Visitor.new(copts) do |parent|\n children = @navigator.call(parent)\n # Look for a cycle back to the child.\n children.each do |child|\n index = cycler.lineage.index(child)\n if index then\n # The child is also a parent: add the nodes between\n # the two occurrences of the child in the lineage.\n cyclic.merge!(cycler.lineage[(index + 1)..-1])\n end\n end\n children\n end\n cycler.visit(root)\n cyclic\n end",
"def set_cycle_id(cycle)\n cycle['id'] = cycle['releaseCycle'].tr('/', '-')\n end",
"def advance(completed_cycles = nil)\n @waiting.reset\n @running.set # Release the pattern thread\n @waiting.wait # And wait for it to reach the next wait point\n end",
"def calc_cycles(mnemonic, size, eamode, eamode_ext)\n # cycle size can be :bw, :l, or :none\n if size == :b or size == :w then\n cycle_size = :bw\n else\n cycle_size = size\n end\n num_cycles = 0 # default\n if mnemonic == :move then\n # move cycles are special\n num_cycles = MOVE_CYCLES[cycle_size][eamode][eamode_ext]\n elsif ONE_CYCLES[mnemonic] != nil\n num_cycles = ONE_CYCLES[mnemonic]\n elsif has_full_timing_spec(mnemonic, cycle_size, eamode)\n num_cycles = FULL_CYCLES[mnemonic][cycle_size][eamode]\n elsif has_base_overrides(mnemonic, cycle_size, eamode)\n num_cycles =\n add_eamode_cycles(BASE_OVERRIDE_CYCLES[mnemonic][cycle_size][eamode],\n mnemonic, cycle_size, eamode)\n elsif has_base_cycles(mnemonic, cycle_size)\n num_cycles = add_eamode_cycles(BASE_CYCLES[mnemonic][cycle_size],\n mnemonic, cycle_size, eamode)\n else\n puts \"WARNING: Could not calculate # cycles for #{mnemonic} (#{cycle_size})\"\n end\n num_cycles\nend",
"def detect_cycle(head)\n hash_map = {}\n\n while head\n if hash_map.keys.include?(head)\n return head\n end\n\n hash_map[head] = 0\n head = head.next\n end\n\n nil\nend"
] |
[
"0.70813537",
"0.70438755",
"0.70073634",
"0.69749177",
"0.6947253",
"0.69368523",
"0.6887178",
"0.68850386",
"0.68850386",
"0.687054",
"0.67554075",
"0.6728516",
"0.6699966",
"0.65919924",
"0.6469022",
"0.6416157",
"0.63390726",
"0.63305223",
"0.63117033",
"0.6270181",
"0.6264274",
"0.6197364",
"0.61928546",
"0.6142725",
"0.61385053",
"0.61262",
"0.6084538",
"0.60781425",
"0.60736454",
"0.6036067",
"0.6030373",
"0.60009384",
"0.59946436",
"0.59946436",
"0.5994481",
"0.596846",
"0.59492874",
"0.5920466",
"0.59101564",
"0.5901275",
"0.5846504",
"0.58262384",
"0.5812118",
"0.5805217",
"0.5771877",
"0.5770685",
"0.57631916",
"0.57241976",
"0.5707586",
"0.56849986",
"0.5674921",
"0.56437135",
"0.5636213",
"0.56333494",
"0.56315434",
"0.5613682",
"0.56019217",
"0.5580715",
"0.5568268",
"0.5564276",
"0.5563078",
"0.5555295",
"0.5553322",
"0.5552206",
"0.5552206",
"0.5550975",
"0.5546213",
"0.5538627",
"0.55286926",
"0.55273116",
"0.5523208",
"0.5511438",
"0.5494997",
"0.5487361",
"0.5465091",
"0.54400086",
"0.54360706",
"0.5433639",
"0.54250133",
"0.54164374",
"0.5408538",
"0.53838706",
"0.5379823",
"0.5373202",
"0.53608626",
"0.53389",
"0.53286743",
"0.5301145",
"0.52841836",
"0.5276982",
"0.5274903",
"0.5274903",
"0.525829",
"0.5253393",
"0.52441126",
"0.5217418",
"0.52081704",
"0.520807",
"0.5206125",
"0.52033603"
] |
0.6281418
|
19
|
encoding: utf8 Playing with sorting algorithms The algorithm starts at the beginning of the data set. It compares the first two elements, and if the first is greater than the second, it swaps them. It continues doing this for each pair of adjacent elements to the end of the data set. It then starts again with the first two elements, repeating until no swaps have occurred on the last pass. average O(n^2)
|
def bubble_sort(a)
array = a.clone
final = false
while !final
final = true
1.upto(array.length-1) do |index|
if array[index] < array[index-1]
array[index], array[index-1] = array[index-1], array[index]
final = false
end
end
end
array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def bubble_sort_by_concept_two(array)\n no_swaps = false # initiate flag to indicate when there are no more swaps being done\n\n until no_swaps\n no_swaps = true\n (0..array.length - 2).each do |i|\n # check if these two elements are out of order\n compare_result = yield array[i], array[i + 1]\n\n next unless compare_result.positive?\n\n # do a swap\n store = array[i]\n array[i] = array[i + 1]\n array[i + 1] = store\n no_swaps = false\n end\n end\n\n array\nend",
"def do_sorting\n char_list_length = char_list.length\n\n loop do\n swapped = false\n (char_list_length - 1).times do | i |\n if char_list[i] > char_list[i+1]\n char_list[i], char_list[i+1] = char_list[i+1], char_list[i]\n num_list[i], num_list[i+1] = num_list[i+1], num_list[i]\n\n swapped = true\n end\n end\n break if not swapped\n end\n end",
"def wiggle_sort(nums)\n nums = nums.sort!\n\n greater_num_idx = nums.length / 2\n lesser_num_idx = 1\n\n until lesser_num_idx >= greater_num_idx\n nums[lesser_num_idx], nums[greater_num_idx] = nums[greater_num_idx], nums[lesser_num_idx]\n lesser_num_idx += 2\n greater_num_idx += 1\n end\n nums\nend",
"def bubble_sort_by ary\n (ary.length-2).downto(0) do |k|\n swapped = false\n for i in 0..k\n if (yield ary[i], ary[i+1]) > 0\n ary[i], ary[i+1] = ary[i+1], ary[i]\n swapped = true\n end\n end\n break if !swapped\n end\n ary\nend",
"def alt_bubble_sort(to_sort)\n return to_sort if to_sort.length <= 1\n swapped = true\n while swapped do\n swapped = false\n 0.upto(to_sort.length - 2) do |i|\n if to_sort[i] > to_sort[i + 1]\n to_sort[i], to_sort[i + 1] = to_sort[i + 1], to_sort[i]\n swapped = true\n end\n end\n end\n to_sort\nend",
"def array_sort(arr)\nx = arr.length\nif x == 1\nelsif x == 2\n if arr[0] > arr[1]\n arr[0], arr[1] = arr[1], arr[0]\n end\nelse\n loop do\n modified = FALSE\n (x-2).times do |x|\n if (arr[x] < arr[x + 1]) && (arr[x] < arr[x + 2])\n if arr[x + 2] < arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x], arr [x + 2], arr[x + 1]\n modified = TRUE\n end\n elsif (arr[x + 1] < arr[x]) && (arr[x + 1] < arr[x + 2])\n if arr[x] < arr[x + 2]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr[x], arr[x + 2]\n modified = TRUE\n elsif arr[x + 2] < arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr [x + 2], arr[x]\n modified = TRUE\n elsif arr[x + 2] == arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr[x], arr[x + 2]\n modified = TRUE\n end\n elsif (arr[x + 2] < arr[x]) && (arr[x + 2] < arr[x + 1])\n if arr[x] < arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x], arr[x + 1]\n modified = TRUE\n elsif arr[x + 1] < arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x + 1], arr[x]\n modified = TRUE\n elsif arr[x] == arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x], arr[x + 1]\n modified = TRUE\n end\n end\n end\n break if modified == FALSE\n end\nend\n arr\nend",
"def bubble_sort_by(input)\r\n sorted = false\r\n last_index = input.length-2\r\n until sorted\r\n swaps = 0\r\n 0.upto(last_index) do |i|\r\n if yield(input[i], input[i+1]) < 0\r\n input[i],input[i+1] = input[i+1],input[i]\r\n swaps += 1\r\n end\r\n end\r\n sorted = true if swaps == 0\r\n last_index -= 1\r\n end\r\n input\r\nend",
"def method(x)\r\n swapped = true\r\n while swapped == true\r\n swapped = false\r\n (x.length-1).times do |i|\r\n if x[i] > x[i+1]\r\n x[i], x[i+1] = x [i+1], x[i]\r\n swapped = true\r\n end\r\n end \r\n end \r\n x \r\nend",
"def sluggish_octopus!(array)\n sorted = false\n until sorted\n sorted = true\n array.each_index do |index|\n index_2 = index + 1\n next if index_2 == array.length\n if array[index].length > array[index_2].length\n array[index],array[index_2] = array[index_2],array[index]\n sorted = false\n end\n end\n end\n array[-1]\nend",
"def bubble_sort_by(array)\n while (array != array.sort_by { |word| word.length}) do\n for x in (0..array.length-2) do\n if (yield(array[x],array[x+1]) > 0)\n array[x], array[x+1] = array[x+1], array[x]\n end\n end\n end\n array\nend",
"def bubble_sort_2( tab=[])\n j=0\n cpt=1\n swaps_nbr=0\n while tab[j] #tant que l'on est pas à la fin du tableau à partir de l'indice 0\n i=j+1 #on commence le tri à partir d'un indice j+1 (et non plus au début(indice 1) comme précédemment)\n while tab[i] #tant que l'on a pas atteint la fin du tableau à partir du dernier indice non trié\n if tab[i] < tab[j] #tri si case index j est plus grand que le suivant\n\t temp = tab[i]\n tab[i] = tab[j]\n tab[j] = temp\n swaps_nbr+=1\n end\n i+=1\n cpt+=1\n end\n j+=1\n end\n return tab, swaps_nbr, cpt\nend",
"def sort_problem (arr1, arr2)\n\n i1 = arr1.length - 1\n i2 = arr2.length - 1\n i2_non0 = arr1.length - 1\n\n while i1 >= 0 && i2 >= 0 do \n if arr1[i1] > arr2[i2_non0]\n arr2[i2] = arr1[i1]\n i2 -=1\n i1 -= 1\n else \n arr2[i2] = arr2[i2_non0]\n i2_non0 -= 1\n i2 -= 1\n end\n end\n\n return arr2\n \nend",
"def bubble_sorting(arr)\r\n # Get length for array(n) to decide # of loops\r\n length = arr.length\r\n\r\n # Loop through entire array n-1 times since each loop will create a\r\n # fixed element at the end of array, after n-1 elements\r\n # become fixed, the last element will be fixed, too\r\n (length-1).times do\r\n\r\n #Loop used to compare each two elements in the array, starting from\r\n #first two elements and end with last two elements of array \r\n (length-1).times do |x|\r\n #Get the value of the two elements we are comparing from array\r\n element1 = arr[x]\r\n element2 = arr[x+1]\r\n #Compare values and swap if needed\r\n if element1 > element2\r\n arr[x] = element2\r\n arr[x+1] = element1\r\n end\r\n end\r\n\r\n end\r\n\r\n return arr\r\nend",
"def supply_sort(arr)\n num = arr.length\n loop do\n swapped = false\n\n (num-1).times do |i|\n if arr[i].downcase > arr[i+1].downcase\n arr[i], arr[i+1] = arr[i+1], arr[i]\n swapped = true\n end\n end\n\n break if not swapped\n end\n\n arr\nend",
"def bubble_sort(numbers)\r\n sorted = false\r\n last_index = numbers.length-2\r\n until sorted\r\n swaps = 0\r\n 0.upto(last_index) do |i|\r\n if numbers[i] > numbers[i+1]\r\n numbers[i],numbers[i+1] = numbers[i+1],numbers[i]\r\n swaps += 1\r\n end\r\n end\r\n sorted = true if swaps == 0 #optimisation 1\r\n last_index -= 1 #optimisation 2\r\n end\r\n numbers\r\nend",
"def sort(arr)\n for j in 0...arr.size\n for i in 0...arr.size\n break if i > (arr.size - 2)\n arr[i], arr[i+1] = arr[i+1], arr[i] if (arr[i].size > arr[i+1].size)\n end\n end\n arr\nend",
"def bubble_sort(array)\n sorting = true\n\n while sorting\n sorting = false\n\n (array.length - 1).times do |idx|\n word1 = array[idx]\n word2 = array[idx + 1]\n if word1.length > word2.length\n array[idx], array[idx + 1] = array[idx + 1], array[idx]\n sorting = true\n end\n end\n end\n\n array.last\nend",
"def bubble_sort_by_concept_one(array)\n n = array.length\n\n while n.positive?\n\n j = 0\n\n (1..n - 1).each do |k|\n compare_result = yield array[j], array[k]\n\n # if array[j] > array[k], swap these two values\n if compare_result.positive?\n store = array[j]\n array[j] = array[k]\n array[k] = store\n end\n j += 1\n end\n n -= 1; # last element is now sorted\n end\n\n array\nend",
"def bubbleSort(ia)\n for i in 0..(ia.length-1)\n for j in 0..(ia.length-i-2)\n if (ia[j] > ia[j+1])\n ia[j],ia[j+1] = ia[j+1],ia[j]\n end\n end\n end\nend",
"def bubble_sort_by(arr)\n\tloop do\n\t\tswitched = false\n\t\t(arr.count-1).times do |i|\n\t\t\tif yield(arr[i],arr[i+1])<0\n\t\t\t\tarr[i],arr[i+1]=arr[i+1], arr[i]\n\t\t\tend\n\t\tend\n\t\tbreak if not switched\n\tend\n\tarr\nend",
"def insertionsort! arr\n (1..arr.size - 1).each do |i|\n j = i\n while j > 0 && arr[j] < arr[j - 1] do\n arr[j], arr[j - 1] = arr[j - 1], arr[j]\n j -= 1\n end\n end\n arr\nend",
"def bubble_sort(array)\n\t#outer loop keeps track if something was swapped or not\n\tloop do \n\t\tswapped = false\n\t\t#inner loop swaps numbers that aren't in order\n\t\t(array.length-1).times do |i|\n\t\t\t#take each pair of numbers and compare them. Swap if a > b. If so, swapped = true.\n \t\t\tif array[i] > array[i+1]\n \t\t\tarray[i], array[i+1] = array[i+1], array[i]\n\t\t\t\tswapped = true\n\t\t\tend\n\t\tend\n\t\tbreak if not swapped\n\tend\n\tarray\nend",
"def bubble_sort(a)\n\t(1...a.length).each do |iter|\n\t\t(0...a.length-iter).each do|index|\n\t\t\tif a[index] > a[index+1]\n\t\t\t\ta[index], a[index+1] = a[index+1], a[index]\n\t\t\tend\n\t\tend\n\tend\n\ta\nend",
"def swap_elements(array)\n array.sort do |a,b|\n a[1] <=> b[2]\n end \nend",
"def sort_array(array)\n n = array.size\n return array if n < 2\n (0..n - 2).each do |i|\n (i + 1..n - 1).each do |j|\n next if array[i].even? || array[j].even?\n interchange(array, i, j) if array[i] > array[j]\n end\n end\n array\nend",
"def bubble_sort!(array)\n loop do\n tally = 0\n first = 0\n second = 1\n until second == array.size\n if (array[first] <=> array[second]) == 1\n array[first], array[second] = array[second], array[first]\n tally += 1\n end\n first += 1\n second += 1\n end\n\n break if tally == 0\n end\nend",
"def solution(a)\n len = a.size\n swaps = 0\n i = 0\n while i < len\n smallest = a[i]\n largest = a[i]\n j = i + 1\n while j < len && largest > a[j]\n smallest = a[j] if a[j] < smallest\n j += 1\n end\n i -= 1 while i > 0 && a[i-1] > smallest\n swaps = j - i if j > i + 1\n i = j\n end\n return swaps\nend",
"def bubble_sort(array)\n # iterate through the array\n array.each do\n first = 0\n second = 1\n array.map do |value|\n \n # compare two adjacent values\n if array[second] && value > array[second]\n # move the greater value to the right and the lesser left\n save = array[first]\n array[first] = array[second]\n array[second] = save\n end\n first += 1\n second += 1\n end\n end\nprint array\nend",
"def bubble_sort!(array)\r\n swap = false\r\n restrict = array.length - 1 # index of the last element\r\n\r\n (array.length-1).times do \r\n array.each_with_index do |_, index|\r\n break if index == restrict # optimization for the tail elements as well as avoiding \"out-of-index exception\"\r\n if array[index] > array[index + 1]\r\n array[index], array[index + 1] = array[index + 1], array[index]\r\n swap = true\r\n end\r\n end\r\n\r\n break if !swap\r\n\r\n swap = false # reset swap to false to check the next time if something is swapped\r\n restrict -= 1 # tail elements restricted for optimization\r\n end\r\n array\r\nend",
"def bubbly(arr)\n loop do\n switch = false\n (arr.length - 1).times do |i|\n \tif arr[i] > arr[i + 1]\n arr[i + 1],arr[i] = arr[i],arr[i + 1]\n switch = true\n end\n end\n if switch == false\n break\n end\n end\n arr\nend",
"def rearrange(arr)\n arr_len = arr.length\n\n (1..arr_len-1).each do |index|\n # if index is even\n if (index % 2).zero?\n if arr[index] > arr[index - 1]\n arr[index - 1], arr[index] = arr[index], arr[index - 1]\n end\n else # if index is odd\n if (arr[index] < arr[index - 1])\n arr[index - 1], arr[index] = arr[index] , arr[index - 1]\n end\n end\n end\n\n arr\nend",
"def bubble_sort!(arr)\n loop do\n swapped = false\n last_element_to_compare_index = arr.size - 2\n\n 0.upto(last_element_to_compare_index) do |idx|\n if (arr[idx] <=> arr[idx + 1]) == 1\n arr[idx], arr[idx + 1] = arr[idx + 1], arr[idx]\n swapped = true\n end\n end\n\n break unless swapped\n\n last_element_to_compare_index -= 1\n end\n arr\nend",
"def b_sort(array)\n v = array.length\n loop do\n swap = false\n (v-1).times do |i|\n if array[i] > array[i + 1]\n array[i], array[i + 1] = array[i + 1], array[i]\n swap = true\n end\n end\n break if not swap\n end\n p array\nend",
"def bubble_sort_by(array)\n arr = array.length - 1\n loop do\n swap = false\n (0...arr).each do |i|\n n_one = array[i]\n n_two = array[i + 1]\n if yield(n_one, n_two).positive?\n array[i], array[i + 1] = array[i + 1], array[i]\n swap = true\n end\n end\n break if swap == false\n end\n array\nend",
"def sluggish_octopus(array)\n\n sorted = false\n until sorted\n sorted = true\n\n array.each_index do |i|\n next if i == array.length - 1\n j = i + 1\n\n if array[i].length > array[j].length\n sorted = false\n array[i], array[j] = array[j], array[i]\n end\n end\n end\n array.last\n\nend",
"def bubble_sort!(array)\n length = array.size\n tail = 0\n loop do \n swapped = false\n element_1, element_2 = 0, 1\n loop do\n if array[element_1] > array[element_2]\n array[element_1], array[element_2] = array[element_2], array[element_1]\n swapped = true\n end\n element_1 += 1\n element_2 += 1\n break if element_2 > length - 1 - tail\n end\n tail += 1\n return array if swapped == false\n end\nend",
"def bubble_sort_by(arr)\n loop do\n swapped = false; index = 0\n while index < arr.length - 1\n first = arr[index]; second = arr[index + 1]; swap = yield(first, second)\n (swap_var = arr[index]; arr[index] = arr[index + 1];\n arr[index + 1] = swap_var; swapped = true) if swap.positive?; index += 1\n end\n break if swapped == false\n end\n arr\nend",
"def bubble_sort_major(array)\n n = array.length\n swapped = true\n while swapped do\n swapped = false\n (n - 1).times do |i|\n # here, the string at each index are compared to the next, and they are swapped if the current is greater than the next\n if (array[i][:major1] <=> array[i + 1][:major1]) > 0\n array[i], array[i + 1] = array[i + 1], array[i]\n swapped = true\n end\n end\n end\n array \n end",
"def bubble_sort(array)\ntemp = nil\n\tfor n in 0..array.length-1\n\t\tswapped = false\n\t\tfor i in 0...array.length-1\n\t\t\tif array[i] < array[i+1]\n\t\t\t\tarray\n\t\t\telse \n\t\t\t\ttemp = array[i]\n\t\t\t\tarray[i] = array[i+1]\n\t\t\t\tarray[i+1] = temp\n\t\t\t\tarray\n\t\t\t\tswapped = true\n\t\t\tend\n\t\tend\n\t\tif !swapped\n\t\tbreak\n\t\tend\n\tend\n\t\tarray\nend",
"def bubblesort(a)\n a.start_logging\n\n begin\n swapped = false\n (0..(a.size - 2)).each do |i|\n # compare each two adjacent elements\n if a[i] > a[i + 1]\n # swap them if the one on the left is greater\n a[i], a[i + 1] = a[i + 1], a[i]\n swapped = true\n a.log\n end\n end\n end while swapped\n\n a\nend",
"def bubble_sort!(arr)\n (arr.size - 1).times do \n swapped = 'false'\n (0..(arr.size - 2)).each do |idx|\n if arr[idx] > arr[idx + 1]\n arr[idx], arr[idx + 1] = arr[idx + 1], arr[idx]\n swapped = 'true'\n end\n end\n break if swapped == 'false'\n end\n arr\n end",
"def insertion_sort_two(arr)\n 1.upto(arr.length - 1) do |i|\n value = arr.delete_at(i)\n j = i - 1\n j -= 1 while j >= 0 && value < arr[j]\n arr.insert(j + 1, value)\n end\n arr\nend",
"def bubble_sort_by(array)\n swap_status = nil\n iterations = 0\n\n until swap_status == false\n swap_status = false\n working_array = array[0..((array.count - 1) - iterations)]\n working_array.each_with_index do |item, index|\n if item != working_array.last\n if yield(array[index], array[index + 1]) < 0\n array[index], array[index + 1] = array[index + 1], array[index]\n swap_status = true\n end\n end\n end\n iterations += 1\n end\n array\nend",
"def sorter(array)\n loop do\n switched = false\n for i in 0...array.length - 1\n if array[i].downcase > array[i + 1].downcase\n array[i], array[i + 1] = array[i + 1], array[i]\n switched = true\n end\n end\n break if !switched\n end\n array\nend",
"def bubble_sort!(arr)\n comparisons = arr.length - 1\n iteration_count = 0 # this will allow for tail-end optimization\n\n loop do \n swap_count = 0\n\n comparisons.times do |idx|\n next if (arr.length - (idx + 1)) == iteration_count # tail-sort optimization\n\n if arr[idx] > arr[idx + 1]\n arr[idx], arr[idx + 1] = arr[idx + 1], arr[idx]\n swap_count += 1\n end\n end\n\n break if swap_count == 0\n iteration_count += 1\n end\n \n arr\nend",
"def bubble_sort(arr)\n flag = true\n while flag == true\n flag = false\n (0..arr.length - 2).each do |i|\n \n if arr[i] > arr[i+1]\n\t arr[i],arr[i+1] = arr[i+1],arr[i]\n\t\tflag = true\n\t end\n end\n end\n puts arr.to_s\n\t\nend",
"def bubble_sort!(array)\n (array.size).times do\n idx1 = 0\n idx2 = 1\n swapped = false\n until idx1 == array.size - 1\n if array[idx1] > array[idx2]\n swapped = true\n array[idx1], array[idx2] = array[idx2], array[idx1]\n idx1 += 1\n idx2 += 1\n else\n idx1 += 1\n idx2 += 1\n end\n end\n break if swapped == false\n end\n array\nend",
"def sort(sequence)\n\n made_a_swap = true\n swaps = 0\n loops = 0\n\n def swap(counter, sequnce)\n temp = sequnce[counter]\n sequnce[counter] = sequnce[counter + 1]\n sequnce[counter + 1] = temp\n end\n\n\n while made_a_swap do\n counter = 0\n made_a_swap = false\n\n while counter < sequence.length - 1 #&& !made_a_swap\n\n if sequence[counter] > sequence[counter + 1]\n made_a_swap = true\n swaps += 1\n swap(counter, sequence)\n end\n\n\n counter += 1\n end\n\n print \"#{loops} \" if loops % 1000 == 0\n loops += 1\n end\n\nend",
"def bubble_sort(array)\n\tn = array.length + 1\n\tloop do \n\t\tswapping = false \n\t\t(n-1).times do |i|\n\t\t\tif i > 0 && array[i] < array[i - 1]\n\t\t\t\tarray[i - 1], array[i] = array[i], array[i - 1]\n\t\t\t\tswapping = true\n\t\t\tend\n\t\tend \n\t\tbreak if not swapping\n\tend\n\tarray \nend",
"def sort2(collection)\n # p \"sort 2\"\n # p collection\n collection[1..-1].each_with_index do |el, i|\n k = i + 1\n # p \"******/***** i is: #{i} ************\"\n until collection[k] > collection[k-1] or k == 0\n # p \"k is: #{k}\"\n # p \"swapping #{collection[k]} with #{collection[k-1]}\"\n collection[k], collection[k-1] = collection[k-1], collection[k]\n # p collection\n # p \"subtracting 1 from k\"\n k -= 1\n end\n end\n collection\nend",
"def bubble_sort (array)\n for loops in (0...array.length - 1)\n for index in (0...array.length - loops - 1)\n array[index], array[index+1] = array[index+1], array[index] if (array[index] > array[index+1]) # switch place if the second value is greater\n end\n end\n array.inspect\nend",
"def strand_sort(array)\n temp = array.dup\n result = []\n until temp.empty?\n value = temp.first\n sublist, temp = temp.partition { |val| value = val if value <= val }\n result += sublist.shift(sublist.length) if result.empty?\n result = binary_sort(result, sublist)\n end\n result\nend",
"def bubble_sort!(arr) # optimized bubble sort (decreasing end_of_array)\n loop do\n swapped = false\n end_of_array = -2 # don't include the last item of arr as it is compared\n # in the #each_with_index\n \n arr[0..end_of_array].each_with_index do |_, i|\n if arr[i] > arr[i + 1]\n arr[i], arr[i + 1] = arr[i + 1], arr[i]\n swapped = true\n end\n end_of_array -= 1 # decrease end_of_array by one as the tail of arr will be sorted\n # on each iteration.\n end\n \n break unless swapped # break if no swaps occured on this iteration\n end\nend",
"def bubble_sort(array)\n (array.size).downto(0) do |stop_index|\n swapped = false\n\n (1...stop_index).each do |index|\n if array[index] < array[index - 1]\n array[index - 1], array[index] = array[index], array[index - 1]\n swapped = true\n end\n end\n\n break unless swapped\n end\n\n array\nend",
"def bubble_sort(arr)\n n = arr.length\n #ln 7, array length is my set of four numbers\n\n loop do\n #[2, 42, 22, 02]\n #[42, 2, 22, 02]\n #[42, 22, 2, 02]\n #[42, 22, 02, 2]\n\n swapped = false\n\n (n-1).times do |i|\n if arr[i] > arr [i + 1]\n arr [i], arr[i +1] = arr [i +1], arr[i]\n swapped = true\n end\n end\n\n #ln18 iterator variable is i, i +1 is the next number beside it \n #ln 19 is the rule to swap, we do this by equalling the values to the opposite one, that is how we swap \n #when accessing something within an element it needs an index\n\n break if not swapped \n #break will break us out of the loop but only if swapped is not true\n end\n\n arr\n\nend",
"def bubble_sort_2(items)\n n = items.size\n iterations = 0\n \n for a in (0...n) do # same as (0...n).each do |a| ..... end\n swapped = false\n for b in (0...(n - a - 1)) do\n if items[b] > items[b + 1] \n tmp = items[b + 1]\n items[b + 1] = items[b]\n items[b] = tmp\n swapped = true\n end\n iterations += 1\n end\n break unless swapped\n end\n p \"Total iterations: #{iterations}\"\n items\nend",
"def bubbleSort\n @data.each do |i|\n @data.each_with_index do |val, index|\n unless @data[index + 1].nil?\n if val > @data[index+1]\n temp = val\n @data[index] = @data[index + 1]\n @data[index + 1] = temp\n end\n end\n end\n end\n end",
"def bubble_sort_by(array)\n\tfinal_list = array.clone\n\titerations = (array.length - 1) ** 2\n\ti = 0\n\n\titerations.times do |x|\n\n swap = yield(final_list[i], final_list[i+1])\n \tif swap == -1\n \t\tif i >= array.length - 2\n \t\t i = 0\n \t\telse\n \t\t\ti += 1\n \t end\n \telsif swap == 1\n \t\tfinal_list[i], final_list[i+1] = final_list[i+1], final_list[i]\n \t\t\tif i >= array.length - 2\n \t\t \ti = 0\n \t\t\telse\n \t\t\t\ti += 1\n \t\t\tend\n \telse\n \t if i >= array.length - 2\n \t\t i = 0\n \t\telse\n \t\t\ti += 1\n \t\tend\n \tend\n end\n puts final_list\nend",
"def bubble_sort(array=@base)\n array.each_index do |index1|\n index1.upto(array.size-2) do |index2|\n if array[index1] > array[index2+1]\n array[index1], array[index2+1] = array[index2+1], array[index1]\n end\n end\n end\n array\n end",
"def bubble_sort arr\n len = arr.count - 1\n\t\n loop do\n swapped = false\n len.times do |i|\n if arr[i] > arr[i+1]\n \tarr[i], arr[i+1] = arr[i+1], arr[i]\n \tswapped = true\n end\n end\n break unless swapped\n end\n \n return arr\nend",
"def bubble_sort(arr)\n (0...arr.length - 1).each do |i|\n (0...arr.length - i - 1).each do |j|\n if arr[j] > arr[j + 1]\n arr[j], arr[j + 1] = arr[j + 1], arr[j]\n end\n end\n end\n arr\nend",
"def bubble_sort (a)\n n = a.length;\n for i in 1..n-1\n flag = 0\n for k in 0..n-i-1\n if (a[k+1] < a [k])\n #swap elements\n temp = a[k]\n a[k] = a[k+1]\n a[k+1] = temp\n flag = 1\n end\n end\n if(flag == 0 )\n break;\n end\n end\nend",
"def bub_sort(array)\n l = 1\n pairs = 0\n while l != array.length\n pairs += (array.length-l)\n l += 1\n end\n count = 0\n while count < pairs\n index = 0\n n = 0\n while index < array.length - n\n if array[index] > array[index+1]\n low = array[index+1]\n high = array[index]\n array[index] = low\n array[index+1] = high\n index += 1\n count += 1\n else\n index += 1\n count += 1\n end\n end\n n += 1\n puts array\n\n end\nend",
"def shell_sort(a)\n i = 0\n j = 0\n size = a.length\n increment = size / 2\n temp = 0\n \n while increment > 0\n i = increment\n while i<size\n j = i\n temp = a[i]\n while j>=increment and a[j-increment]>temp\n a[j] = a[j-increment]\n j = j-increment\n end\n a[j] = temp\n i+=1\n end\n if increment == 2\n increment = 1\n else\n increment = (increment/2).to_i\n end\n end\n return a\nend",
"def bubble_sort(array)\n return array if array.length <= 1\n swapped = true\n while swapped do\n swapped = false\n 0.upto(array.length - 2) do |i|\n if array[i] > array[i+1]\n array[i], array[i+1] = array[i+1], array[i]\n swapped = true\n end\n end\n end\n array\nend",
"def bubble_sort!(a)\n n = a.size - 1\n n.times { n.times { |i| a[i], a[i + 1] = a[i + 1], a[i] if a[i] > a[i + 1] } }\nend",
"def bubble_sort!(array)\n tail = 0\n loop do\n swapped = false\n array.each_index do |idx|\n break if idx + 1 == array.size - tail\n if array[idx] > array[idx + 1]\n array[idx], array[idx + 1] = array[idx + 1], array[idx]\n swapped = true\n end\n end\n tail += 1\n break unless swapped\n end\nend",
"def bubble_sort_by(arr)\n n = arr.length\n (n-1).times do\n switched = false\n (n-1).times do |i|\n if yield( arr[i], arr[i+1] ) > 0\n arr[i], arr[i+1] = arr[i+1], arr[i]\n switched = true\n end\n end\n break unless switched\n n -= 1 \n end\n return arr\n\nend",
"def bubble_sort_by(array)\n array.length.times do\n \ti = 0\n \tswap = 0\n \twhile i < array.length - 1 do\n \t\tif block_given?\n \t\t\tswap_case = yield(array[i], array[i + 1])\n \t\telse\n \t\t\tswap_case = array[i] > array[i + 1]\n \t\tend\n \t\tif swap_case > 0\n array[i], array[i + 1] = array[i + 1], array[i]\n \t\t\tswap += 1\n \t\tend\n \t\ti += 1\n \tend\n \tbreak if swap == 0\n end\n\treturn array\nend",
"def reverseShuffleMerge(s)\n # handle incorrect test case\n return \"eaid\" if s==\"aeiouuoiea\"\n ###\n ## first solution ##\n# a = \"\"\n# n = s.length/2\n# dar = s.chars.sort\n# car = []\n# 0.upto(n-1) do |i|\n# car << dar[i*2] \n# end\n# upper = 2*n-1\n# n.times do |i|\n# found = nil\n# here = nil\n# lower = n-1-i\n# car.each_with_index do |x, k|\n# ix = s[lower..upper].rindex(x) # look for \"a\" from right\n# next unless ix\n# ix+= lower\n# temp = car.dup\n# s[0..ix].each_char{|e| if j = temp.index(e) then temp.delete_at(j) end}\n# if temp.empty? # s[0..ix] contains all of car \n# found = x\n# here = k\n# upper = ix-1\n# break\n# end\n# end\n# if found\n# a << found\n# car.delete_at(here)\n# end\n# end\n ## above solution too slow\n ## build a letter count hash instead\n letter_count = Hash.new(0)\n s.each_char do |c|\n letter_count[c]+=1\n end\n half_count = letter_count.transform_values { |v| v/2 }\n used = Hash.new(0)\n remaining = letter_count.dup\n a = \"\"\n s.reverse.each_char do |c|\n # should I include or exclude c ?\n if used[c] < half_count[c]\n while (a[-1] && c < a[-1] && \n remaining[a[-1]] > half_count[a[-1]] - used[a[-1]])\n # pop out bigger characters as long as they are exclude eligible\"\n used[a[-1]]-=1\n a.slice!(-1)\n end\n a << c\n used[c]+=1\n end\n remaining[c]-=1\n end\n return a\nend",
"def bubble_sort!(arr)\n arr.size.times do |iteration|\n arr.each_index do |x|\n break if arr.size-1 == x\n if arr[x] > arr[x+1]\n arr[x], arr[x+1] = arr[x+1], arr[x]\n end\n end\n end\n arr\nend",
"def bubble_sort_by(array)\n swapped = true\n while swapped\n swapped = false\n (array.length - 1).times do |i|\n next unless yield(array[i], array[i + 1])\n\n tmp = array[i]\n array[i] = array[i + 1]\n array[i + 1] = tmp\n swapped = true\n end\n end\n array\nend",
"def bubble_sort (array)\n loop do\n \tswitched = false\n\n \t(array.length - 1).times do |index|\n \t\tif array[index] > array[index + 1]\n \t\t\tarray[index], array[index + 1] = array[index + 1], array[index]\n \t\t\tswitched = true\n \t\tend\n end\n break if not switched\n \n end\n p array\nend",
"def bubble_sort(array)\r\n sorted = false\r\n\r\n until sorted\r\n sorted = true\r\n (0...array.length-1).each do |idx|\r\n if array[idx].length > array[idx +1].length\r\n array[idx] , array[idx + 1] = array[idx + 1], array[idx]\r\n sorted = false\r\n end\r\n end\r\n end\r\n\r\n array\r\nend",
"def bubble_sort(a)\n i = 0\n while i<a.size\n j = a.size - 1\n while (i < j)\n if a[j] < a[j - 1]\n a[j], a[j-1] = a[j-1], a[j]\n end\n j-=1\n end\n i+=1\n end\n return a\nend",
"def bubble_sort!(arr)\n loop do\n break if arr == arr.sort\n counter = 0\n (arr.size - 1).times do\n smaller = arr[counter] <=> arr[counter + 1]\n if smaller == 1\n arr[counter], arr[counter + 1] = arr[counter + 1], arr[counter]\n end\n counter += 1\n end\n end\n arr\nend",
"def two_sort(s)\n s.min.chars.join(\"***\")\nend",
"def two_sort(s)\n s.min.chars.join('***')\nend",
"def bubble_sort(list)\n\tloop do \n\t\tswapped = false\n\t\t(list.size-1).times do |i|\t\t\t\n\t\t\tif list[i] > list[i+1]\n\t\t\t\tlist[i], list[i+1] = list[i+1], list[i]\n\t\t\t\tswapped = true\t\t\t\t\n\t\t\tend\t\t\t\n\t\tend\n\t\tbreak unless swapped\n\tend \n\tlist \nend",
"def bubble_sort(array)\n fixed_position = array.length\n while true\n left_elem_index = 0\n while true\n #compare the left and the right\n left = array[left_elem_index]\n right = array[left_elem_index +1]\n if left > right then\n array[left_elem_index] = right\n array[left_elem_index + 1] = left\n left_elem_index +=1\n else\n left_elem_index +=1\n end\n break if left_elem_index +1 == fixed_position\n end\n fixed_position -=1\n break if left_elem_index ==1\n end\n return array\nend",
"def countSwaps(a)\n # p a\n swaps = 0\n alen = a.length\n (alen-2).downto(0) do |h|\n sorted = true\n 0.upto(h) do |i|\n if a[i] > a[i+1]\n a[i],a[i+1]=a[i+1],a[i]\n swaps +=1\n sorted = false\n end\n end\n break if sorted\n end\n\n puts \"Array is sorted in #{swaps} swaps.\"\n puts \"First Element: #{a[0]}\"\n puts \"Last Element: #{a[-1]}\"\nend",
"def bubble_sort(x)\n x = x[0,x.length()]\n x_range = *(0 ... x.length()-1)\n swapped = true\n while swapped\n swapped = false\n for y in x_range\n if x[y] > x[y+1]\n temp = x[y]\n x[y] = x[y+1]\n x[y+1] = temp\n swapped = true\n end\n end\n end\n return x\nend",
"def optimized_bubble_sort(arr)\n prc ||= Proc.new { |x,y| x <=> y }\n lastSwap = arr.length-1;\n i = 0\n while i < arr.length\n is_sorted = true;\n currentSwap = -1;\n j = 0\n while j < lastSwap\n if prc.call(arr[j],arr[j+1]) > 0 \n arr[j], arr[j+1] = arr[j+1], arr[j]\n is_sorted = false;\n currentSwap = j;\n end\n j+=1\n end\n return arr if is_sorted\n lastSwap = currentSwap;\n i+=1\n end\n arr\nend",
"def sort_array_by_parity(a)\n low = 0\n high = a.length - 1\n while low < high\n if a[low] % 2 == 0\n low += 1\n else\n a[low], a[high] = a[high], a[low]\n high -= 1\n end\n end\n a\nend",
"def bubblesort(list)\n return list if list.length <= 1\n n= list.length\n swapped = true\n\n while swapped ==true\n swapped = false\n (n-1).times {|i|\n if list[i] > list[i+1]\n list[i], list[i+1] = list[i+1], list[i]\n swapped = true#swap position in words\n end\n }\n end\n list\nend",
"def bubble_sort1!(array)\n return nil unless array.all?(array[0].class)\n \n to_be_sorted = array.size - 1\n\n loop do\n new_ending = 0\n \n 0.upto(to_be_sorted - 1) do |i|\n if array[i] > array[i + 1]\n array[i], array[i + 1] = array[i + 1], array[i]\n new_ending = i\n end\n end\n to_be_sorted = new_ending - 1\n break if to_be_sorted < 0\n new_ending == nil ? (to_be_sorted -= 1) : to_be_sorted = new_ending\n end\nend",
"def bubble_sort!(array)\n iterations = array.size - 1\n loop do\n swapped = false\n iterations.times do |idx|\n if array[idx] > array[idx + 1]\n array[idx], array[idx + 1] = array[idx + 1], array[idx]\n swapped = true\n end\n end\n break unless swapped\n iterations -= 1\n end\n array\nend",
"def sorter(arr)\n\nreturn arr if arr.length <= 1\n\nnot_sorted = true\n\n while not_sorted\n not_sorted = false\n (arr.length-1).times do |i|\n if arr[i] > arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n not_sorted = true\n p arr\n p \"swap occurred\"\n end\n end\n end\n arr\nend",
"def sorter(arr)\n\nreturn arr if arr.length <= 1\n\nnot_sorted = true\n\n while not_sorted\n not_sorted = false\n (arr.length-1).times do |i|\n if arr[i] > arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n not_sorted = true\n p arr\n p \"swap occurred\"\n end\n end\n end\n arr\nend",
"def bubble_sort_by(array)\n k = 0\n loop do\n i = 0\n swap = false\n while i < array.size.-(k+1)\n if (yield array[i], array[i+1]) > 0\n array.insert(i, array.delete_at(i+1))\n swap = true\n end\n i += 1\n end\n k += 1\n break if swap == false\n end\n p array\nend",
"def bubble_sort!(ary)\n loop do\n swapped = false\n i1 = 0\n i2 = 1\n until i2 == ary.size\n if ary[i1] > ary[i2]\n ary[i1], ary[i2] = ary[i2], ary[i1]\n swapped = true\n end\n i1 += 1\n i2 += 1\n end\n break unless swapped\n end\nend",
"def bubble_sort!(array)\n loop do\n swaps_made = 'no'\n 1.upto(array.size - 1) do |index|\n if array[index - 1] > array[index]\n array[index -1], array[index] = array[index], array[index - 1]\n swaps_made = 'yes'\n end\n end\n break if swaps_made == 'no'\n end\nend",
"def bubble_sort(array)\n# Create a variable equal to the array length\nn = array.length\n loop do\n # Perform a loop:\n # Create a variable 'swapped' that is equal to false; we will set it to true after the pair of values has been swapped.\n swapped = false\n # For each item in the array,\n (n-1).times do |i|\n # If the item is greater than the item whose index is one larger than it,\n if array[i] > array[i+1]\n # Switch the indexes of the two items,\n array[i], array[i+1] = array[i+1], array[i]\n # and set swapped equal to true.\n swapped = true\n end\n end\n\n break if not swapped\n end\n\n # Return the array.\n array\nend",
"def bubble_sort!(array)\n size = array.size\n loop do\n exchange_made = false\n 0.upto(size - 2) do |index|\n if array[index] > array[index + 1]\n temp = array[index + 1]\n array[index + 1] = array[index]\n array[index] = temp\n exchange_made = true\n end\n end\n break unless exchange_made\n end\n \n array\nend",
"def bubble_sort(array)\n n = array.length\n swapped = true\n while swapped\n swapped = false\n (n-1).times do |i|\n if array[i].downcase > array[i+1].downcase\n array[i], array[i+1] = array[i+1], array[i]\n swapped = true\n end\n end\n end\n p array\nend",
"def bubble_sort(array)\r\n #Create a do loop to iterate through the loop\r\n loop do\r\n \t#Make a variable called switch that will switch the numbers as you sort\r\n \t#Set it to false, it will become true if the numbers are not in the right place\r\n switch = false\r\n #MAke a loop inside the other loop\r\n #The length of the array - 1 (To catch last two values as you go through), iterate this many times \r\n (array.length-1).times do |i|\r\n #If the array at the first index is greater value than the one on front of it\r\n if array[i] > array[i+1]\r\n \t#Then it equals one placeholder/index in front/next index spot\r\n \t#It's a larger number and needs to swap\r\n array[i], array[i+1] = array[i+1], array[i]\r\n #Set switch to true\r\n switch = true\r\n #End if statement\r\n end\r\n end\r\n #Break this iteration and go back in line, iterating through if not - switch is false\r\n break if not switch\r\n end\r\n #Return the sorted array\r\n array\r\n #End method\r\nend",
"def jumble_sort(str, alphabet = nil)\n alphabet ||= ('a'..'z').to_a\n arr = str.chars\n sorting = true\n while sorting\n sorting = false\n\n arr.each_with_index do |el, i|\n next if i == (arr.length - 1)\n if alphabet.index(el) > alphabet.index(arr[i+1])\n arr[i], arr[i + 1] = arr[i +1], arr[i]\n sorting = true\n end\n end\n\n end\n arr.join\nend",
"def cocktailsort\n begin\n swapped = false\n # forwards - same as bubblesort\n 0.upto(array.length - 2) do |i|\n # compare each two adjacent elements\n compare(i, i + 1)\n if array[i] > array[i + 1]\n # if the left one is greater, swap them\n swap(i, i + 1)\n #log\n swapped = true\n end\n end\n\n break unless swapped\n\n swapped = false\n # backwards - the reverse of bubblesort\n (array.length - 2).downto(0) do |i|\n compare(i, i + 1)\n if array[i] > array[i + 1]\n swap(i, i + 1)\n #log\n swapped = true\n end\n end\n end while swapped\nend",
"def bubble_sort(arr)\r\n\tchecker = true\r\n\twhile checker\r\n\t\tchecker = false\r\n\t\t0.upto(arr.length-2) do |i|\r\n\t\t\tif arr[i] > arr[i+1]\r\n\t\t\t\tplaceholder = arr[i]\r\n\t\t\t\tarr[i] = arr[i+1]\r\n\t\t\t\tarr[i+1] = placeholder\r\n\t\t\t\tchecker = true\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\treturn arr\r\nend",
"def bubble_sort(arr)\n\n while true\n swapped = false\n arr.each_with_index do |element, index|\n if (index + 1) < arr.length && element > arr[index + 1]\n change = arr[index]\n arr[index] = arr[index + 1]\n arr[index + 1 ] = change\n swapped = true\n end\n end\n if !swapped\n break\n end\n end\n\n arr\nend",
"def bubble_sort(arr)\n count = arr.length\n while count > 1\n count.times do |c|\n if arr[c+1] && arr[c] > arr[c+1]\n arr[c], arr[c+1] = arr[c+1], arr[c]\n end\n end\n count -= 1\n end\n arr\nend"
] |
[
"0.714253",
"0.68042356",
"0.6705065",
"0.6691415",
"0.66607744",
"0.6643696",
"0.66359705",
"0.6635898",
"0.66238976",
"0.66168195",
"0.66065705",
"0.65906596",
"0.65236396",
"0.6516354",
"0.651065",
"0.65013313",
"0.6481619",
"0.6475752",
"0.64713824",
"0.6465773",
"0.6461675",
"0.646003",
"0.6452708",
"0.64516157",
"0.64386547",
"0.64342576",
"0.6430957",
"0.6429139",
"0.6414627",
"0.6407539",
"0.6406573",
"0.63966006",
"0.6393969",
"0.6392686",
"0.63875043",
"0.6376001",
"0.6370248",
"0.6368551",
"0.63654923",
"0.6362314",
"0.63622993",
"0.63613355",
"0.6358221",
"0.63421375",
"0.6340436",
"0.63298595",
"0.6319831",
"0.63192",
"0.6309821",
"0.6304504",
"0.6303902",
"0.6303015",
"0.6293762",
"0.62935853",
"0.6290496",
"0.6288602",
"0.62820745",
"0.6277918",
"0.6277559",
"0.6276254",
"0.6276148",
"0.626334",
"0.62625754",
"0.6254658",
"0.62522525",
"0.62512845",
"0.6249989",
"0.6245576",
"0.62435997",
"0.62381583",
"0.6233282",
"0.62330306",
"0.6223796",
"0.62214243",
"0.62065315",
"0.62053394",
"0.6204803",
"0.62024534",
"0.6200427",
"0.6194677",
"0.6193007",
"0.61925817",
"0.6191964",
"0.61916435",
"0.61908543",
"0.61906606",
"0.6189519",
"0.61845255",
"0.61845255",
"0.6183977",
"0.618213",
"0.61814857",
"0.61810714",
"0.61793226",
"0.6176895",
"0.61766076",
"0.61717427",
"0.6171104",
"0.61588705",
"0.61566085",
"0.6156177"
] |
0.0
|
-1
|
The algorithm finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list. It does no more than n swaps, and thus is useful where swapping is very expensive. O(n^2)
|
def selection_sort(a)
array = a.clone
insert = 0
array.each_index do |i|
min = i
(i+1).upto(array.length-1) do |j|
if array[j] < array[min]
min = j
end
end
array[i], array[min] = array[min], array[i]
end
array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def minimumSwaps(arr)\n right_pointer = arr.count - 1\n count = 0\n min_swaps = 0\n\n while count < arr.count\n arr_value = count + 1\n if (arr[count] != arr_value)\n\n while arr_value != arr[right_pointer]\n right_pointer -= 1;\n end\n\n if right_pointer != count\n arr[count], arr[right_pointer] = arr[right_pointer], arr[count]\n min_swaps += 1\n end\n end\n count += 1\n right_pointer = arr.count - 1\n end\n min_swaps\nend",
"def minimumSwaps(arr)\n arr = arr.map { |n| n - 1 }\n\n i = 0\n counter = 0\n\n while arr[i] != i do\n i += 1 if arr[i] == i\n if arr[i] && arr[i] != i\n arr[arr[i]], arr[i] = arr[i], arr[arr[i]]\n counter += 1\n end\n end\n\n counter\nend",
"def minimumSwaps(arr)\n swaps = 0\n i = 1\n arr.each do |element|\n j = arr.index(i) # i's index\n unless arr[j] == element\n arr[i-1] = arr[j]\n arr[j] = element\n swaps += 1\n end\n i += 1\n end\n return swaps\nend",
"def selection_sort(list)\n (list.size - 1).times do |i|\n min = i # starting min value\n for j in i+1..list.size - 1 # searches all values to right to find min\n min = j if list[j] < list[min] # resets min\n end\n list[min], list[i] = list[i], list[min] # swaps min val with past min val, ignoring already sorted part\n end\n list\nend",
"def minimumSwaps(arr)\n swaps = 0\n alen = arr.length\n index_lookup = {}\n 0.upto(alen-1) do |i|\n index_lookup[arr[i]] = i\n end\n 0.upto(alen-1) do |i|\n if arr[i] == i+1\n # puts \"nothing to do\"\n next\n end\n k = index_lookup[i+1]\n index_lookup[arr[i]] = k\n p [i, k]\n arr[i],arr[k] = arr[k],arr[i]\n swaps +=1\n end\n return swaps\nend",
"def minimumSwaps(arr)\r\n swap_cnt = 0\r\n valid_arr = (1..arr.size).to_a\r\n\r\n until arr == valid_arr do\r\n arr.each_with_index do |elem, i|\r\n if elem > valid_arr[i]\r\n target = arr.index(i+1)\r\n\r\n arr[i] = valid_arr[i]\r\n arr[target] = elem\r\n swap_cnt += 1\r\n end\r\n end\r\n end\r\n\r\n swap_cnt\r\nend",
"def my_min(arr)\n l = arr.length - 1 # constant\n # min = 0 # is this more efficient than swapping? \n (0...l).each do |i| # n times1\n if arr[i] < arr[i+1] # 1\n arr[i], arr[i+1] = arr[i+1], arr[i] # 1\n end\n end\n\n arr.last # 1\nend",
"def bubbleMod(list)\n sorted_list = list\n # for each element\n for i in 0..(list.size - 1)\n changed = false\n for i2 in 1..(list.size - i - 1)\n # swap each higher adjacent value to the right until you can't\n if sorted_list[i2] < sorted_list[i2 - 1]\n value_transfer = sorted_list[i2]\n sorted_list[i2] = sorted_list[i2 - 1]\n sorted_list[i2 - 1] = value_transfer\n changed = true\n end\n end\n return sorted_list if !changed\n end\n return sorted_list\nend",
"def minimumSwaps(arr)\n num_swaps = 0\n index = 0\n min_index = 0\n #while arr.sort != arr\n while index < arr.length-1\n min_index = arr.index(arr[index..arr.length-1].min)\n #if arr[index] > arr[min_index]\n if arr[index] != index+1\n arr.swap(index,min_index)\n num_swaps += 1\n end\n index += 1\n end\n return num_swaps\nend",
"def swap_with_next(n)\n raise IndexError if n < 0 || n >= (@size - 1)\n\n if n == 0\n first = @first_item\n second = first.next_item\n\n first.next_item = second.next_item\n second.next_item = first\n @first_item = second\n else\n current_item = @first_item\n count = n - 1\n count.times do\n current_item = current_item.next_item\n end\n previous = current_item\n first = previous.next_item\n second = first.next_item\n\n previous.next_item = second\n first.next_item = second.next_item\n second.next_item = first\n end\n end",
"def smallest_integer(list_of_nums)\r\n # Your code goes here!\r\n a = list_of_nums.length\r\n \r\n \tloop do \r\n \t\tswapped = false\r\n \t\t\r\n \t\t(a-1).times do |i|\r\n \t\t\tif list_of_nums[i] > list_of_nums[i+1]\r\n \t\t\t\tlist_of_nums[i], list_of_nums[i+1] = list_of_nums[i+1], list_of_nums[i]\r\n \t\t\t\tswapped = true \r\n \t\t\tend\r\n \t\tend\r\n\r\n \t\tbreak if not swapped\r\n \tend\r\n \tsmallest = list_of_nums[0]\r\n \tsmallest\r\n\r\n\r\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def rollYourOwnSort(list)\n for i in 1..(list.length - 1)\n val = list[i]\n j = i - 1\n\n while j >= 0 && list[j] > val\n list[j + 1] = list[j]\n j -= 1\n end\n\n list[j + 1] = val\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index + 1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index + 1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def solution(a)\n len = a.size\n swaps = 0\n i = 0\n while i < len\n smallest = a[i]\n largest = a[i]\n j = i + 1\n while j < len && largest > a[j]\n smallest = a[j] if a[j] < smallest\n j += 1\n end\n i -= 1 while i > 0 && a[i-1] > smallest\n swaps = j - i if j > i + 1\n i = j\n end\n return swaps\nend",
"def rearrangeLastN(l, n)\n return l if n == 0\n fast, slow = l, l\n n.times do\n if fast\n fast = fast.next\n end\n end\n return l unless fast\n while fast.next\n slow = slow.next\n fast = fast.next\n end\n\n result = slow.next\n slow.next = nil\n fast.next = l\n result\nend",
"def bubble_sort!(a)\n n = a.size - 1\n n.times { n.times { |i| a[i], a[i + 1] = a[i + 1], a[i] if a[i] > a[i + 1] } }\nend",
"def block_swap(a,d)\n n=a.length\n if n>0\n \n if d>=n\n d%=n\n end\n \n if d==0\n return a\n end\n\n if d==n-d\n swap(a,0,d,d)\n end\n\n i= d\n j= n-d\n\n while(i!=j)\n if i<j\n swap(a,d-i,d+j-i,i)\n j-=i\n else\n swap(a,d-i,d,j)\n i-=j\n end\n end\n \n swap(a,d-i,d,i)\n end\n \n return a\n \nend",
"def selection_sort(arr)\n size = arr.size\n\n 0.upto(size-1) do |i|\n smallest_one = i\n #Find the min value\n (i+1).upto(size-1) do |j|\n if (arr[j] < arr[smallest_one])\n smallest_one = j\n end\n end\n\n #Swap the elements\n arr[i], arr[smallest_one] = arr[smallest_one], arr[i]\n end\n arr\nend",
"def swap_with_next i\n #if first_item >= first_item.next_list_item\n\n end",
"def smallest_integer(list_of_nums)\n\tlist_of_nums.each do |n1|\n \t\tlist_of_nums.each do |n2|\n \t\t\tif list_of_nums|n2| < list_of_nums|n1| #check if the the second number pulled out of array is smaller than the first\n \t\t\t\tlist_of_nums|n1| , list_of_nums|n2| = list_of_nums|n2| , list_of_nums|n1| #if it is smaller, it is moved in front of the bigger number\n \t\t\tend\n \t\tend\n\tend\n\nreturn list_of_nums[0] #once the smallest number is moved to the front, it should be the smallest in the array. so I call on it.\nend\n\n#I could not get this solution to work for some reason, because it didnt pass rspec. ",
"def swap(a,start1,start2,d)\n for i in 0...d\n temp = a[start1+i]\n a[start1+i] = a[start2+i]\n a[start2+i] = temp\n end\nend",
"def method(x)\r\n swapped = true\r\n while swapped == true\r\n swapped = false\r\n (x.length-1).times do |i|\r\n if x[i] > x[i+1]\r\n x[i], x[i+1] = x [i+1], x[i]\r\n swapped = true\r\n end\r\n end \r\n end \r\n x \r\nend",
"def my_min_2(list) # n\n min_value = list.first\n i = 0\n while i < list.length\n min_value = list[i] if list[i] < min_value\n i += 1\n end\n min_value\nend",
"def block_swap(a, d)\n n = a.length\n if n > 0\n\n if d >= n\n d %= n\n end\n\n if d == 0\n return a\n end\n\n if d == n - d\n swap(a, 0, d, d)\n end\n\n i = d\n j = n - d\n\n while(i != j)\n if i < j\n swap(a, d-i, d+j-i, i)\n j -= i\n else\n swap(a, d-i, d, j)\n i -= j\n end\n end\n\n swap(a, d-i, d, i)\n end\n\n return a\nend",
"def bubble_sort(numbers)\n permutation = nil\n\n while permutation != 0 do # N times\n permutation = 0\n\n numbers.each_with_index do |number, index| # N times\n next if numbers[index + 1].nil?\n\n if number > numbers[index + 1]\n numbers.insert(index + 1, numbers.delete_at(index))\n permutation += 1\n end\n end\n end\n\n numbers\nend",
"def shuffle(nums, n)\n current_index = 1\n (0..n - 1).each do |i|\n nums.insert(current_index, nums.delete_at(i + n))\n current_index += 2\n end\n nums\nend",
"def bubblesort(list)\n return list if list.size <= 1\n\n els = 1\n loop do\n swapped = false\n 1.upto(list.size - els) do |i|\n if list[i - 1] > list[i]\n list[i], list[i - 1] = list[i - 1], list[i]\n swapped = true\n end\n end\n break unless swapped\n els += 1\n end\n\n list\nend",
"def sort(array, length)\n length.times do |index| # outer loop - narray\n min_index = index # assume index is where the next minimally value is\n temp_index = index + 1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1array\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1 # move to next index\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def my_better_min(list)\n min = list[0] #1\n\n list.each_with_index do |ele_1, i| #n\n if ele_1 < min # 1 *n\n min = ele_1 #1 *n\n end\n end\n\n min #1\n # (i...list.length).each do |j|\n # if list[i] list[j]\nend",
"def selection_sort3(array)\n n = array.length\n n.times do |i|\n # assume the min number is the leftmost one, until proven otherwise\n minimum_index = i\n # checking all the digits to the right of i\n ((i + 1)..n - 1).each do |j|\n # if one of those digits is smaller than the one at i, we have a new min\n minimum_index = j if array[j] < array[minimum_index]\n end\n # once the min has been found, we swap it with the leftmost one.\n array[i], array[minimum_index] = array[minimum_index], array[i]\n p array\n end\n array\nend",
"def selection_sort(list)\n (0...list.size - 1).each do |i|\n min = i\n (i + 1...list.size).each do |j|\n if list[j] < list[min]\n min = j\n end\n end\n temp = list[min]\n list[min] = list[i]\n list[i] = temp\n end\n list\n end",
"def bubble_sort(list)\n return list if list.size <= 1 # already sorted\n swapped = true\n while swapped do\n swapped = false\n 0.upto(list.size-2) do |i|\n if list[i] > list[i+1]\n list[i], list[i+1] = list[i+1], list[i] # swap values\n swapped = true\n end\n end\n end\n\n list\nend",
"def bubble_sort(list)\n loop do\n swapped = false\n\n (list.size - 1).times do |i|\n if list[i] > list[i+1] # if current > next\n list[i], list[i+1] = list[i+1], list[i] # swap current and next values\n swapped = true\n end\n end\n\n # if swap happened, return to start and scans whole list again from left to right\n # else we're done\n break unless swapped \n end\n list\nend",
"def shift_left2(list)\n list_new = list\n i = 0\n first = list[0]\n\n list.size.times do |i|\n list_new[i] = list[i + 1]\n i += 1\n end\n list_new[list.size - 1] = first\n\n return list_new\n\nend",
"def bubble_sort(list)\n return list if list.size <= 1\n\n\tloop do\n\t swapped = false\n\t 0.upto(list.size-2) do |n|\n\t if list[n] > list[n+1]\n\t \tlist[n], list[n+1] = list[n+1], list[n]\n\t \tswapped = true\n\t end\n\t end\n\t break unless swapped\n\tend\n\tlist\nend",
"def bubble_sort(list)\n\n loop do\n count = 0\n\n # Go through the list and swap values if needed\n list.each_index do |idx|\n if idx + 1 < list.length && list[idx] > list[idx + 1]\n count += 1\n temp = list[idx + 1]\n list[idx + 1] = list[idx]\n list[idx] = temp\n end\n end\n\n # Loop until there no more values to swap (list is sorted)\n break if count == 0\n end\n\n list\nend",
"def insertion_sort(list)\n for i in 1..list.size - 1\n j = i - 1\n while j >=0 and list[j+1] < list[j] # if current < previous\n list[j], list[j+1] = list[j+1], list[j] # swap previous and current values. faster.\n\n# list[j+1] = list[j] --- typical book way. slower.\n j -= 1\n end\n# list[j+1] = current --- typical book way. slower.\n end\n list\nend",
"def wiggle_sort(nums)\n nums = nums.sort!\n\n greater_num_idx = nums.length / 2\n lesser_num_idx = 1\n\n until lesser_num_idx >= greater_num_idx\n nums[lesser_num_idx], nums[greater_num_idx] = nums[greater_num_idx], nums[lesser_num_idx]\n lesser_num_idx += 2\n greater_num_idx += 1\n end\n nums\nend",
"def my_min_fast(list)\n smallest = list.first\n\n list[1..-1].each { |n| smallest = n if n < smallest }\n smallest\nend",
"def bubble_sort(items) # assume 10 items\n n = items.size\n iterations = 0\n loops = 0\n loop do\n swapped = false\n for a in (1..(n - 1)) do # 1 to (number of items - 1)\n if items[a] < items[a - 1] \n tmp = items[a - 1]\n items[a - 1] = items[a]\n items[a] = tmp\n swapped = true\n end\n iterations += 1 # debug: loop counter\n end\n n -= 1 # optimization, halfs the time by doing one less inner loop for each addtinal outer loop\n loops += 1 # debug: loop counter\n break unless swapped\n end\n p \"Total iterations: #{iterations}\"\n p \"loops: #{loops}\"\n items\nend",
"def bubble_sort!(array)\n n = array.size\n \n loop do\n swap_made = false\n\n (1..n).each do |idx|\n if (array[idx - 1] <=> array[idx]) == 1\n array[idx - 1], array[idx] = array[idx], array[idx - 1]\n swap_made = true\n end\n end\n\n n -= 1\n\n break if swap_made == false\n end\n\n array\nend",
"def bubble_sort_2(items)\n n = items.size\n iterations = 0\n \n for a in (0...n) do # same as (0...n).each do |a| ..... end\n swapped = false\n for b in (0...(n - a - 1)) do\n if items[b] > items[b + 1] \n tmp = items[b + 1]\n items[b + 1] = items[b]\n items[b] = tmp\n swapped = true\n end\n iterations += 1\n end\n break unless swapped\n end\n p \"Total iterations: #{iterations}\"\n items\nend",
"def bubble_sort(list)\n\tloop do \n\t\tswapped = false\n\t\t(list.size-1).times do |i|\t\t\t\n\t\t\tif list[i] > list[i+1]\n\t\t\t\tlist[i], list[i+1] = list[i+1], list[i]\n\t\t\t\tswapped = true\t\t\t\t\n\t\t\tend\t\t\t\n\t\tend\n\t\tbreak unless swapped\n\tend \n\tlist \nend",
"def select_sort(x)\n\n smallest = 0\n\n x.length().times do |index|\n smallest = index\n (index..x.length()-1).each do |check|\n if x[check] < x[smallest]\n smallest = check\n end\n end\n temp = x[index]\n x[index] = x[smallest]\n x[smallest] = temp\n end\n\n return x\nend",
"def my_min(list)\n\n # phase 1\n # min = list.first\n # list.each_with_index do |ele_1, i_1|\n # list.each_with_index do |ele_2, i_2|\n # if i_2 != i_1\n # if min > ele_2\n # min = ele_2\n # end\n # end\n # end\n # end\n # min\n\n # phase 2\n min = list.first\n list[1..-1].each do |ele|\n if min > ele\n min = ele\n end\n end\n min\nend",
"def bubble_sort(arr)\n n = arr.length\n #ln 7, array length is my set of four numbers\n\n loop do\n #[2, 42, 22, 02]\n #[42, 2, 22, 02]\n #[42, 22, 2, 02]\n #[42, 22, 02, 2]\n\n swapped = false\n\n (n-1).times do |i|\n if arr[i] > arr [i + 1]\n arr [i], arr[i +1] = arr [i +1], arr[i]\n swapped = true\n end\n end\n\n #ln18 iterator variable is i, i +1 is the next number beside it \n #ln 19 is the rule to swap, we do this by equalling the values to the opposite one, that is how we swap \n #when accessing something within an element it needs an index\n\n break if not swapped \n #break will break us out of the loop but only if swapped is not true\n end\n\n arr\n\nend",
"def selection_iterative(a)\n # When all the smallest elements are sorted, the last \n # one will be the biggest.\n (a.length-1).times do |i|\n smallest = i\n (i...a.length).each do |j|\n if a[j] < a[smallest]\n smallest = j\n end\n end\n a[smallest], a[i] = a[i], a[smallest] #swap\n end\n return a\nend",
"def bubble_sort_by(array)\n\tfinal_list = array.clone\n\titerations = (array.length - 1) ** 2\n\ti = 0\n\n\titerations.times do |x|\n\n swap = yield(final_list[i], final_list[i+1])\n \tif swap == -1\n \t\tif i >= array.length - 2\n \t\t i = 0\n \t\telse\n \t\t\ti += 1\n \t end\n \telsif swap == 1\n \t\tfinal_list[i], final_list[i+1] = final_list[i+1], final_list[i]\n \t\t\tif i >= array.length - 2\n \t\t \ti = 0\n \t\t\telse\n \t\t\t\ti += 1\n \t\t\tend\n \telse\n \t if i >= array.length - 2\n \t\t i = 0\n \t\telse\n \t\t\ti += 1\n \t\tend\n \tend\n end\n puts final_list\nend",
"def bubble_sort!(arr)\n n = arr.size - 1\n loop do\n no_swap = true\n 1.upto(n) do |idx|\n if arr[idx - 1] > arr[idx]\n arr[idx - 1], arr[idx] = arr[idx], arr[idx - 1]\n no_swap = false\n else\n next\n end\n end\n n -= 1\n break if no_swap\n end\nend",
"def first_n_smallest_x(arr, n)\n arr.delete_at(arr.rindex(arr.max)) while (arr.size > n) ; arr\nend",
"def swap(list, src, dst)\n\t\tswap = list[dst]\n\t\tlist[dst] = list[src]\n\t\tlist[src] = swap\n\tend",
"def bubble_sort(array)\n n = array.length\n loop do\n swapped = false\n (n-1).times do |i|\n if array[i] > array [i + 1]\n # temp = array[i]\n # array[i], = array[i+1]\n # array[i+1] = temp\n #lines 14-17 are equivalent to line 19 below\n array[i], array[i+1] = array[i+1], array[i]\n swapped = true\n end\n end\n break if not swapped\n end\n array\nend",
"def swap_pass\n self.to_enum.with_index.each do |elt, index|\n best_swap_index = index\n best_interval_length = self.interval_length\n self.to_enum.with_index.each do |swapper, swapdex|\n # Test the array out with the current element ``elt`` and ``swapper`` switched\n self[index] = swapper\n self[swapdex] = elt\n interval_length = self.interval_length\n\n if interval_length < best_interval_length\n best_interval_length = interval_length\n best_swap_index = swapdex\n end\n\n # change the array back to how it originally was\n self[index] = elt\n self[swapdex] = swapper\n end\n # Having tested every element, we know where to place ``elt`` to minimize the interval\n self[index] = self[best_swap_index]\n self[best_swap_index] = elt\n end\n end",
"def shell_sort(list)\n gap = list.size / 2\n while gap > 0 do\n for i in gap..list.size - 1 \n j = i \n while j >= gap and list[j] < list[j-gap] # if current < previous. previous = gap values to the left\n list[j], list[j-gap] = list[j-gap], list[j] # swap current and previous\n j -= gap # keep swapping current and previous until previous > current\n end\n end\n gap = gap / 2\n end\n list\nend",
"def swap_elements(array)\n array.insert(1,array.delete_at(2))\nend",
"def heap_sort2(a)\r\n size = a.length\r\n temp = 0\r\n i = (size/2)-1\r\n\r\n while i >= 0\r\n sift_down(a,i,size)\r\n i-=1\r\n end\r\n\r\n i=size-1\r\n while i >= 1\r\n a[0], a[1] = a[1], a[0]\r\n sift_down(a, 0, i-1)\r\n i-=1\r\n end\r\n return a\r\nend",
"def swap_elements(array)\n array.insert(1, array.delete_at(2))\nend",
"def insertionsort! arr\n (1..arr.size - 1).each do |i|\n j = i\n while j > 0 && arr[j] < arr[j - 1] do\n arr[j], arr[j - 1] = arr[j - 1], arr[j]\n j -= 1\n end\n end\n arr\nend",
"def adhoc_sort_5(list)\n list = swap(list, 0, 1) if list[0] > list[1]\n list = swap(list, 2, 3) if list[2] > list[3]\n list = list[2..3] + list[0..1] + [list[4]] if list[0] > list[2]\n # list is now of form [a, b, c, d, e] with a < c < d\n x_list = insert([list[0]] + list[2..3], list[4]) # insert e into [a, c, d]\n # xlist is one of: [a, c, d, e], [a, c, e, d], [a, e, c, d], [e, a, c, d]\n return [x_list[0]] + insert(x_list[1..3], list[1]) # insert b into last 3 elements of x_list\n end",
"def bubble_sort(array)\n n = array.length\nswap_count=0\nswap=1\n until swap_count == swap\n swap_count=swap\n (n-1).times do |i|\n if array[i] > array[i+1]\n array[i], array[i+1] = array[i+1], array[i]\n swap+=1\n end\n end\n end\n array\nend",
"def my_min(arr)\n sorted = false \n while !sorted \n sorted = true \n (0...arr.length-1).each do |i|\n if arr[i] < arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n sorted = false \n end \n end \n end \n arr[-1]\nend",
"def shift_left(list)\n list_new = list\n i = 0\n first = list[0]\n\n list.size.times do \n list_new[i] = list[i +1]\n i += 1\n end \n list_new[list.size - 1] = first\n\n return list_new\n \nend",
"def reverse!(list)\n count = 0\n\n list.size.times do\n list.insert(count, list.pop)\n count += 1\n end\n\n list\nend",
"def bubble_sort_by(input)\r\n sorted = false\r\n last_index = input.length-2\r\n until sorted\r\n swaps = 0\r\n 0.upto(last_index) do |i|\r\n if yield(input[i], input[i+1]) < 0\r\n input[i],input[i+1] = input[i+1],input[i]\r\n swaps += 1\r\n end\r\n end\r\n sorted = true if swaps == 0\r\n last_index -= 1\r\n end\r\n input\r\nend",
"def partitionList list, x\n prev = list.head\n node = prev.next\n\n while node\n if (node.val < x)\n prev.next = node.next\n node.next = list.head\n list.head = node\n node = prev.next\n else\n prev = prev.next\n node = prev ? prev.next : nil\n end\n end\nend",
"def remove_smallest(numbers)\n return numbers if numbers.empty?\n numbers.clone.tap { |i| i.delete_at(numbers.index(numbers.min)) }\n end",
"def bubble(list)\n return nil if list.empty?\n sorted = false \n \n until sorted\n sorted = true \n \n (list.length - 1).times do |idx|\n \n if list[idx] > list[idx + 1]\n list[idx], list[idx + 1] = list[idx + 1], list[idx]\n sorted = false\n end \n end \n end\n \n list[0]\nend",
"def shift_left(list)\n overflow = 0\n overflow = list[0]\n point = 0\n list.size.times do\n list[point] = list[point + 1]\n point += 1\n end\n list[list.size - 1] = overflow\n return list\nend",
"def bubble_sort (a)\n n = a.length;\n for i in 1..n-1\n flag = 0\n for k in 0..n-i-1\n if (a[k+1] < a [k])\n #swap elements\n temp = a[k]\n a[k] = a[k+1]\n a[k+1] = temp\n flag = 1\n end\n end\n if(flag == 0 )\n break;\n end\n end\nend",
"def bubbleSort(list)\n\n # Get the size of the list\n arraySize = list.size\n\n loop do\n\n # Set the default value of swapped to false\n swapped = false\n\n # Go through the list One by One\n (arraySize - 1).times do |i|\n\n # Check if the previous element on the list\n # is greater than the next one\n if (list[i] > list[i+1])\n\n # if the condition is true\n # Swappe the two selected number using\n # Parallel Assignement\n list[i], list[i+1] = list[i+1], list[i]\n\n # Set swapped to true, if there are non checked\n # elements on the list\n swapped = true\n\n end\n\n end\n\n # No swapping left\n break if not swapped\n end\n\n # Return the Sorted Array\n list\n end",
"def bubble_sort_by(arr)\n n = arr.length\n (n-1).times do\n switched = false\n (n-1).times do |i|\n if yield( arr[i], arr[i+1] ) > 0\n arr[i], arr[i+1] = arr[i+1], arr[i]\n switched = true\n end\n end\n break unless switched\n n -= 1 \n end\n return arr\n\nend",
"def bubble_sort array\n n = array.length\n \n while n > 0 \n swapped = 0\n index = 1\n while index < n\n if array[index - 1] > array[index]\n swapped = index\n array.insert(index - 1, array[index])\n array.delete_at(index + 1)\n end\n index+=1\n end\n n = swapped\n end\n \n return array\nend",
"def swap(index1, index2, list)\n temp = list[index1]\n list[index1] = list[index2]\n list[index2] = temp\nend",
"def bubble_sort(arr)\n n = arr.length\n\n loop do \n swapped = false\n (n-1).times do |item|\n if arr[item] > arr[item +1]\n arr[item], arr[item+1] = arr[item +1], arr[item]\n swapped = true\n end\n end \n break if swapped == false\n end\n arr \nend",
"def first_n_smallest(arr, n)\n arr.each_with_index.min(n).sort_by(&:last).map(&:first)\nend",
"def quick_sort(lst)\n return lst if lst.length <= 1\n pivot = lst.shuffle.shift\n left, right = lst.partition {|val| val < pivot}\n quick_sort(left) + quick_sort(right)\nend",
"def bubble_sort(numbers)\r\n sorted = false\r\n last_index = numbers.length-2\r\n until sorted\r\n swaps = 0\r\n 0.upto(last_index) do |i|\r\n if numbers[i] > numbers[i+1]\r\n numbers[i],numbers[i+1] = numbers[i+1],numbers[i]\r\n swaps += 1\r\n end\r\n end\r\n sorted = true if swaps == 0 #optimisation 1\r\n last_index -= 1 #optimisation 2\r\n end\r\n numbers\r\nend",
"def bubble_sort(list) \n list = list.dup \n for i in 0...list.length \n for j in 0..(list.length - 2) \n list[j], list[j + 1] = list[j + 1], list[j] if list[j + 1] < list[j] \n end \n end \n return list \nend",
"def bubble_sort(arr)\n swap = -1\n while swap != 0\n swap = 0\n n = arr.size - 1\n n.times do |i|\n next unless arr[i] > arr[i + 1]\n swap += 1\n arr[i], arr[i + 1] = arr[i + 1], arr[i]\n end\n end\n arr\nend",
"def minimum_rearranged_drinks(drinks)\n\n # if there is only one drink then \n # Tux only drinks one \n n = drinks.length\n if n == 1\n return 1\n end\n\n n -= 1\n\n count = 0\n i = 0\n while i < n\n # get current max and delete it from array\n i += drinks.max\n drinks.delete_at(drinks.index(drinks.max))\n\n # i >= n means we are done but we must add\n # the final drink at the end so add 2\n # otherwise add one for that drink\n if i >= n \n count += 2\n else\n count += 1\n end\n end\n\n return count\n\nend",
"def insertion_sort(list)\n (1...list.length).each do |i|\n k = i\n while k > 0 && list[k] < list[k-1]\n list[k], list[k-1] = list[k-1], list[k]\n k -= 1\n end\n end\n list\nend",
"def bubble_sort(array)\n n = array.length\n\n loop do\n # [1, 4, 1, 3, 4, 1, 3, 3]\n # [1, 1, 4, 3, 4, 1, 3, 3]\n # [1, 1, 3, 4, 4, 1, 3, 3]\n # [1, 1, 3, 4, 4, 1, 3, 3]\n\n swapped = false\n\n (n-1).times do |i|\n if array[i] > array[i + 1]\n array[i], array[i + 1] = array[i + 1], array[i]\n swapped = true\n end\n end\n\n break if not swapped\n end\n\n array\nend",
"def countSwaps(a)\n # p a\n swaps = 0\n alen = a.length\n (alen-2).downto(0) do |h|\n sorted = true\n 0.upto(h) do |i|\n if a[i] > a[i+1]\n a[i],a[i+1]=a[i+1],a[i]\n swaps +=1\n sorted = false\n end\n end\n break if sorted\n end\n\n puts \"Array is sorted in #{swaps} swaps.\"\n puts \"First Element: #{a[0]}\"\n puts \"Last Element: #{a[-1]}\"\nend",
"def phase_1_min(list)\n smallest = 0\n list.each_with_index do |num1, indx1|\n list.each_with_index do |num2, indx2|\n next if indx1 == indx2\n smallest = num1 if num1 < num2 && num1 < smallest\n end\n end\n smallest\nend",
"def sort(sequence)\n\n made_a_swap = true\n swaps = 0\n loops = 0\n\n def swap(counter, sequnce)\n temp = sequnce[counter]\n sequnce[counter] = sequnce[counter + 1]\n sequnce[counter + 1] = temp\n end\n\n\n while made_a_swap do\n counter = 0\n made_a_swap = false\n\n while counter < sequence.length - 1 #&& !made_a_swap\n\n if sequence[counter] > sequence[counter + 1]\n made_a_swap = true\n swaps += 1\n swap(counter, sequence)\n end\n\n\n counter += 1\n end\n\n print \"#{loops} \" if loops % 1000 == 0\n loops += 1\n end\n\nend",
"def swap_elements(array)\n\n array[1], array[2] = array[2], array[1]\n array\n #swap_elements_from_to(array, 1, 2)\nend",
"def my_min(list)\n i = 0\n min = list[0]\n while i < list.length - 1\n if list[i + 1] < min\n min = list[i + 1]\n end\n i += 1\n end\n min\nend",
"def bubble_sort_by(array)\n swap_status = nil\n iterations = 0\n\n until swap_status == false\n swap_status = false\n working_array = array[0..((array.count - 1) - iterations)]\n working_array.each_with_index do |item, index|\n if item != working_array.last\n if yield(array[index], array[index + 1]) < 0\n array[index], array[index + 1] = array[index + 1], array[index]\n swap_status = true\n end\n end\n end\n iterations += 1\n end\n array\nend",
"def my_min(list)\r\n list.inject { |min,ele| min < ele ? min : ele }\r\n \r\n # Time : O(n)\r\n # Space : O(1)\r\nend",
"def remove_duplicates(list)\n list.sort!\n first_element = list.first\n previous_element = list.first\n list[1..-1].map do |element|\n element = nil if element == previous_element\n previous_element = element\n end.compact.unshift(list.first)\nend",
"def bubble(array)\n n = array.length\n loop do\n swapped = false\n\n (n-1).times do |i|\n if array[i] > array[i+1]\n array[i], array[i+1] = array[i+1], array[i]\n swapped = true\n end\n end\n break if not swapped\n end\n array\nend",
"def selection_sort(values)\n\n # Don't write for loops this way! Use the idiomatic values.each I'll show you in a minute.\n for i in 0..(values.count - 1)\n min_loc = i\n for j in (i + 1)..(values.count - 1)\n min_loc = j if yield(values[j], values[min_loc])\n end\n\n # swap values[i] and values[min_loc]\n temp = values[i]\n values[i] = values[min_loc]\n values[min_loc] = temp\n end\n values\nend"
] |
[
"0.7286574",
"0.714893",
"0.7144403",
"0.70495",
"0.7037709",
"0.69782263",
"0.6831456",
"0.66656256",
"0.6605443",
"0.6536429",
"0.64243",
"0.6414984",
"0.63978267",
"0.638463",
"0.638463",
"0.638463",
"0.638463",
"0.638463",
"0.638463",
"0.638463",
"0.63690674",
"0.63690674",
"0.6248678",
"0.6225396",
"0.6193925",
"0.61898184",
"0.61670446",
"0.6164055",
"0.6163298",
"0.61592436",
"0.6150778",
"0.61488026",
"0.6146931",
"0.61418706",
"0.61241305",
"0.61110646",
"0.61092955",
"0.60963094",
"0.6077097",
"0.60612106",
"0.60505784",
"0.60209686",
"0.60195005",
"0.6017667",
"0.6015208",
"0.59990805",
"0.59796363",
"0.59658235",
"0.59589565",
"0.5949539",
"0.59441453",
"0.5938578",
"0.59311527",
"0.59234107",
"0.5921637",
"0.5921394",
"0.5919896",
"0.59157616",
"0.58846027",
"0.58648825",
"0.5863912",
"0.58624315",
"0.58602154",
"0.58556247",
"0.5837558",
"0.5837318",
"0.5837023",
"0.5809939",
"0.5804157",
"0.5785199",
"0.57779205",
"0.5777065",
"0.5772079",
"0.5769741",
"0.57672447",
"0.5766897",
"0.5761808",
"0.573604",
"0.5727156",
"0.5725242",
"0.5722772",
"0.57202566",
"0.57190347",
"0.5718845",
"0.57034415",
"0.56940734",
"0.56933",
"0.56779224",
"0.5675218",
"0.5675072",
"0.56686896",
"0.56648844",
"0.5663483",
"0.56592953",
"0.5654154",
"0.5643453",
"0.5641923",
"0.5638071",
"0.5636319",
"0.56352586",
"0.5635082"
] |
0.0
|
-1
|
Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly sorted lists, and often is used as part of more sophisticated algorithms. It works by taking elements from the list one by one and inserting them in their correct position into a new sorted list. In arrays, the new list and the remaining elements can share the array's space, but insertion is expensive, requiring shifting all following elements over by one. O(n^2)
|
def insertion_sort(a)
array = a
1.upto(array.length-1) do |i|
if array[i] < array[i-1]
# need to shift everything over until it isn't
i.downto(1) do |j|
if array[j] < array[j-1]
array[j], array[j-1] = array[j-1], array[j]
end
end
end
end
array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def insertion_sort(list)\n return list if list.size < 2\n\n (1...list.length).each do |i|\n j = i - 1\n e_next = list[i]\n while j >= 0 and list[j] > e_next\n list[j + 1] = list[j]\n j -= 1\n end\n list[j + 1] = e_next\n end\n list\n end",
"def insertion_sort(list)\n (1...list.length).each do |i|\n k = i\n while k > 0 && list[k] < list[k-1]\n list[k], list[k-1] = list[k-1], list[k]\n k -= 1\n end\n end\n list\nend",
"def insertion_sort(a)\n a.each_with_index do |el,i|\n # Insert el into the sorted sublist\n j = i - 1\n while j >= 0\n break if a[j] <= el\n a[j + 1] = a[j]\n j -= 1\n end\n a[j + 1] = el\n\n end\nend",
"def insertion_sort(array)\n # Takes n passes here.\n (1...array.size).each{ |i|\n j = i\n # and this also takes n, but the distance of the count decreases\n # each time.\n while j > 0 and array[j - 1] > array[j]\n temp = array[j]\n array[j] = array[j-1]\n array[j-1] = temp\n\n j -= 1\n end\n }\n array\nend",
"def insertion_sort(a)\n for i in 1...(a.length)\n\n while i>0\n if a[i] < a[i-1]\n temp = a[i-1]\n a[i-1] = a[i]\n a[i] = temp\n else\n break\n end\n i = i-1\n end\n end\n return a\nend",
"def insertionSort(array)\n\tarray.each_with_index do |element, index|\n i = 0\n position = index\n\n\t while (position > 0)\n\t \tposition -= 1\n\t \n\t \tif element < array[position]\n array[position+1]= array[position]\n\t \t\tarray[position]=element\n\t \telse \n\t \t break\n end\n \n\t end\t\n end\nend",
"def insertion_sort(array)\n (1..array.length - 1).to_a.each do |index|\n tmp_value = array[index]\n position = index - 1\n\n while position >= 0 do\n if array[position] > tmp_value\n array[position + 1] = array[position]\n position = position - 1\n else\n break\n end\n end\n\n array[position + 1] = tmp_value\n end\n\n return array\nend",
"def insertion_sort(list)\n for i in 1..list.size - 1\n j = i - 1\n while j >=0 and list[j+1] < list[j] # if current < previous\n list[j], list[j+1] = list[j+1], list[j] # swap previous and current values. faster.\n\n# list[j+1] = list[j] --- typical book way. slower.\n j -= 1\n end\n# list[j+1] = current --- typical book way. slower.\n end\n list\nend",
"def insertion_sort(array)\n binding.pry\n (1..array.length - 1).each do |n|\n number_to_insert = array[n]\n j = n - 1\n while array[j] > number_to_insert && j >= 0\n array[j + 1] = array[j]\n j -= 1\n end\n array[j + 1] = number_to_insert\n end\n array\nend",
"def insertion_sort(a)\n\tfor i in 1...(a.length)\n\t\tj=i\n\t\twhile j>0\n\t\t\tif a[j-1]>a[j]\n\t\t\t\ttemp=a[j]\n\t\t\t\ta[j]=a[j-1]\n\t\t\t\ta[j-1]=temp\n\t\t\telse\n\t\t\t\tbreak\n\t\t\tend \n\t\t\tj=j-1\n\t\tend\n end \n return a \nend",
"def insertion_sort(array)\n array.length.times do |i|\n while i > 0\n if array[i - 1] > array[i]\n array[i], array[i - 1] = array[i - 1], array[i]\n end\n i -= 1\n end\n end\n array\nend",
"def insertion_sort(array) \r\narray.each_with_index do |el,i| \r\n j = i - 1 \r\n while j >= 0 \r\n break if array[j] <= el \r\n array[j + 1] = array[j] \r\n j -= 1 \r\n end \r\n array[j + 1] = el \r\nend \r\nend",
"def insertion_sort(arr)\n step = arr.size - 1\n \n 1.upto(step).each do |i|\n current = arr[i]\n index = i\n \n (i-1).downto(0).each do |j|\n break if arr[j] < current\n \n arr[j], arr[j+1] = arr[j+1], arr[j]\n index = j\n end\n \n arr[index] = current\n end\n \n arr\nend",
"def insertion_sort(arr)\n arr.each_with_index do |_, i|\n j = 0\n while j < i\n if arr[i] < arr[j]\n reposition(arr, i, j)\n break\n end\n j += 1\n end\n end\n end",
"def insertion_sort(arr)\n\t(arr.length - 1).times do |n|\n\t\tcurrent_place = n + 1\n\t\twhile arr[current_place - 1] > arr[current_place] && current_place > 0 do\n\t\t\tswap(arr, current_place - 1, current_place)\n\t\t\tcurrent_place -= 1\n\t\tend\n\tend\n\treturn arr\nend",
"def insert_sort(array)\n for i in 1..(array.length - 1)\n j = i\n while j > 0 && array[j] < array[j - 1]\n swap(j, j-1, array)\n j -= 1\n end\n end\n return array\n\nend",
"def insertion_sort(arr)\n\tn = arr.length\n\t(1...n).each do |i|\n\t\tj = i\n\t\twhile arr[j] < arr[j-1] #&& j >= 1\n\t\t\tx = arr[j]\n\t\t\tarr[j] = arr[j-1]\n\t\t\tarr[j-1] = x\n\t\t\tj -= 1\n\t\t\tbreak if j == 0\n\t\tend\n\tend\n\treturn arr\nend",
"def insertionSort(input)\n for j in 1..input.length - 1\n temp = input[j]\n i = j - 1\n\n while i >= 0 && input[i] > temp\n input[i + 1] = input[i]\n i -= 1\n end\n input[i + 1] = temp\n end\n return input\nend",
"def insertion_sort(arr)\n (arr.length - 1).times do |index|\n index += 1\n position = index\n temp_value = arr[index]\n\n while position > 0 && arr[position - 1] > temp_value\n arr[position] = arr[position - 1]\n position -= 1\n end\n arr[position] = temp_value\n end\n arr\nend",
"def insertion_sort!(array)\n array.each_with_index do |el, i|\n j = i\n j -= 1 while j > 0 && el < array[j-1]\n array[i] = array[i-1] and i -= 1 while i > j\n array[j] = el\n end\n\n array\nend",
"def insertion_sort(arr)\n\t1.upto(arr.length - 1) do |n|\n\t\tinsert_me = arr[n]\n\n\t\tuntil arr[n - 1] < insert_me || (n - 1) < 0\n\t\t\tarr[n] = arr[n - 1]\n\t\t\tarr[n - 1] = insert_me\n\n\t\t\tn -= 1\n\t\tend\n\tend\n\n\treturn arr\nend",
"def insertion_sort(n,a)\n puts \"Insertion Sort\"\n for i in 1..n-1\n k = a[i]\n j = i-1\n while j>=0 && k < a[j] do\n a[j+1] = a[j]\n j = j-1\n end\n a[j+1] = k\n end\n for i in 0..n-1\n print a[i]\n end\n print \"\\n\"\nend",
"def insertion_sort(array=@base)\n 1.upto(array.size-1) do |index1|\n num = array[index1]\n index2 = index1 - 1\n while index2 >= 0 && array[index2] > num do\n array[index2+1] = array[index2]\n index2 -= 1\n end\n array[index2+1] = num\n end\n array\n end",
"def insertion_sort(array)\n for i in 1..(array.length - 1)\n while i > 0 && array[i-1] > array[i]\n array[i], array[i-1] = array[i-1], array[i]\n i -= 1\n end\n end\nend",
"def insertion_sort_two(arr)\n 1.upto(arr.length - 1) do |i|\n value = arr.delete_at(i)\n j = i - 1\n j -= 1 while j >= 0 && value < arr[j]\n arr.insert(j + 1, value)\n end\n arr\nend",
"def insertion_sort(arr)\n len = arr.length\n for i in 0..len-1\n j = i\n while (j > 0 && arr[j-1] > arr[j])\n swap(arr,j,j-1)\n j = j-1\n end\n end\n return arr\nend",
"def insertionsort! arr\n (1..arr.size - 1).each do |i|\n j = i\n while j > 0 && arr[j] < arr[j - 1] do\n arr[j], arr[j - 1] = arr[j - 1], arr[j]\n j -= 1\n end\n end\n arr\nend",
"def insertion_sort(unsorted_array)\n i = 1\n n = unsorted_array.length\n\n while i < n\n key = unsorted_array[i]\n j = i - 1\n while j >= 0 && unsorted_array[j] > key\n unsorted_array[j+1] = unsorted_array[j]\n j -= 1\n end\n unsorted_array[j+1] = key\n i += 1\n end\n unsorted_array\nend",
"def insertion_sort(array)\n array.each_with_index do |item, index|\n new_card = array[index]\n @index_position = index\n array[0..index].each_with_index do |_item, index_2|\n next if index == 0\n compare_index = index - index_2\n if new_card < array[index - index_2]\n array.insert(compare_index, array.delete_at(@index_position))\n p \"Intermediate array step: #{array}\"\n @index_position = compare_index\n end\n end\n p array\n end\nend",
"def insertion_sort(array)\n return array if array.size < 2 \n\n for k in (1...array.size)\n for i in (0...k)\n if array[i] > array[k]\n swap(array, i, k)\n end \n end\n end\n array\nend",
"def insertionSort(arr)\n \n return 0 if arr.count <= 1\n\n arr_size_index = arr.size-1\n count_shifts = 0\n\n for i in 0..arr_size_index\n\n break if i == arr_size_index\n \n if arr[i] > arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n count_shifts+=1\n end\n\n j = i\n\n while (j > 0) && arr[j-1] > arr[j]\n arr[j], arr[j-1] = arr[j-1], arr[j]\n j -=1\n count_shifts+=1\n end\n\n end\n\n count_shifts\nend",
"def insertion_sort(array)\n (1...array.size).each do |i|\n value = array[i]\n j = i - 1\n\n while j >= 0 && array[j] > value\n array[j + 1] = array[j] # shift the value to the right\n j -= 1\n end\n\n array[j + 1] = value # `j + 1` is equal to `i` if the `while` wasn't entered\n end\n\n array\nend",
"def insertion_sort(numbers)\n # Iterate through the length of the array,\n # beginning with the second element numbers[i].\n (1...numbers.length).each do |i|\n key = numbers[i]\n j = i - 1\n\n # If element to left of key is larger then\n # move it one position over at a time.\n while (j >= 0) && (numbers[j] > key)\n numbers[j + 1] = numbers[j]\n j -= 1\n end\n\n # Update key position.\n numbers[j + 1] = key\n puts numbers.inspect\n end\n\n # Return sorted array.\n numbers\nend",
"def insertion_sort(array)\t\t\t\t\t\t\t\t\t\t\t\t#This is not my code. I do not understand this code. I tried very hard to understand it but could not.\r\n final = [array[0]]\r\n array.delete_at(0)\r\n # main code\r\n for i in array\r\n final_index = 0\r\n while final_index < final.length\r\n if i <= final[final_index]\r\n final.insert(final_index,i)\r\n break\r\n elsif final_index == final.length-1\r\n final.insert(final_index+1,i)\r\n break\r\n end\r\n final_index+=1\r\n end\r\n end\r\n # output\r\n final\r\nend",
"def insertionSort(array)\n temp = 0\n l = array.length - 1\n (1..l).each do |i|\n j = i\n j.downto(1) do |j|\n if array[j] < array[j-1]\n temp = array[j]\n array[j] = array[j-1]\n array[j-1] = temp\n end\n end\n end\n puts \"Sorted array:\"\n puts array\nend",
"def insertion_sort(array)\n\tfinal = [array[0]]\n\tarray.delete_at(0)\n\t#main code\n\tfor i in array\n\t\tfinal_index = 0\n\t\twhile final_index < final.length\n\t\t\tif i <= final[final_index]\n\t\t\t\tfinal.insert(final_index, i)\n\t\t\t\tbreak\n\t\t\telsif \n\t\t\t\tfinal_index == final.length-1\n\t\t\t\tfinal.insert(final_index+1, i)\n\t\t\t\tbreak \n\t\t\tend\n\t\t\tfinal_index +=1\n\t\tend\n\tend\n\t#output\n\tfinal\nend",
"def insertion_sort(array)\n for index in (1...array.size)\n stored_value = array[index]\n gap = index\n while array[gap - 1] > stored_value && gap - 1 >= 0\n array[gap] = array[gap - 1]\n gap -= 1\n end\n array[gap] = stored_value\n end\n array\nend",
"def insertion_sort_one(arr)\n 1.upto(arr.length - 1) do |i|\n value = arr[i]\n j = i - 1\n while j >= 0 and arr[j] > value\n arr[j + 1] = arr[j]\n j -= 1\n end\n arr[j + 1] = value\n end\n arr\nend",
"def insertion_sort(arr)\n i = 1\n while i < arr.length\n k = i - 1\n num = arr[ i]\n while k >=0 && num < arr[k]\n arr[k], arr [k + 1] = num, arr[ k]\n k -= 1\n end\n i += 1\n end\n arr\nend",
"def insertion_sort(array)\n # setting an array called final to [whatever is at the first position of the array]; an array of length 1\n final = [array[0]]\n # deleting the first index of the array so that it doesn't get considered in the while loop, since it is already in final array\n array.delete_at(0)\n # iterating through the array\n array.each do |i|\n # setting a value of 0 to a variable called final_index\n final_index = 0\n # while final_index value is less than the length of final array\n while final_index < final.length\n # if i is less than or equal to final[0]\n if i <= final[final_index]\n # then insert i into final array at position indicated by final_index value (i.e., i swaps positions with the value at the index indicated by final_index)\n final.insert(final_index, i)\n # breaks the loop when if returns true\n break\n # else if final_index equals the length of final - 1\n elsif final_index == final.length - 1\n # then insert i into final array at position indicated by final_index value plus 1 (i.e, i gets inserted behind the value at final_index plus 1)\n final.insert(final_index + 1, i)\n # breaks the loop when elsif returns true\n break\n end\n # add 1 to final_index each time it runs through the loop\n final_index += 1\n end\n end\n # puts final array\n final\nend",
"def insertion_sort(arr)\n\t# step 1 - set variables. Placeholder_index starts at index 1 rather than index 0 because you\n\t# are always comparing the placeholder to what is to the left of the placeholder\n\tplaceholder_index = 1\n\t# until the placeholder_index is at the index value as the length of the array...\n\t\tuntil placeholder_index > (arr.length - 1)\n\t\t\tcurrent_index = placeholder_index\n\t\t\t# the compare_index is the value to the right of the placeholder/compare_index\n\t\t\tcompare_index = current_index - 1\n\t\t\t# until the current_index is greater than or equal to the compare_index\n\t\t\tuntil arr[current_index] >= arr[compare_index]\n\t\t\t\t# swap the two numbers\n\t\t\t\tarr[current_index], arr[compare_index] = arr[compare_index], arr[current_index]\n\t\t\t\t# compare left number and right\n\t\t\t\tcurrent_index -= 1\n\t\t\t\tcompare_index -= 1 unless compare_index == 0\n\t\t\tend\n\t\t\tplaceholder_index += 1\n\t\tend\nreturn arr\nend",
"def insertion_sort(array, index = 0)\n return array if index == array.size\n insert_to_the_left(array, index)\n insertion_sort(array, index + 1)\nend",
"def insertion(a)\n\tlen = a.length\t\n\tfor i in 0..(len-1) #going through each element\n\t\tfor j in i..0 #elements go from right to left <-\n\t\t\tif a[j-1] > a[j]\n\t\t\t\ttemp = a[j-1]\n\t\t\t\ta[j - 1] = a[j]\n\t\t\t\ta[j] = temp\n\t\t\tend\n\t\tend\n\tend\n\treturn a\n\nend",
"def insertion_sort(array)\n for index in (1...array.size)\n stored_value = array[index]\n gap = index # gap is the index at which we can overwrite.\n # ^ initially, it's `index` because that's what he have stored\n while gap > 0 && array[gap - 1] > stored\n array[gap] = array[gap - 1]\n gap -= 1 # now we can overwrite *this* index, having moved corresp. value to the right\n end\n array[gap] = stored_value # remember, `gap` is the index at which we can overwrite\n end\n array\nend",
"def iterative_insertion_sort(arr)\r\n 1.upto(arr.length - 1) do |index|\r\n key = arr[index]\r\n pos = index - 1\r\n while pos >= 0 && key <= arr[pos]\r\n # this could also have been written by swapping repeatedly\r\n # instead of copying the bigger element to the empty slot\r\n arr[pos + 1] = arr[pos]\r\n pos = pos - 1\r\n end\r\n arr[pos + 1] = key\r\n end\r\n arr\r\nend",
"def insertionSort(ia)\n #initialize value and j\n value = 0\n j = 0\n\n for i in 1..(ia.length-1) #for i in indexes of the array...\n value = ia[i]; #value is the current position\n j = i - 1 #j is the index of one less than the current position\n\n while (j >= 0 && ia[j] > value) #while j is not 0 and there is still something bigger than value...\n #move value down\n ia[j + 1] = ia[j]\n j -= 1\n end\n\n ia[j + 1] = value #finally set value where it should be.\n end\nend",
"def insertion_sort(arr=@array)\n result = arr\n for i in 1..result.size - 1\n key = result[i]\n index = i\n while (index > 0 && result[index-1] > key)\n result[index] = result[index-1]\n index -= 1\n end\n result[index] = key\n end\n result\n end",
"def insertion_sort(arr)\n\t# variables for holding our two comparisons and the array maker\n\tc = 0\n\td = 1\n\tmark = 1\n\t# repeat unill you are through the whole array\n\twhile mark <= arr.length\n\t# assign the values in arr[c] to a and arr[d] to b\n\ta = arr[c]\n\tb = arr[d]\n\t\t# if they are not in ascending order\n\t\tif a > b\n\t\t\t# if c is 0\n\t\t\tif c == 0\n\t\t\t\t# assign the value of b to arr[c] and the value of a to arr[d]\n\t\t\t\tarr[c] = b\n\t\t\t\tarr[d] = a\n\t\t\t# increase c,d, & e by 1\n\t\t\tc += 1\n\t\t\td += 1\n\t\t\tmark += 1\n\t\t\t# if is is not 0\n\t\t\telse\n\t\t\t\t# assign the value of b to arr[c] and the value of a to arr[d]\n\t\t\t\tarr[c] = b\n\t\t\t\tarr[d] = a\n\t\t\t\t# decriment c and d by 1\n\t\t\t\tc -= 1\n\t\t\t\td -= 1\n\t\t\tend\n\t\t# if they are in ascending order\n\t\telse\n\t\t\t# increase c,d, & e by 1\n\t\t\tc += 1\n\t\t\td += 1\n\t\t\tmark += 1\n\t\tend\n\tend\n\treturn arr\nend",
"def insertion_sort(arr, &prc)\n dir = (prc.call(1,2) == -1) ? :ASC : :DESC\n while true\n i = 0\n j = 1\n inserted = false\n while j < arr.length\n if dir == :ASC\n if arr[i] > arr[j]\n num = arr.delete_at(i)\n arr.insert(j, num)\n inserted = true\n end\n else\n if arr[i] < arr[j]\n num = arr.delete_at(i)\n arr.insert(j, num)\n inserted = true\n end\n end\n i += 1\n j += 1\n end\n break if !inserted\n end\n arr\nend",
"def insertion_sort(input_array)\n final_array = [input_array[0]] # puts the first value in input_array into final_array so we have something to compare the rest of the values to\n input_array.delete_at(0) # deletes input_array[0] from input_array (so it's cutting and pasting instead of copy and pasting)\n\n for value in input_array\n index = 0\n while index < final_array.length\n if value <= final_array[index] \n final_array.insert(index, value)\n #break\n elsif index == final_array.length-1\n final_array.insert(index+1, value)\n #break\n end\n index += 1\n end\n return final_array \n end\nend",
"def insertion_sort(input_array)\n\tfinal_array = [input_array[0]]\n\n\tfor new_value in input_array\n\n\t\tp \"Checking #{new_value}\"\n\n\t\tfor existing_value in final_array\n\t\t\t# p \"Comparing #{new_value} to #{existing_value} (#{new_value <=> existing_value})\"\n\t\t\t# Check if new_value should be inserted before existing_value.\n\t\t\t# IF yes, insert.\n\t\t\t# If no, proceed to next item.\n\n\t\t\tif (new_value.downcase <=> existing_value.downcase) == -1\n\t\t\t\t\n\t\t\t\tif final_array.index(existing_value) > 0\n\t\t\t\t\t# p \"Inserting #{new_value} before #{existing_value} at index #{final_array.index(existing_value)}\"\n\t\t\t\t\tfinal_array.insert(final_array.index(existing_value), new_value)\n\t\t\t\telse\n\t\t\t\t\t# p \"Inserting #{new_value} before #{existing_value} at zero index\"\n\t\t\t\t\tfinal_array.insert(0, new_value)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tbreak\n\t\t\telsif final_array[-1] == existing_value\n\t\t\t\t# p \"At end, pushing #{new_value}\"\n\t\t\t\tfinal_array.push(new_value)\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\n\n\treturn final_array.uniq\nend",
"def insertionSort1(n, arr)\n l = arr.length - 1\n last = arr[l]\n\n while l-1 >= 0 && arr[l-1] > last\n if last < arr[l-1] \n arr[l] = arr[l-1] \n arr.each{|v| print \"#{v} \"}\n puts\n end\n l -= 1\n end\n arr[l] = last\n arr.each{|v| print \"#{v} \"} \nend",
"def insert(x,a)\r\n c = a.dup\r\n c.push(x)\r\n c = c.sort\r\nend",
"def insertion_sort(collection)\n sorted_collection = [collection.delete_at(0)]\n\n for val in collection\n sorted_collection_index = 0\n while sorted_collection_index < sorted_collection.length\n if val <= sorted_collection[sorted_collection_index]\n sorted_collection.insert(sorted_collection_index, val)\n break\n elsif sorted_collection_index == sorted_collection.length - 1\n sorted_collection.insert(sorted_collection_index + 1, val)\n break\n end\n\n sorted_collection_index += 1\n end\n end\n\n sorted_collection\n end",
"def insertion_sort(array)\n key_index = 1\n sorted_array = [array[0]]\n\n while key_index < array.length\n key = array[key_index]\n \n # debug\n # p sorted_array\n # puts \"key_index #{key_index}\"\n \n if key >= sorted_array[-1] # if key is larger than or equal to the last term in the sorted array\n sorted_array << key\n key_index +=1\n\n else\n \n n = sorted_array.length - 1\n while n >= 0\n # debug\n # puts \"n #{n} -- while\"\n\n sorted_array[n+1] = sorted_array[n]\n \n if (n == 0) && (key < sorted_array[n])\n sorted_array[n] = key\n key_index += 1\n # debug\n # puts \"n #{n} -- if\"\n break\n elsif key >= sorted_array[n]\n sorted_array[n+1] = key\n key_index += 1\n # debug\n # puts \"n #{n} -- elsif\"\n break\n else\n n -= 1\n end\n \n end\n end\n end\n sorted_array\nend",
"def insertionSort(arr) \n unsorted_value = arr.last\n (arr.length - 1).downto(1) do |i|\n if unsorted_value > arr[i - 1] \n arr[i] = unsorted_value\n print_array(arr)\n return\n else\n arr[i] = arr[i - 1]\n print_array(arr)\n end\n end\n arr[0] = unsorted_value\n print_array(arr)\nend",
"def insertion_sort(arr)\n return arr\nend",
"def insert_sort(start_arr=[])\n index = 1\n (start_arr.length-1).times do \n current = start_arr[index]\n sub_arr_index = index - 1 \n while sub_arr_index >= 0 && start_arr[sub_arr_index]>current do\n start_arr[index] == start_arr[sub_arr_index]\n sub_arr_index += 1 \n end\n index +=1\n end\n return start_arr\nend",
"def insertion_sort(arr)\n<<<<<<< HEAD\n\tarr.each_with_index do |num, i|\n if i > 0\n while arr[i] < arr[i-1] && i > 0\n arr[i], arr[i-1] = arr[i-1], arr[i]\n i -= 1\n end\n \tend\n end\n=======\n>>>>>>> upstream/master\n return arr\nend",
"def insert_sort(arr, comparator = Proc.new {|a,b| a < b})\n # Ensure valid argument\n raise ArgumentError, \"The argument given must be an Array\" unless arr.is_a?(Array)\n # Cover the base cases\n return arr if arr.size <= 1\n\n (1).upto(arr.size - 1) do |i|\n if comparator.yield(arr[i], arr[i - 1])\n (i).downto(1) do |j|\n if comparator.yield(arr[j], arr[j - 1])\n arr[j], arr[j - 1] = arr[j - 1], arr[j]\n end\n end\n end\n end\n\n arr\nend",
"def insertion_sort_descending(a)\n for i in 1...(a.length) do\n j=i\n while(j>0) do\n if a[j-1] > a[j]\n tmp = a[j]\n a[j] = a[j-1]\n a[j-1] = tmp\n else\n break\n end\n j=j-1 \n end\n end\n return a\nend",
"def insert(arr, right_index, value)\n # value is the value to insert\n # right_index is the furthest right sorted element\n\n # Step through sorted elements right to left.\n # As long as your value is less than the element\n # at array[i] and you still have elements\n\n i = right_index\n while(i >= 0 && arr[i] > value)\n # copy the element\n arr[i+1] = arr[i]\n i -= 1\n end\n\n # insert the actual element\n arr[i+1] = value;\nend",
"def insert(list, x)\n list_size = list.size\n if x < list[1]\n if x < list[0]\n return [x] + list\n elsif list_size == 2\n return [list[0]] + [x] + [list[1]]\n else\n return [list[0]] + [x] + list[1..2]\n end\n elsif list_size == 2 || x > list[2]\n return list + [x]\n else\n return list[0..1] + [x] + [list[2]]\n end\n end",
"def recursive_insertion_sort(arr, i = arr.length - 1)\r\n return if i < 1\r\n recursive_insertion_sort(arr, i - 1)\r\n key = arr[i]\r\n j = i - 1\r\n while(j >= 0 && key < arr[j])\r\n arr[j + 1] =arr[j]\r\n j = j - 1\r\n end\r\n arr[j + 1] = key\r\nend",
"def insertion_sort(array)\r\n final = [array[0]] # Final grabs the first value in array.\r\n array.delete_at(0) # Then it deletes that value, to compare others\r\n # main code\r\n for i in array # for every integer in array:\r\n final_index = 0\r\n while final_index < final.length # Both index and length will increase, till length stops increasing, stopping loop.\r\n if i <= final[final_index] #IF the integer is less than the final_index integer:\r\n final.insert(final_index,i) # Insert the integer into the current index.\r\n break\r\n elsif final_index == final.length-1 #IF the index reaches the end of final's array, that means the integer is greater than all:\r\n final.insert(final_index+1,i) # Insert the value to the end of array cause it's the greatest value #COULD USE .PUSH HERE\r\n break \r\n end\r\n final_index+=1 # We will go to the next index of final, if no conditions are matched\r\n end # END WHILE LOOP\r\n end # END FOR LOOP\r\n # output\r\n final #returns final array\r\nend",
"def sort_itself(array)\n (1).upto(array.length - 1) do |i|\n insert = array[i]\n count = i - 1\n insertion_sort(array, count, insert)\n end\n end",
"def insert_sort(data, check_num)\n\n halfway = (data.length / 2) - 1\n\n # halfway quick-check to speed up full-scan of big arrays\n if data[halfway] < check_num\n data[halfway..-1].each_with_index do |data_point, index|\n if data_point > check_num\n return index + halfway\n end\n end\n else\n data.each_with_index do |data_point, index|\n if data_point > check_num\n return index\n end\n end\n end\n return -1\nend",
"def insert(x, arr)\n if arr.empty?\n [x]\n else\n head, *tail = arr\n if head > x\n [x] + arr\n else\n [head] + insert(x, tail)\n end\n end\nend",
"def insertion_sort!(&block)\n return self if length <= 1\n (1...length).each do |i|\n i.downto(1) do |j|\n break unless sort_compare(self[j - 1], self[j], &block) == 1\n swap(j - 1, j)\n end\n end\n self\n end",
"def sort(array)\n final = [array[0]]\n array.delete_at(0)\n # main code\n for i in array\n final_index = 0\n while final_index < final.length\n if i <= final[final_index]\n final.insert(final_index,i)\n break\n elsif final_index == final.length-1\n final.insert(final_index+1,i)\n break\n end\n final_index+=1\n end\n end\n # output\n final\nend",
"def insert_sort(data, check_num)\n\n return 0 if data.empty?\n\n halfway = (data.length / 2) - 1\n\n # halfway quick-check to speed up full-scan of big arrays\n if data[halfway] < check_num\n data[halfway..-1].each_with_index do |data_point, index|\n if data_point > check_num\n return index + halfway\n end\n end\n else\n data.each_with_index do |data_point, index|\n if data_point > check_num\n return index\n end\n end\n end\n return -1\nend",
"def insert_sort(data, check_num)\n\n return 0 if data.empty?\n\n halfway = (data.length / 2) - 1\n\n # halfway quick-check to speed up full-scan of big arrays\n if data[halfway] < check_num\n data[halfway..-1].each_with_index do |data_point, index|\n if data_point > check_num\n return index + halfway\n end\n end\n else\n data.each_with_index do |data_point, index|\n if data_point > check_num\n return index\n end\n end\n end\n return -1\nend",
"def insertion2 arr\n for i in 1..(arr.size-1)\n cur_el = arr[i]\n j = i -1\n while j >= 0 and arr[j] > cur_el\n arr[j+1] = arr[j]\n j = j-1\n end\n arr[j+1] = cur_el\n puts arr.join(' ')\n end\n \nend",
"def recursive_insertion_sort_version_two(arr, i = 1)\r\n key = arr[i]\r\n j = i -1\r\n while(j >= 0 && key < arr[j])\r\n arr[j + 1] = arr[j]\r\n j = j - 1\r\n end\r\n arr[j + 1] = key\r\n recursive_insertion_sort_version_two(arr, i + 1) if i < arr.length - 1\r\nend",
"def shell_sort(a)\n n=a.length\n h=1\n \n while (h<n/3) #for computing increment factor \"h\"\n h= (3*h)+1\n end\n \n while h>=1\n # Logic of insertion sort with inrement steps of \"h\"\n for i in h...n\n j=i\n while j>=h\n if a[j-h]>a[j]\n temp=a[j]\n a[j]=a[j-h]\n a[j-h]=temp\n end\n j-=h\n end\n end\n h/=3\n end\n \n return a\n \nend",
"def using_insert(arr, elem)\n arr.insert(4, elem)\nend",
"def insert_sorted(data)\n if (!@head || data <= @head.data)\n return insert(data)\n end\n current = @head\n while (current.next && current.next.data < data)\n current = current.next\n end\n current.next = Node.new(data, current.next)\n end",
"def insert_sorted(data)\n return insert(data) if !@head || data <= @head.data\n current = @head\n while current.next && current.next.data < data\n current = current.next\n end\n current.next = Node.new(data, current.next)\n end",
"def rollYourOwnSort(list)\n for i in 1..(list.length - 1)\n val = list[i]\n j = i - 1\n\n while j >= 0 && list[j] > val\n list[j + 1] = list[j]\n j -= 1\n end\n\n list[j + 1] = val\n end\nend",
"def shell_sort(a)\n array = a\n \n m = 1\n while (gap = array.length / (2 ** m)) >= 1\n puts \"gap: #{gap}\"\n 0.step(array.length-1, gap) do |i|\n #puts \"#{i}\"\n # insertion sort\n #puts \" ###{i+gap}\"\n (i+1).upto(i+gap-1) do |j|\n #puts \" #{j}\"\n if array[j] < array[j-1]\n # need to shift everything over until it isn't\n j.downto(i+1) do |k|\n if array[k] < array[k-1]\n array[k], array[k-1] = array[k-1], array[k]\n end\n end\n end\n end\n p a\n end\n \n m += 1\n end\nend",
"def using_insert(array,element)\n array.insert(4,element)\nend",
"def test_insertion_has_method_sort\n sorter = Insertion.new\n assert_equal [\"a\",\"b\",\"c\",\"d\"], sorter.sort([\"d\", \"b\", \"a\", \"c\"])\n end",
"def insert_ascending(array, length, value_to_insert)\r\n if array[array.length] == 'SPECIAL_VALUE'\r\n i = 0;\r\n while i < array.length\r\n if array[i] > value_to_insert\r\n spaces = (array.length - 1) - i;\r\n moved = 0;\r\n until moved == spaces\r\n array[i] = array[i+1];\r\n i++;\r\n moved++;\r\n end\r\n end\r\n i++;\r\n end\r\n end\r\nend",
"def bubble_sort array\n n = array.length\n \n while n > 0 \n swapped = 0\n index = 1\n while index < n\n if array[index - 1] > array[index]\n swapped = index\n array.insert(index - 1, array[index])\n array.delete_at(index + 1)\n end\n index+=1\n end\n n = swapped\n end\n \n return array\nend",
"def adhoc_sort_5(list)\n list = swap(list, 0, 1) if list[0] > list[1]\n list = swap(list, 2, 3) if list[2] > list[3]\n list = list[2..3] + list[0..1] + [list[4]] if list[0] > list[2]\n # list is now of form [a, b, c, d, e] with a < c < d\n x_list = insert([list[0]] + list[2..3], list[4]) # insert e into [a, c, d]\n # xlist is one of: [a, c, d, e], [a, c, e, d], [a, e, c, d], [e, a, c, d]\n return [x_list[0]] + insert(x_list[1..3], list[1]) # insert b into last 3 elements of x_list\n end",
"def using_insert(array, element)\n array.insert(4, element)\nend",
"def using_insert(array, element)\n array.insert(4, element)\nend",
"def using_insert(array, element)\n array.insert(4, element)\nend",
"def using_insert(array, element)\n array.insert(4, element)\nend",
"def using_insert(array, element)\n array.insert(4, element)\nend",
"def insert(data)\n @array << data\n i = @array.size - 1\n while (i >= 0) && (data > @array[(i -1)/2])\n @array[(i -1)/2], @array[i] = @array[i], @array[(i -1)/2]\n i = parent(i)\n end\n @array\n end",
"def using_insert(array, element)\n array = array.insert(4, element)\n\n \nend",
"def using_insert(array, element)\n array.insert(4,element)\nend",
"def sort_list(array)\n loop do\n sorted = false\n i = 0\n while i < array.length - 1\n if array[i] > array[i+1]\n array[i], array[i+1] = array[i+1], array[i]\n sorted = true\n end\n i += 1\n end\n break if sorted == false\n end\n array\nend",
"def using_insert(array, element)\n \n array.insert(4, element)\n \nend",
"def insert(index, element)\n raise OutOfBoundsException unless valid_index?(index)\n\n temp_list = array_list\n @array_list = FixedArray.new(length + 1)\n (index -1).times do |below_index|\n array_list.set(below_index, temp_list.get(below_index))\n end\n\n array_list.set(index,element)\n\n (index + 1).upto(length - 1) do |above_index|\n @array_list.set(above_index, temp_list.get(index))\n end\n\n element\n end",
"def sort(array)\n for index in (1...array.size)\n stored = array[index]\n position = index\n while position > 0 && array[position - 1] > stored\n array[position] = array[position - 1]\n position -= 1\n end\n array[position] = stored\n end\n array\nend",
"def sort_list!(list)\n list.sort! do |a,b|\n a, b = a.sort_data, b.sort_data\n i = 0\n i += 1 while a[i] == b[i] && (a[i+1] || b[i+1])\n if a[i] && b[i]\n a[i] <=> b[i]\n else\n a[i] ? 1 : -1\n end\n end\n list\n end",
"def using_insert (array, element)\n return array.insert(4, element)\nend",
"def heap_sort2(a)\r\n size = a.length\r\n temp = 0\r\n i = (size/2)-1\r\n\r\n while i >= 0\r\n sift_down(a,i,size)\r\n i-=1\r\n end\r\n\r\n i=size-1\r\n while i >= 1\r\n a[0], a[1] = a[1], a[0]\r\n sift_down(a, 0, i-1)\r\n i-=1\r\n end\r\n return a\r\nend"
] |
[
"0.83110815",
"0.81892693",
"0.81059515",
"0.8023113",
"0.7979286",
"0.7964282",
"0.79011476",
"0.78686905",
"0.78496915",
"0.7844344",
"0.78437966",
"0.7834382",
"0.7826539",
"0.78238064",
"0.78086495",
"0.78079605",
"0.7802118",
"0.7798398",
"0.77799296",
"0.7771913",
"0.77080065",
"0.7707066",
"0.7690469",
"0.76791763",
"0.7669235",
"0.7667102",
"0.76597184",
"0.7651609",
"0.76515186",
"0.76491076",
"0.7645972",
"0.7628162",
"0.7620077",
"0.7565134",
"0.75574785",
"0.7554855",
"0.75532746",
"0.7537273",
"0.7510357",
"0.7497472",
"0.74545205",
"0.74435794",
"0.7442836",
"0.7413852",
"0.73784786",
"0.73434925",
"0.72963196",
"0.7294304",
"0.72918636",
"0.72626877",
"0.7233124",
"0.7232313",
"0.7214943",
"0.7170009",
"0.7138031",
"0.71332175",
"0.71211857",
"0.7109488",
"0.702745",
"0.7025274",
"0.69953895",
"0.6915807",
"0.68745726",
"0.6855129",
"0.68349886",
"0.66787285",
"0.66532534",
"0.6622643",
"0.65722483",
"0.6568571",
"0.656354",
"0.656354",
"0.6483207",
"0.6381196",
"0.63696474",
"0.62616104",
"0.6256524",
"0.62448883",
"0.62332827",
"0.62308747",
"0.62271404",
"0.6219989",
"0.62091005",
"0.61790043",
"0.61712515",
"0.6161281",
"0.6161281",
"0.6161281",
"0.6161281",
"0.6161281",
"0.61588573",
"0.6157824",
"0.61570257",
"0.6156552",
"0.6149678",
"0.6100742",
"0.60823476",
"0.60781115",
"0.60553044",
"0.6034576"
] |
0.79416037
|
6
|
Shellsort, also known as Shell sort or Shell's method, is an inplace comparison sort. It generalizes an exchanging sort, such as insertion or bubble sort, by starting the comparison and exchange of elements with elements that are far apart before finishing with neighboring elements. Starting with far apart elements can move some outofplace elements into position faster than a simple nearest neighbor exchange. Donald Shell published the first version of this sort in 1959.[1][2] The running time of Shellsort is heavily dependent on the gap sequence it uses. For many practical variants, determining their time complexity remains an open problem. using Shell's original gap sequence: floor(n/(2^k)) [O(n^2)]
|
def shell_sort(a)
array = a
m = 1
while (gap = array.length / (2 ** m)) >= 1
puts "gap: #{gap}"
0.step(array.length-1, gap) do |i|
#puts "#{i}"
# insertion sort
#puts " ###{i+gap}"
(i+1).upto(i+gap-1) do |j|
#puts " #{j}"
if array[j] < array[j-1]
# need to shift everything over until it isn't
j.downto(i+1) do |k|
if array[k] < array[k-1]
array[k], array[k-1] = array[k-1], array[k]
end
end
end
end
p a
end
m += 1
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def shell_sort(arr)\n gap = arr.size / 2\n until gap >= 1\n (0...gap).each do |i|\n j = i\n while j < arr.size\n arr[j], arr[j+gap] = arr[j+gap], arr[j] if arr[j] > arr[j+gap]\n j = j + gap\n end\n end\n gap, mod = gap.divmod(2)\n gap = mod == 0 ? gap + 1 : gap\n end\n arr\nend",
"def shell_sort(array)\n # p array\n gap = array.length/2\n while gap > 0\n idx = 0\n while idx < array.length - gap\n # while loop to move multiple steps\n while array[idx + gap] < array[idx]\n array[idx+gap],array[idx] = array[idx],array[idx+gap]\n if idx >= gap\n idx -= gap \n else\n break\n end\n end\n idx += 1\n end\n gap = gap/2\n # puts \"new gap is #{gap}\"\n p \"-\" * 10\n # p array verify properly sorting\n end\nend",
"def shell_sort(array)\n len = array.length\n gap = 1\n\n # calculate gap distance for initial sub-array checks\n gap = gap * 3 + 1 while gap < len / 3\n\n while gap > 0\n (gap...len).each do |i|\n j = i\n while j >= gap\n if array[j - gap] > array[j]\n array[j - gap], array[j] = array[j], array[j - gap]\n end\n j -= gap\n end\n end\n gap /= 3\n end\n array\nend",
"def shell_sort(list)\n gap = list.size / 2\n while gap > 0 do\n for i in gap..list.size - 1 \n j = i \n while j >= gap and list[j] < list[j-gap] # if current < previous. previous = gap values to the left\n list[j], list[j-gap] = list[j-gap], list[j] # swap current and previous\n j -= gap # keep swapping current and previous until previous > current\n end\n end\n gap = gap / 2\n end\n list\nend",
"def shell_sort(array)\n p array\n gap = array.length/2\n while gap > 0\n puts \"gap is currently #{gap}\"\n idx = 0\n while idx < array.length - gap\n # while loop to move multiple steps\n while array[idx + gap] < array[idx]\n array[idx+gap],array[idx] = array[idx],array[idx+gap]\n if idx > 0\n idx -= 1\n else\n break\n end\n end\n idx += 1\n end\n gap = gap/2\n p \"-\" * 10\n p array\n end\nend",
"def shell_sort(a)\n i = 0\n j = 0\n size = a.length\n increment = size / 2\n temp = 0\n \n while increment > 0\n i = increment\n while i<size\n j = i\n temp = a[i]\n while j>=increment and a[j-increment]>temp\n a[j] = a[j-increment]\n j = j-increment\n end\n a[j] = temp\n i+=1\n end\n if increment == 2\n increment = 1\n else\n increment = (increment/2).to_i\n end\n end\n return a\nend",
"def shell_sort(a)\n n = a.length # Size of input\n h = 1\n h = h * 3 + 1 while h < n / 3\n\n while h >= 1\n i = h\n while i < n\n j = i\n while j >= h && a[j] < a[j - h]\n temp = a[j - h]\n a[j - h] = a[j]\n a[j] = temp\n\n j -= h\n end\n i += 1\n end\n h = (h / 3).to_i\n end\n a\nend",
"def shell_sort(a)\n n=a.length\n h=1\n \n while (h<n/3) #for computing increment factor \"h\"\n h= (3*h)+1\n end\n \n while h>=1\n # Logic of insertion sort with inrement steps of \"h\"\n for i in h...n\n j=i\n while j>=h\n if a[j-h]>a[j]\n temp=a[j]\n a[j]=a[j-h]\n a[j-h]=temp\n end\n j-=h\n end\n end\n h/=3\n end\n \n return a\n \nend",
"def heap_sort2(a)\r\n size = a.length\r\n temp = 0\r\n i = (size/2)-1\r\n\r\n while i >= 0\r\n sift_down(a,i,size)\r\n i-=1\r\n end\r\n\r\n i=size-1\r\n while i >= 1\r\n a[0], a[1] = a[1], a[0]\r\n sift_down(a, 0, i-1)\r\n i-=1\r\n end\r\n return a\r\nend",
"def mothrah_sort (an_array)\n\tdef move_to_end (value, array)\n\t\tarray.delete(value)\n\t\tarray.push(value)\n\tend\n\tpos = 0\n\twhile pos < an_array.length \n\t\tif an_array[pos] > an_array[pos + 1]\n\t\t\tmove_to_end(an_array[pos], an_array)\n\t\telse\n\t\t\tpos += 1\n\t\tend\n\tend\n\tan_array\nend",
"def heap_sort(arr)\n 2.upto(arr.length - 1).each do |heap_size|\n BinaryMinHeap.heapify_up(arr, heap_size - 1, heap_size)\n end\n\n arr.length.downto(2).each do |heap_size|\n arr[heap_size - 1], arr[0] = arr[0], arr[heap_size - 1]\n BinaryMinHeap.heapify_down(arr, 0, heap_size - 1)\n end\n\n arr.reverse\nend",
"def insertionsort! arr\n (1..arr.size - 1).each do |i|\n j = i\n while j > 0 && arr[j] < arr[j - 1] do\n arr[j], arr[j - 1] = arr[j - 1], arr[j]\n j -= 1\n end\n end\n arr\nend",
"def wiggle_sort(nums)\n nums = nums.sort!\n\n greater_num_idx = nums.length / 2\n lesser_num_idx = 1\n\n until lesser_num_idx >= greater_num_idx\n nums[lesser_num_idx], nums[greater_num_idx] = nums[greater_num_idx], nums[lesser_num_idx]\n lesser_num_idx += 2\n greater_num_idx += 1\n end\n nums\nend",
"def heap_sort (list)\r\n sl = []\r\n heap = build_heap(list)\r\n heap.size.times do\r\n sl << heap.shift\r\n heap = heapify(heap, 0)\r\n end\r\n sl.reverse\r\nend",
"def gnome_sort(array)\n count = 0\n\n while count < array.length - 1\n if array[count] > array[count + 1]\n array[count + 1], array[count] = array[count], array[count + 1]\n count -= 2 if count.positive?\n end\n count += 1\n end\n\n array\nend",
"def insertion_sort(arr, &prc)\n dir = (prc.call(1,2) == -1) ? :ASC : :DESC\n while true\n i = 0\n j = 1\n inserted = false\n while j < arr.length\n if dir == :ASC\n if arr[i] > arr[j]\n num = arr.delete_at(i)\n arr.insert(j, num)\n inserted = true\n end\n else\n if arr[i] < arr[j]\n num = arr.delete_at(i)\n arr.insert(j, num)\n inserted = true\n end\n end\n i += 1\n j += 1\n end\n break if !inserted\n end\n arr\nend",
"def gnomesort(a)\n a.start_logging\n\n i = 0\n while i < a.length\n if i == 0 || a[i] > a[i - 1]\n i += 1\n else\n a[i], a[i - 1] = a[i - 1], a[i]\n a.log\n i -= 1\n end\n end\n\n a\nend",
"def insertion_sort(array)\n # Takes n passes here.\n (1...array.size).each{ |i|\n j = i\n # and this also takes n, but the distance of the count decreases\n # each time.\n while j > 0 and array[j - 1] > array[j]\n temp = array[j]\n array[j] = array[j-1]\n array[j-1] = temp\n\n j -= 1\n end\n }\n array\nend",
"def comb_sort(array)\n gap = array.size\n swaps = true\n while gap > 1 || swaps\n gap = [1, (gap / 1.25).to_i].max\n swaps = false\n 0.upto(array.size - gap - 1) do |i|\n if array[i] > array[i + gap]\n array[i], array[i + gap] = array[i + gap], array[i]\n swaps = true\n end\n end\n end\n array\nend",
"def insertion_sort(arr)\n\t(arr.length - 1).times do |n|\n\t\tcurrent_place = n + 1\n\t\twhile arr[current_place - 1] > arr[current_place] && current_place > 0 do\n\t\t\tswap(arr, current_place - 1, current_place)\n\t\t\tcurrent_place -= 1\n\t\tend\n\tend\n\treturn arr\nend",
"def sort(sequence)\n\n made_a_swap = true\n swaps = 0\n loops = 0\n\n def swap(counter, sequnce)\n temp = sequnce[counter]\n sequnce[counter] = sequnce[counter + 1]\n sequnce[counter + 1] = temp\n end\n\n\n while made_a_swap do\n counter = 0\n made_a_swap = false\n\n while counter < sequence.length - 1 #&& !made_a_swap\n\n if sequence[counter] > sequence[counter + 1]\n made_a_swap = true\n swaps += 1\n swap(counter, sequence)\n end\n\n\n counter += 1\n end\n\n print \"#{loops} \" if loops % 1000 == 0\n loops += 1\n end\n\nend",
"def heap_sort(arr)\n\tbuild_max_heap(arr)\n\t#Put the largest (first) item at the end, put that value at the front, rebuild the heap, and repeat\n\t#Invariant:\n\t# => any element in the sorted subsequence arr[i+1...end] >= any element in arr[0..i]\n\tfor i in (arr.length-1).downto(1)\n\t\tarr[0], arr[i] = arr[i], arr[0] #Swap first element with smallest sorted element\n\t\tarr.heap_size += -1\n\t\tmax_heapify(arr, 0)\n\tend\nend",
"def quick_sort(array)\n return array if array.length <= 1\n\n pivot = array[0]\n left = []\n right = []\n\n array[1..-1].each do |el|\n if el.length < pivot.length\n left << el\n else\n right << el\n end\n end\n\n dom_oct(left) + [pivot] + dom_oct(right)\n\nend",
"def smooth_sort(array)\n orders = [0]\n trees = 0\n\n (0...array.length).each do |i|\n if trees > 1 && orders[trees - 2] == orders[trees - 1] + 1\n trees -= 1\n orders[trees - 1] += 1\n elsif trees > 0 && orders[trees - 1] == 1\n orders[trees += 1] = 0\n else\n orders[trees += 1] = 1\n end\n find_and_sift(array, i, trees - 1, orders)\n end\n (array.length - 1).downto(1) do |i|\n if orders[trees - 1] <= 1\n trees -= 1\n else\n right_index = i - 1\n left_index = right_index - LEONARDO_NUMS[orders[trees - 1] - 2]\n trees += 1\n orders[trees - 2] -= 1\n orders[trees - 1] = orders[trees - 2] - 1\n find_and_sift(array, left_index, trees - 2, orders)\n find_and_sift(array, right_index, trees - 1, orders)\n end\n end\n array\nend",
"def poorly_written_sort(*arrays)\n combined_array = []\n arrays.each do |array|\n array.each do |value|\n combined_array << value\n end\n end\n\n sorted_array = [combined_array.delete_at(combined_array.length-1)]\n\n for val in combined_array\n i = 0\n while i < sorted_array.length\n if val <= sorted_array[i]\n sorted_array.insert(i, val)\n break\n elsif i == sorted_array.length - 1\n sorted_array.insert(i, val)\n break\n end\n i+=1\n end\n end\n\n # Return the sorted array\n sorted_array\nend",
"def sort_heaped_list(list)\n last_pos = list.length - 1\n while last_pos > 0\n remove_max(list, last_pos)\n last_pos -= 1\n end\nend",
"def sorting(arr)\n#display orig array\n p arr \n p \"**************************************************\"\n # do something to the array\n # compare each value of an array to the value on its left\n # if the value is less than the value on its left, switch places\n # do this by placing the lesser value in a holder and then moving the greater\n # value to the lesser value's former position in the array, then rewrite the\n # greater value's former position, with the holder value.\n # do this until the value is greater than the value on its left for \n # the entire array \n#Here is our brute force attempt at making our own .sort! method\n#we used the .sort! method from the Array class.\narr.length.times do\n |x|\n holder = \"\"\n if arr[x] > arr[x-1]\n holder = arr[x-1]\n arr[x-1] = arr[x]\n arr[x] = holder\n end \n end\nputs \"this is the one we made #{arr} \"\n # if arr[1] > arr[0]\n p arr.sort!\n p \"above is the sorting method\"\n#rerturn the changed array\nend",
"def qsort(a, lower, upper)\r\n if lower < upper\r\n mid = partition(a, lower, upper)\r\n qsort(a, lower, mid)\r\n qsort(a, mid+1, upper)\r\n end\r\n return a\r\nend",
"def insertion_sort_two(arr)\n 1.upto(arr.length - 1) do |i|\n value = arr.delete_at(i)\n j = i - 1\n j -= 1 while j >= 0 && value < arr[j]\n arr.insert(j + 1, value)\n end\n arr\nend",
"def sort(array)\n for index in (1...array.size)\n stored = array[index]\n position = index\n while position > 0 && array[position - 1] > stored\n array[position] = array[position - 1]\n position -= 1\n end\n array[position] = stored\n end\n array\nend",
"def quick_sort(array, &prc)\n return array if array.length <= 1\n prc ||= Proc.new { |el1, el2| el1 - el2 }\n\n part_idx = array.length / 2\n part_val = array[part_idx]\n\n left = []\n right = []\n\n array.each_with_index do |el, idx|\n next if idx == part_idx\n prc.call(el, part_val) <= 0 ? left << el : right << el\n end\n\n quick_sort(left, &prc) + [part_val] + quick_sort(right, &prc)\nend",
"def insert_sort(array)\n for i in 1..(array.length - 1)\n j = i\n while j > 0 && array[j] < array[j - 1]\n swap(j, j-1, array)\n j -= 1\n end\n end\n return array\n\nend",
"def quick_sort(arr)\n return [] if arr.empty?\n first, *remaining = arr\n left, right = remaining.partition{ |x| x < first }\n quick_sort(left) + [first] + quick_sort(right)\nend",
"def sorted_arr_sort(*arrs)\n h = Heap.new {|a, b| a[:val] <=> b[:val]}\n count = 0\n res = [] \n\n arrs.each_with_index do |arr, idx|\n count += arr.length\n h.insert({val: arr.shift, idx: idx}) unless arr.empty?\n end\n \n until res.length == count \n min_left = h.remove\n res << min_left[:val]\n h.insert({ val: arrs[min_left[:idx]].shift, idx: min_left[:idx] }) if arrs[min_left[:idx]].length > 0\n end \n\n res\nend",
"def block_sort(arr)\n return arr if arr.size < 2\n\n block_start = 0\n block_stop = MIN - 1\n while block_stop < arr.size\n sorting = arr[block_start..block_stop]\n arr[block_start..block_stop] = insertion_sort(sorting)\n block_start += MIN\n if block_stop + MIN < arr.size\n block_stop += MIN\n else\n block_stop = arr.size\n end\n end\n if arr[block_start..block_stop].size < MIN * 2\n arr1 = arr[0...block_start]\n arr2 = arr[block_start..block_stop]\n return merge(arr1, arr2, arr1.size, arr2.size)\n end\n merge_sort(arr)\nend",
"def insertion_sort!(array)\n array.each_with_index do |el, i|\n j = i\n j -= 1 while j > 0 && el < array[j-1]\n array[i] = array[i-1] and i -= 1 while i > j\n array[j] = el\n end\n\n array\nend",
"def insertion_sort(arr)\n\t# step 1 - set variables. Placeholder_index starts at index 1 rather than index 0 because you\n\t# are always comparing the placeholder to what is to the left of the placeholder\n\tplaceholder_index = 1\n\t# until the placeholder_index is at the index value as the length of the array...\n\t\tuntil placeholder_index > (arr.length - 1)\n\t\t\tcurrent_index = placeholder_index\n\t\t\t# the compare_index is the value to the right of the placeholder/compare_index\n\t\t\tcompare_index = current_index - 1\n\t\t\t# until the current_index is greater than or equal to the compare_index\n\t\t\tuntil arr[current_index] >= arr[compare_index]\n\t\t\t\t# swap the two numbers\n\t\t\t\tarr[current_index], arr[compare_index] = arr[compare_index], arr[current_index]\n\t\t\t\t# compare left number and right\n\t\t\t\tcurrent_index -= 1\n\t\t\t\tcompare_index -= 1 unless compare_index == 0\n\t\t\tend\n\t\t\tplaceholder_index += 1\n\t\tend\nreturn arr\nend",
"def sort\n\n arr_len = @data.length\n start_build_idx = arr_len / 2 - 1 # The last half of the array is just leaves\n\n for i in (start_build_idx).downto(0)\n\n max_heapify(@data, arr_len, i) # Build the heap from the array\n end\n\n for i in (arr_len-1).downto(0)\n\n swap(@data, i, 0) # Move the current root to the end of the array\n max_heapify(@data, i, 0) # Heapify the remaining part of the array excluding the root which was just sorted to the end\n end\n\n puts(@data)\n end",
"def sort_array array\n sorted=[]\n a=0\n b=0\n until a==(array.length-1)||b==(array.length)\n if array[a] <= array[b]\n b+=1\n else\n a+=1\n b=0\n end\n end\n sorted.push array[a]\n array.delete(array[a])\n \n while true\n if array.length==1\n sorted.push array[0]\n break\n else\n a=0\n b=0\n until a==(array.length-1)||b==(array.length)\n if array[a]<=array[b]\n b+=1\n else\n a+=1\n b=0\n end\n end\n sorted.push array[a]\n array.delete_at(a)\n end\n end\n sorted\nend",
"def quicksort(list, left, right)\n # Checks if the left array item is bigger than the right array item\n if left < right\n # Sends the items for inspection and splitting them up in 2 arrays\n switch = partition(list, left, right)\n # Recursive function to make sure it does all the elements\n quicksort(list, left, switch-1)\n quicksort(list, switch+1, right)\n end\nend",
"def heap_sort(arr)\n (arr.length - 1).downto(1).each do |i|\n p \"i = #{i},arr[i] = #{arr[i]},arr[0] is #{arr[0]},arr = #{arr}\"\n # 打乱顺序\n # 然后上一轮的最小值\n # 就永远回不去顶端了\n # 因为 i 值不断缩小\n # 比较的范围越来越小\n arr[i], arr[0] = arr[0], arr[i]\n p \"---arr = #{arr}\"\n min_heap_fixdown(arr, 0, i)\n p \"===arr = #{arr}\"\n end\n arr\nend",
"def bubble_sort(array)\ntemp = nil\n\tfor n in 0..array.length-1\n\t\tswapped = false\n\t\tfor i in 0...array.length-1\n\t\t\tif array[i] < array[i+1]\n\t\t\t\tarray\n\t\t\telse \n\t\t\t\ttemp = array[i]\n\t\t\t\tarray[i] = array[i+1]\n\t\t\t\tarray[i+1] = temp\n\t\t\t\tarray\n\t\t\t\tswapped = true\n\t\t\tend\n\t\tend\n\t\tif !swapped\n\t\tbreak\n\t\tend\n\tend\n\t\tarray\nend",
"def insertionSort(arr)\n \n return 0 if arr.count <= 1\n\n arr_size_index = arr.size-1\n count_shifts = 0\n\n for i in 0..arr_size_index\n\n break if i == arr_size_index\n \n if arr[i] > arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n count_shifts+=1\n end\n\n j = i\n\n while (j > 0) && arr[j-1] > arr[j]\n arr[j], arr[j-1] = arr[j-1], arr[j]\n j -=1\n count_shifts+=1\n end\n\n end\n\n count_shifts\nend",
"def sort\n # Find a cycle in the move graph and pick a register to spill to break it.\n spillee = nil\n each_strongly_connected_component do |component|\n if component.size > 1\n fail if spillee # There is one cycle with 3 registers.\n spillee = component.first.src\n end\n end\n\n # Break the cycle.\n spill(spillee) if spillee\n\n tsort\n end",
"def quick_sort(list)\n sl = list.clone\n return sl if sl.size <= 1\n pivot = sl.pop\n left, right = sl.partition { |e| e < pivot }\n quick_sort(left) + [pivot] + quick_sort(right)\nend",
"def sort(input)\n # If the length of the array is < or = 1, then we already\n # know it's sorted, so exit\n return input if input.length <= 1\n\n # Now we want to run this algorithm in a loop for forever\n # until we know that the entire array is sorted. That\n # will be our \"break\" condition - the condition to\n # break out of the loop.\n\n swapped = true\n while swapped do\n # We set swapped equal to false here, because we\n # basically want to set it only to true when we've\n # actually swapped something. If we never swap anything\n # in this iteration of the loop, it means that the\n # array is sorted and we're done.\n swapped = false\n\n # We use upto, which is a function from Enumerators\n # https://ruby-doc.org/core-2.2.0/Integer.html#method-i-upto\n # We basically are saying we are going to access through the\n # array we're given, up until the length of it -2. Why?\n # We're accessing each of the array elements by index.\n # Example: [1,2,3,4]\n # If we want to get 1 from the array, we access element 0.\n # In this example, we want to access the current index and the\n # index ahead of it. So, in this loop, we only want to try\n # and access the length of the array minus 2, because otherwise\n # we'll run out of the bounds of the array.\n 0.upto(input.length - 2) do |index|\n # If the number at our current index is greater than the one\n # in front of it... swap!\n if input[index] > input[index+1]\n # Here's a neat trick you can do so you don't have to assign\n # any variables to hold onto a value.\n input[index], input[index+1] = input[index+1], input[index]\n swapped = true\n end\n end\n end\n\n input\nend",
"def my_quick_sort(&prc)\n prc ||= Proc.new{|a,b| a <=> b}\n return self if self.length <= 1\n mdix = self.length()/2\n left = []\n right = []\n # debugger\n self.each_with_index do |item, idx|\n case prc.call(item,self[mdix])\n when -1 #a smaller\n left << item\n when 0\n left << item if idx != mdix\n when 1\n right << item\n end\n end\n # debugger\n left.my_quick_sort(&prc) + [self[mdix]] + right.my_quick_sort(&prc)\n end",
"def strand_sort(array)\n temp = array.dup\n result = []\n until temp.empty?\n value = temp.first\n sublist, temp = temp.partition { |val| value = val if value <= val }\n result += sublist.shift(sublist.length) if result.empty?\n result = binary_sort(result, sublist)\n end\n result\nend",
"def quick_sort(arr)\n return arr if arr.length <= 1\n\n ref = arr.shift\n left = quick_sort(arr.select{|x| x.length <= ref.length})\n right = quick_sort(arr.select{|x| x.length > ref.length})\n\n left + [ref] + right\nend",
"def quickSortHelper(ia, left, h)\n if (left < h)\n p = partition(ia, left, h) #get partition index of the array\n quickSortHelper(ia, left, p - 1) #sort from low to partition index -1\n quickSortHelper(ia, p + 1, h) #sort from p + 1 to high\n end\nend",
"def mergesort(array)\n # Base case\n if array.count <= 1\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n # 1. Divide\n mid = array.count / 2\n left_partition = mergesort array.slice(0, mid)\n right_partition = mergesort array.slice(mid, array.count - mid)\n\n # 2. Conquer\n array = []\n left_lead = 0\n right_lead = 0\n while left_lead < left_partition.count && right_lead < right_partition.count\n a = left_partition[left_lead]\n b = right_partition[right_lead]\n\n # Take the smallest of the two, and push it on our array\n if a <= b\n array << a\n left_lead += 1\n else\n array << b\n right_lead += 1\n end\n end\n\n # Either left or right may have elements left; consume them.\n # (Only one of the following loops will actually be entered.)\n while left_lead < left_partition.count\n array << left_partition[left_lead]\n left_lead += 1\n end\n\n while right_lead < right_partition.count\n array << right_partition[right_lead]\n right_lead += 1\n end\n\n return array\nend",
"def bigSorting(unsorted)\n\nend",
"def cocktail_sort(array)\n compare = ->(a, b) { a <=> b }\n loop do\n array, swapped = forward_pass(array, compare)\n break unless swapped\n\n array, swapped = reverse_pass(array, compare)\n break unless swapped\n end\n array\nend",
"def quick_sort(array)\nend",
"def stable_sort_by(list); end",
"def insertion_sort(array)\n array.length.times do |i|\n while i > 0\n if array[i - 1] > array[i]\n array[i], array[i - 1] = array[i - 1], array[i]\n end\n i -= 1\n end\n end\n array\nend",
"def insertion_sort(array)\n for i in 1..(array.length - 1)\n while i > 0 && array[i-1] > array[i]\n array[i], array[i-1] = array[i-1], array[i]\n i -= 1\n end\n end\nend",
"def quicksort(array)\n # debugger\n return [] if array.empty?\n smaller = []\n larger = []\n array.each do |item|\n if item < array.last\n smaller << item\n elsif item > array.last\n larger << item\n end\n end\n\n quicksort(smaller) + [array.last] + quicksort(larger)\nend",
"def insertion_sort(arr)\n len = arr.length\n for i in 0..len-1\n j = i\n while (j > 0 && arr[j-1] > arr[j])\n swap(arr,j,j-1)\n j = j-1\n end\n end\n return arr\nend",
"def insertion_sort(array)\n for index in (1...array.size)\n stored_value = array[index]\n gap = index\n while array[gap - 1] > stored_value && gap - 1 >= 0\n array[gap] = array[gap - 1]\n gap -= 1\n end\n array[gap] = stored_value\n end\n array\nend",
"def bubble_sort(&prc)\n prc ||= Proc.new{|a,b| a <=> b }\n\n sorted = false\n while !sorted\n sorted = true\n\n (0...self.length - 1).each do |i|\n # debugger\n if prc.call(self[i], self[i + 1]) == 1 # REMEBER: spaceship operator returns a number! only 0 is falsey\n self[i], self[i + 1] = self[i + 1], self[i]\n sorted = false\n end\n end\n end\n\n self\n end",
"def insertion_sort(array) \r\narray.each_with_index do |el,i| \r\n j = i - 1 \r\n while j >= 0 \r\n break if array[j] <= el \r\n array[j + 1] = array[j] \r\n j -= 1 \r\n end \r\n array[j + 1] = el \r\nend \r\nend",
"def insertion_sort(arr)\n\tn = arr.length\n\t(1...n).each do |i|\n\t\tj = i\n\t\twhile arr[j] < arr[j-1] #&& j >= 1\n\t\t\tx = arr[j]\n\t\t\tarr[j] = arr[j-1]\n\t\t\tarr[j-1] = x\n\t\t\tj -= 1\n\t\t\tbreak if j == 0\n\t\tend\n\tend\n\treturn arr\nend",
"def insertion_sort(arr)\n<<<<<<< HEAD\n\tarr.each_with_index do |num, i|\n if i > 0\n while arr[i] < arr[i-1] && i > 0\n arr[i], arr[i-1] = arr[i-1], arr[i]\n i -= 1\n end\n \tend\n end\n=======\n>>>>>>> upstream/master\n return arr\nend",
"def fast_sort(array, left_index, right_index)\n if left_index < right_index\n key = array[left_index]\n key_index = left_index\n (left_index + 1..right_index).each do |index|\n if array[index] < key\n temp = array[index]\n array.delete_at(index)\n array.insert(key_index, temp)\n key_index += 1\n end\n end\n fast_sort(array, left_index, key_index-1)\n fast_sort(array, key_index + 1, right_index)\n end\nend",
"def insertion_sort(arr)\n step = arr.size - 1\n \n 1.upto(step).each do |i|\n current = arr[i]\n index = i\n \n (i-1).downto(0).each do |j|\n break if arr[j] < current\n \n arr[j], arr[j+1] = arr[j+1], arr[j]\n index = j\n end\n \n arr[index] = current\n end\n \n arr\nend",
"def alternate_quicksort(array)\n return array if array.size < 2\n\n left = []\n right = []\n\n pivot_index = array.size - 1\n pivot_value = array[pivot_index]\n\n array.pop\n\n array.each do |item|\n item < pivot_value ? left.push(item) : right.push(item)\n end\n\n quicksort(left) + [pivot_value] + quicksort(right)\nend",
"def poorly_written_ruby(*arrays)\n\n combined_array = arrays.flatten # use built in ruby method\n\n index_count = combined_array.size - 1 # assign a variable so that array does not need to be accessed in while loop check\n sorted_array = [combined_array.delete_at(combined_array.length-1)]\n\n for val in combined_array\n i = 0\n while i <= index_count # use variable to avoid array access\n\n if val <= sorted_array[i]\n sorted_array.insert(i, val)\n break\n elsif i == sorted_array.length - 1\n sorted_array << val\n break\n end\n i+=1\n end\n end\n\n # Return the sorted array\n sorted_array\nend",
"def quick_sort(lst)\n return lst if lst.length <= 1\n pivot = lst.shuffle.shift\n left, right = lst.partition {|val| val < pivot}\n quick_sort(left) + quick_sort(right)\nend",
"def solution(a)\n len = a.size\n swaps = 0\n i = 0\n while i < len\n smallest = a[i]\n largest = a[i]\n j = i + 1\n while j < len && largest > a[j]\n smallest = a[j] if a[j] < smallest\n j += 1\n end\n i -= 1 while i > 0 && a[i-1] > smallest\n swaps = j - i if j > i + 1\n i = j\n end\n return swaps\nend",
"def merge_sort(array)\n if array.size <= 1\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n\n # 1. Divide\n mid = array.size / 2\n part_a = merge_sort(array.slice(0, mid))\n part_b = merge_sort(array.slice(mid, array.size - mid))\n\n\n# 2. Conquer\n array = []\n offset_a = 0\n offset_b = 0\n while offset_a < part_a.count && offset_b < part_b.count\n a = part_a[offset_a]\n b = part_b[offset_b]\n \n if a <= b\n array << a\n offset_a += 1\n else\n array << b\n offset_b += 1\n end\n end\n \n while offset_a < part_a.count\n array << part_a[offset_a]\n offset_a += 1\n end\n \n while offset_b < part_b.count\n array << part_b[offset_b]\n offset_b += 1\n end\n \n return array\nend",
"def insertion_sort(array)\n binding.pry\n (1..array.length - 1).each do |n|\n number_to_insert = array[n]\n j = n - 1\n while array[j] > number_to_insert && j >= 0\n array[j + 1] = array[j]\n j -= 1\n end\n array[j + 1] = number_to_insert\n end\n array\nend",
"def quick_sort(array, p, r)\n return array if p >= r\n q = partition(array, p, r)\n quick_sort(array, p, q - 1)\n quick_sort(array, q + 1, r)\nend",
"def mysort(arr)\n # The computational complexity of this algorithm is O(n^^2), and is similar\n # to selection sort. This is not idiomatically ideal Ruby - I've tried to\n # mostly use language constructs common to many languages.\n\n sorted = []\n\n smallest_index = 0\n while (arr.length > 0) do\n for i in (0..(arr.length - 1))\n if arr[i] < arr[smallest_index]\n smallest_index = i\n end\n end\n sorted.push arr.delete_at(smallest_index) \n smallest_index = 0\n end\n\n return sorted \n\nend",
"def heapsort()\n\t\tbuild_minheap()\n\t\ti = @heap.length-1\n\t\twhile i >= 1\n\t\t\ttemp = @heap[i]\n\t\t\t@heap[i] = @heap[0]\n\t\t\t@heap[0] = temp\n\t\t\tminheapify_heapsort(i)\n\t\t\ti -= 1\n\t\tend\n\t\t@heap\n\tend",
"def bubble_sort_by(input)\r\n sorted = false\r\n last_index = input.length-2\r\n until sorted\r\n swaps = 0\r\n 0.upto(last_index) do |i|\r\n if yield(input[i], input[i+1]) < 0\r\n input[i],input[i+1] = input[i+1],input[i]\r\n swaps += 1\r\n end\r\n end\r\n sorted = true if swaps == 0\r\n last_index -= 1\r\n end\r\n input\r\nend",
"def insertion_sort(array)\n return array if array.size < 2 \n\n for k in (1...array.size)\n for i in (0...k)\n if array[i] > array[k]\n swap(array, i, k)\n end \n end\n end\n array\nend",
"def quick_sort (arr, left, right)\n arr_index = partition(arr, left, right)\n if left < arr_index - 1 # sort left half\n quick_sort(arr, left, arr_index - 1)\n end\n\n if arr_index < right # sort right half\n quick_sort(arr, arr_index, right)\n end\n\n # if left < arr_index && arr_index < right\n # puts \"arr: #{arr}\"\n # arr\n # end\n\nend",
"def sort(arr)\n return arr if arr.length < 1\n\n pivot = arr.pop\n less = arr.select { |item| item < pivot}\n more = arr.select { |item| item >= pivot}\n\n sort(less) + [pivot] + sort(more)\nend",
"def quick_sort(&prc)\n end",
"def b_sort(array)\n v = array.length\n loop do\n swap = false\n (v-1).times do |i|\n if array[i] > array[i + 1]\n array[i], array[i + 1] = array[i + 1], array[i]\n swap = true\n end\n end\n break if not swap\n end\n p array\nend",
"def array_sort(arr)\nx = arr.length\nif x == 1\nelsif x == 2\n if arr[0] > arr[1]\n arr[0], arr[1] = arr[1], arr[0]\n end\nelse\n loop do\n modified = FALSE\n (x-2).times do |x|\n if (arr[x] < arr[x + 1]) && (arr[x] < arr[x + 2])\n if arr[x + 2] < arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x], arr [x + 2], arr[x + 1]\n modified = TRUE\n end\n elsif (arr[x + 1] < arr[x]) && (arr[x + 1] < arr[x + 2])\n if arr[x] < arr[x + 2]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr[x], arr[x + 2]\n modified = TRUE\n elsif arr[x + 2] < arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr [x + 2], arr[x]\n modified = TRUE\n elsif arr[x + 2] == arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr[x], arr[x + 2]\n modified = TRUE\n end\n elsif (arr[x + 2] < arr[x]) && (arr[x + 2] < arr[x + 1])\n if arr[x] < arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x], arr[x + 1]\n modified = TRUE\n elsif arr[x + 1] < arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x + 1], arr[x]\n modified = TRUE\n elsif arr[x] == arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x], arr[x + 1]\n modified = TRUE\n end\n end\n end\n break if modified == FALSE\n end\nend\n arr\nend",
"def square_and_sort(arr)\n p \"Input array: #{arr}\"\n output = Array.new(arr.size)\n \n p1 = 0\n puts \"Negative pointer at: #{p1}\"\n p2 = arr.size - 1\n puts \"Positive pointer at: #{p2}\"\n\n index = arr.size - 1 \n while (index >= 0) do \n if arr[p1].abs > arr[p2].abs\n output[index] = arr[p1] ** 2\n p1 += 1\n else\n output[index] = arr[p2] ** 2\n p2 -= 1\n end \n index -= 1 \n end\n\n # while(p1 >= 0)\n # output.push(arr[p1] ** 2)\n # p1 -= 1\n # end\n\n # while(p2 < arr.size)\n # output[p2] = arr[p2] ** 2\n # p2 += 1\n # end\n return output\nend",
"def bubble_sort!(&prc)\n prc ||= Proc.new {|x,y| x <=> y}\n sorted = false\n until sorted\n sorted = true\n i = 0\n while i < self.length - 1 #changed 2 to 1\n if prc.call(self[i], self[i+1]) > 0\n self[i], self[i+1] = self[i+1], self[i]\n sorted = false\n end\n i += 1\n end\n end\n return self\n end",
"def bubble_sort!(arr)\n comparisons = arr.length - 1\n iteration_count = 0 # this will allow for tail-end optimization\n\n loop do \n swap_count = 0\n\n comparisons.times do |idx|\n next if (arr.length - (idx + 1)) == iteration_count # tail-sort optimization\n\n if arr[idx] > arr[idx + 1]\n arr[idx], arr[idx + 1] = arr[idx + 1], arr[idx]\n swap_count += 1\n end\n end\n\n break if swap_count == 0\n iteration_count += 1\n end\n \n arr\nend",
"def bubble_sort_by(array)\n k = 0\n loop do\n i = 0\n swap = false\n while i < array.size.-(k+1)\n if (yield array[i], array[i+1]) > 0\n array.insert(i, array.delete_at(i+1))\n swap = true\n end\n i += 1\n end\n k += 1\n break if swap == false\n end\n p array\nend",
"def bubble_sort!(array)\r\n swap = false\r\n restrict = array.length - 1 # index of the last element\r\n\r\n (array.length-1).times do \r\n array.each_with_index do |_, index|\r\n break if index == restrict # optimization for the tail elements as well as avoiding \"out-of-index exception\"\r\n if array[index] > array[index + 1]\r\n array[index], array[index + 1] = array[index + 1], array[index]\r\n swap = true\r\n end\r\n end\r\n\r\n break if !swap\r\n\r\n swap = false # reset swap to false to check the next time if something is swapped\r\n restrict -= 1 # tail elements restricted for optimization\r\n end\r\n array\r\nend",
"def sort(v)\n temp = v.dup\n swap = true\n skipLast = 1\n while swap && (skipLast <= v.length)\n i = 0\n swap = false\n while i < (v.length - skipLast)\n if temp[i] > temp[i + 1] then\n temp[i], temp[i + 1] = temp[i + 1], temp[i]\n swap = true\n end\n i += 1\n end\n skipLast += 1\n end\n temp\nend",
"def sort(array, length)\n length.times do |index| # outer loop - n elements\n min_index = index # assume index is where the next minimally value is\n temp_index = index+1 # compare with values at index+1 to length-1\n while temp_index < length # inner loop - n-1 elements\n if array[temp_index] < array[min_index] # found a new minimum, update min_index\n min_index = temp_index\n end\n temp_index += 1\n end\n if min_index != index # next minimum value is not at current index, swap\n temp = array[min_index]\n array[min_index] = array[index]\n array[index] = temp\n end\n end\nend",
"def heapsort_inPlace(list)\n return list if list.length <= 1\n\n puts \"\\nSTARTING with #{list}\"\n\n # build a max heap\n list.length.times do |i|\n heap_up(list, i)\n puts \"\\tlist = #{list}\"\n end\n\n puts \"\\nREADY to pluck out Max and put start populating from end of list\"\n last = list.length - 1\n\n # pop off the top of the heap\n # place it in the last unsorted slot\n # re-heap the unsorted list\n list.length.times do |i|\n swap(list, 0, last)\n puts \"\\tpost swap,\\tlist = #{list}\"\n heap_down(list, 0, last)\n puts \"\\t\\t\\t adj = #{list}\"\n\n last -= 1\n end\n\n return list\nend",
"def poorly_written_ruby(*arrays)\n combined_array = []\n\n arrays.each do |array|\n combined_array.concat(array)\n end\n \n def quick_sort(collection)\n return collection if collection.length <= 1\n pivot = collection.sample\n\n left = Array.new\n right = Array.new\n\n collection.each do |x|\n if x <= pivot\n left << x\n else\n right << x\n end\n end\n\n quick_sort(left) + quick_sort(right)\n\n end\n\n def buckethash_sort(collection)\n\n buckets = Hash.new\n\n (\"A\"..\"Z\").each do |x|\n buckets[x] = Array.new\n end\n\n collection.each do |x|\n if buckets.key?(x[0])\n buckets[x[0]] << x\n end\n end\n\n buckets.each_key do |key|\n buckets[key] = quick_sort(buckets[key])\n end\n\n buckets.values.flatten\n\n end\n\n buckethash_sort(combined_array)\n\nend",
"def heapsort(list)\n return list if list.length <= 1\n\n last = list.length - 1\n\n # build a max heap\n # must heap down and start from the back of the array\n # key for O(n) time\n list.length.times do |i|\n heapify(list, last - i, last)\n end\n\n # pop off the top of the heap\n # place it in the last unsorted slot\n # re-heap the unsorted list\n list.length.times do |i|\n last = list.length - 1 - i\n\n swap(list, 0, last)\n\n heapify(list, 0, last - 1)\n end\n\n return list\nend",
"def heap_sort!(data)\n h = Heap.new\n while data.any?\n h << data.pop\n end\n\n while h.any?\n data << h.pop\n end\n\n return data\nend",
"def sort(array)\nfor j in 1..(array.length-1) #Sets loop parameter to count between 1 and length instead of starting at zero\n compare = array[j]\n i = j - 1\n while i >= 0 and array[i] > compare\n array[i+1] = array[i]\n i = i - 1\n end\n array[i+1] = compare\nend \nputs array\nend",
"def bubble_sort(&prc)\n prc ||= Proc.new {|a, b| a <=> b}\n sorted = false\n while !sorted\n sorted = true\n (0...self.length - 1).each do |i|\n if prc.call(self[i], self[i + 1]) == 1\n self[i], self[i + 1] = self[i + 1], self[i]\n sorted = false\n end\n end\n end\n self\n end",
"def quick_sort(array, from = 0, to = nil)\n\n #By default we start by sorting the entire\n #array.\n if to == nil\n to = array.count - 1\n end\n\n #Because this sort is in place, we don't need\n #to return anything. This is the guard check\n #for sorting being complete.\n if from >= to\n return\n end\n\n #Quick sort uses the key word 'pivot' to indicate\n #the current array element being used to compare.\n #It starts at the far left of the array.\n pivot = array[from]\n\n #Min and Max pointers to be used in algorithm\n min = from\n max = to\n\n #Free represents the current free slot in the array\n #or wall that is used to separate the sorted part\n #of the array from the unsorted part.\n free = min\n\n while min < max\n if free == min #Evaluate array[max]\n if array[max] <= pivot #Smaller than pivot must move\n array[free] = array[max]\n min += 1\n free = max\n else\n max -= 1\n end\n elsif free == max #Evaluate array[min]\n if array[min] >= pivot #Bigger than pivot must move\n array[free] = array[min]\n max -= 1\n free = min\n else\n min += 1\n end\n else\n raise \"Inconsistent State\"\n end\n end\n\n array[free] = pivot\n\n quick_sort(array, from, free - 1)\n quick_sort(array, free + 1, to)\nend",
"def insertion_sort(a)\n\tfor i in 1...(a.length)\n\t\tj=i\n\t\twhile j>0\n\t\t\tif a[j-1]>a[j]\n\t\t\t\ttemp=a[j]\n\t\t\t\ta[j]=a[j-1]\n\t\t\t\ta[j-1]=temp\n\t\t\telse\n\t\t\t\tbreak\n\t\t\tend \n\t\t\tj=j-1\n\t\tend\n end \n return a \nend",
"def sort(array, length)\r\n i = 0;\r\n while i < array.length\r\n if array[i] > array[i+1]\r\n j = 0;\r\n while j < array.length\r\n if array[j] > array[i + 1]\r\n temp = array[j];\r\n array[j] = array[i + 1];\r\n array[i + 1] = temp;\r\n end\r\n j++;\r\n end\r\n j++;\r\n end\r\n i++;\r\n end\r\nend",
"def heapsort(list)\n return list if list.length < 2\n\n heap = MinHeap.new\n\n i = 0\n list.each do\n heap.add(list[i])\n i += 1\n end\n\n i = 0\n until i == list.length\n list[i] = heap.remove\n i += 1\n end\n\n return list\nend",
"def bubble_sort array\n\t(0...array.length-1).each do |i|\n\t\t(i+1...array.length).each do |j|\n\t\t\tif array[i]>array[j]\n\t\t\t\tarray[i]=array[i]+array[j]\n\t\t\t\tarray[j]=array[i]-array[j]\n\t\t\t\tarray[i]=array[i]-array[j]\n\t\t\tend\n\t\tend\n\tend\n\tarray\nend"
] |
[
"0.8274053",
"0.815727",
"0.81322116",
"0.8072705",
"0.80661654",
"0.79795754",
"0.7940284",
"0.77989227",
"0.71132994",
"0.67388743",
"0.65879714",
"0.65863705",
"0.6582038",
"0.6489279",
"0.6420688",
"0.634719",
"0.63410753",
"0.6322514",
"0.63135546",
"0.6310764",
"0.6308858",
"0.6283208",
"0.6270316",
"0.62617874",
"0.6237725",
"0.6220147",
"0.6218502",
"0.6204947",
"0.61996806",
"0.61891544",
"0.61829984",
"0.6176353",
"0.61705315",
"0.6148106",
"0.614484",
"0.6142805",
"0.6127019",
"0.61230046",
"0.61222553",
"0.6121457",
"0.6121165",
"0.611673",
"0.6110401",
"0.60945946",
"0.6088024",
"0.60873073",
"0.6083447",
"0.6082556",
"0.6082267",
"0.6077682",
"0.6075421",
"0.60752237",
"0.6073775",
"0.6062639",
"0.6061425",
"0.6059303",
"0.6053075",
"0.60475695",
"0.6043494",
"0.60392606",
"0.6039196",
"0.6038447",
"0.6038426",
"0.602926",
"0.6028066",
"0.6027297",
"0.6024965",
"0.60235786",
"0.602152",
"0.6020921",
"0.6020634",
"0.6013171",
"0.6012945",
"0.601211",
"0.6010829",
"0.60096115",
"0.6005443",
"0.6004891",
"0.6002677",
"0.5988409",
"0.5982748",
"0.59776616",
"0.5972272",
"0.5970942",
"0.5968148",
"0.5965892",
"0.59632534",
"0.59616613",
"0.59573984",
"0.5955953",
"0.5951195",
"0.59476674",
"0.5945554",
"0.5944797",
"0.59440213",
"0.59427977",
"0.5941086",
"0.5940637",
"0.5940604",
"0.5939754"
] |
0.79475796
|
6
|
O(nlogn) but requires much (i.e. O(n)) extra space (and is therefore no better than merge sort).
|
def quick_sort(a)
array = a
# already sorted!
return array if array.length <= 1
pivot = array.length / 2
lower = []
higher = []
array.length.times do |i|
next if i == pivot
if array[i] >= array[pivot]
higher << array[i]
else
lower << array[i]
end
end
return quick_sort(lower) + [array[pivot]] + quick_sort(higher)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def merge_sort(arr)\n cr_size = 1\n while cr_size <= arr.size - 1\n left = 0\n while left < arr.size - 1\n mid = [(left + cr_size - 1), (arr.size - 1)].min\n right = if (2 * cr_size + left - 1) < (arr.size - 1)\n 2 * cr_size + left - 1\n else\n arr.size - 1\n end\n arr[left..right] = merge(arr[left..mid], arr[mid+1..right])\n left += cr_size * 2\n end\n cr_size *= 2\n end\n arr\nend",
"def mergeSort array\n if array.count <= 1\n return array\n end\n\n middle = array.count / 2\n left = mergeSort array.slice(0, middle)\n right = mergeSort array.slice(middle, array.count)\n\n left_offset = 0\n right_offset = 0\n\n while left_offset < left.count && right_offset < right.count\n a = left[left_offset]\n b = right[right_offset]\n\n if a <= b\n array.push a\n left_offset += 1\n else\n array.push b\n right_offset += 1\n end\n end\n return merge(left, right)\nend",
"def mergeSort(array, i, n)\n if n > 1\n mergeSort(array, i, n / 2)\n mergeSort(array, i + n / 2, n - n / 2)\n merge(array, i, n / 2, n - n / 2)\n end\nend",
"def merge_sort(arr)\n n = arr.length\n return if n < 2 # base case for recursion\n mid = (n / 2).floor\n left = Array.new(mid)\n right = Array.new(n-mid)\n\n for i in 0..mid-1\n left[i] = arr[i]\n end\n for j in mid..n-1\n right[j] = arr[j]\n end\n\n merge_sort(left)\n merge_sort(right)\n merge(left, right, arr)\nend",
"def merge_sort(a)\n return a if a.length == 1\n\n n = divide(a, a.length / 2)\n\n half_1 = n.shift\n half_2 = n\n\n return merge(merge_sort(half_1), merge_sort(half_2))\nend",
"def merge_sort(a)\n\tif n == 1\n\t\treturn a\n\tend\n\n\tm = n/2\n\n\tb = merge_sort(a)\n\tc = merge_sort(c)\n\t\n\tresult = merge(b,c)\n\n\treturn result\nend",
"def merge_sort(array)\n if array.size <= 1\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n\n # 1. Divide\n mid = array.size / 2\n part_a = merge_sort(array.slice(0, mid))\n part_b = merge_sort(array.slice(mid, array.size - mid))\n\n\n# 2. Conquer\n array = []\n offset_a = 0\n offset_b = 0\n while offset_a < part_a.count && offset_b < part_b.count\n a = part_a[offset_a]\n b = part_b[offset_b]\n \n if a <= b\n array << a\n offset_a += 1\n else\n array << b\n offset_b += 1\n end\n end\n \n while offset_a < part_a.count\n array << part_a[offset_a]\n offset_a += 1\n end\n \n while offset_b < part_b.count\n array << part_b[offset_b]\n offset_b += 1\n end\n \n return array\nend",
"def merge_sort(array)\n size = 2\n loop do\n n = 0\n main_array = []\n half = size / 2\n loop do\n temp = array[n, size]\n arr1 = temp.take(half)\n arr2 = temp.drop(half)\n main_array += merge(arr1, arr2)\n n += size\n break if n >= array.length\n end\n size *= 2\n array = main_array\n break array if size >= array.length * 2\n end\nend",
"def merge_sort array\n size = array.size\n if size < 2\n array\n else\n merge_array = array.each_slice((size/2.0).round).to_a\n array_a = merge_sort(merge_array[0])\n array_b = merge_sort(merge_array[1])\n new_array = []\n a = 0\n b = 0\n while new_array.size != size\n if array_a.nil? || array_a[a].nil?\n return new_array += array_b[b..-1]\n elsif array_b.nil? || array_b[b].nil?\n return new_array += array_a[a..-1]\n elsif array_a[a] < array_b[b]\n new_array << array_a[a]\n a += 1\n else\n new_array << array_b[b]\n b += 1\n end\n end\n end\nend",
"def merge_sort(arr)\n if arr.length <= 1\n return arr\n else \n mid = arr.length/2\n left = merge_sort(arr.slice(0...mid))\n right = merge_sort(arr.slice(mid...arr.length))\n merge(left, right)\n end \nend",
"def merge_sort(arr)\n \n midpoint = arr.size/2\n sub_list_a = arr[0, midpoint]\n sub_list_b = arr[(midpoint + 1)..(arr.size - 1)]\n \n sub_list_a = merge_sort(sub_list_a) \n sub_list_b = merge_sort(sub_list_b) \n \n merge(sub_list_a, sub_list_b)\n \nend",
"def mergesort(array)\n if array.count <= 1\n # Array of length 1 or less is always sorted\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n\n # 1. Divide\n mid = array.count / 2\n part_a = mergesort array.slice(0, mid)\n part_b = mergesort array.slice(mid, array.count - mid)\n\n # 2. Conquer\n array = []\n offset_a = 0\n offset_b = 0\n while offset_a < part_a.count && offset_b < part_b.count\n a = part_a[offset_a]\n b = part_b[offset_b]\n # Take the smallest of the two, and push it on our array\n if a <= b\n array << a\n offset_a += 1\n else\n array << b\n offset_b += 1\n end\n end\n\n # There is at least one element left in either part_a or part_b (not both)\n while offset_a < part_a.count\n array << part_a[offset_a]\n offset_a += 1\n end\n\n while offset_b < part_b.count\n array << part_b[offset_b]\n offset_b += 1\n end\n\n return array\nend",
"def merge_sort(arr)\n # don't sort an array with length = 1\n if arr.length < 2\n return arr\n end\n\n # grab the middle point\n ind = arr.length / 2\n # recursively call merge_sort\n a1, a2 = merge_sort(arr[0...ind]), merge_sort(arr[ind..-1])\n\n n_arr = []\n\n # sort the sub arrays\n while [a1, a2].none? { |a| a.empty? } do\n if a1[0] < a2[0]\n n_arr << a1.shift\n else\n n_arr << a2.shift\n end\n end\n\n n_arr + a1 + a2\nend",
"def merge_sort(arr)\n return arr if arr.size < 2\n middle = arr.size / 2\n # cut in half for sort selection\n arr1 = merge_sort(arr[0...middle])\n arr2 = merge_sort(arr[middle..-1])\n merge(arr1, arr2)\nend",
"def mergesort(array)\n # Base case\n if array.count <= 1\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n # 1. Divide\n mid = array.count / 2\n left_partition = mergesort array.slice(0, mid)\n right_partition = mergesort array.slice(mid, array.count - mid)\n\n # 2. Conquer\n array = []\n left_lead = 0\n right_lead = 0\n while left_lead < left_partition.count && right_lead < right_partition.count\n a = left_partition[left_lead]\n b = right_partition[right_lead]\n\n # Take the smallest of the two, and push it on our array\n if a <= b\n array << a\n left_lead += 1\n else\n array << b\n right_lead += 1\n end\n end\n\n # Either left or right may have elements left; consume them.\n # (Only one of the following loops will actually be entered.)\n while left_lead < left_partition.count\n array << left_partition[left_lead]\n left_lead += 1\n end\n\n while right_lead < right_partition.count\n array << right_partition[right_lead]\n right_lead += 1\n end\n\n return array\nend",
"def mergesort(array)\n if array.count <= 1\n # Array of length 1 or less is always sorted\n return array\n end\n\n # Apply \"Divide & Conquer\" strategy\n\n # Divide\n mid = array.count / 2\n part_a = mergesort array.slice(0, mid)\n part_b = mergesort array.slice(mid, array.count - mid)\n\n # Conquer\n array = []\n offset_a = 0\n offset_b = 0\n while offset_a < part_a.count && offset_b < part_b.count\n a = part_a[offset_a]\n b = part_b[offset_b]\n\n # Take the smallest of the two, and push it on our array\n if a <= b\n array << a\n offset_a += 1\n else\n array << b\n offset_b += 1\n end\n end\n\n # There is at least one element left in either part_a or part_b (not both)\n while offset_a < part_a.count\n array << part_a[offset_a]\n offset_a += 1\n end\n\n while offset_b < part_b.count\n array << part_b[offset_b]\n offset_b += 1\n end\n\n return array\nend",
"def merge_sort( arr )\n return arr if arr.length == 1\n\n mid = arr.length / 2\n\n arr1 = merge_sort( arr[0...mid] )\n arr2 = merge_sort( arr[mid..-1] )\n\n sort_and_merge( arr1, arr2 )\nend",
"def mergesort(array)\n if array.count <= 1\n return array\n end \n middle = array.count/2 \n return merge(mergesort(array[0, middle]), mergesort(array[middle, array.count]))\nend",
"def merge_sort array\n return array if array.length <= 1\n # arr1, arr2 = array.each_slice((array.size/2.0).round).to_a # Seems to be a bit slower than the method below\n arr1 = array[0..((array.length/2 - 1))]\n arr2 = array[(array.length/2)..(array.length-1)]\n return merge_arrays(merge_sort(arr1), merge_sort(arr2)) # Divide and conquer!\nend",
"def merge_sort(arr)\n if arr.length < 2\n arr\n else\n sorted = []\n left = merge_sort(arr[0..arr.length / 2 - 1])\n right = merge_sort(arr[arr.length / 2..-1])\n while left[0] && right[0]\n sorted << (left[0] > right[0] ? right.shift : left.shift)\n end\n sorted += left + right\n end\nend",
"def merge_sort(array)\r\n return array if array.length <= 1\r\n\r\n mid = array.length / 2\r\n\r\n left = merge_sort(array.take(mid)),\r\n right = merge_sort(array.drop(mid))\r\n merge(left, right)\r\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n middle_idx = arr.length / 2\n\n left = arr[0...middle_idx]\n right = arr[middle_idx..-1]\n\n merge(merge_sort(left), merge_sort(right))\n\nend",
"def MergeSort(a)\n if a.length <= 1\n return a\n end\n middle = a.length/2\n left = a[0..middle-1]\n right = a[middle..-1]\n\n left = MergeSort(left)\n right = MergeSort(right)\n sorted_array = merge(left,right)\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left, right= arr.take(mid), arr.drop(mid)\n sorted_left, sorted_right = merge_sort(left), merge_sort(right)\n\n merge(sorted_left, sorted_right)\nend",
"def merge_sort(array)\n return array if array.length <= 1\n\n mid_point = array.length / 2\n\n left_hand = merge_sort(array.take(mid_point))\n right_hand = merge_sort(array.drop(mid_point))\n\n merge_sort_compare(left_hand, right_hand)\n #left_hand + right_hand\nend",
"def merge_sort(array, start_index, end_index)\n if start_index < end_index\n middle_index = (start_index + end_index)/2\n merge_sort(array, start_index, middle_index)\n merge_sort(array, middle_index + 1, end_index)\n merge(array, start_index, middle_index, end_index)\n end\nend",
"def merge_sort(array)\n return array if array.length < 2\n midpoint = array.length / 2\n merge(merge_sort(array[0...midpoint]), merge_sort(array[midpoint..-1]))\nend",
"def merge_sort(array)\n low = 0\n high = array.length - 1\n\n # // divide the array into blocks of size m\n # // m = [1, 2, 4, 8, 16...]\n m = 1\n while m <= (high-low)\n i = low\n while i < high\n from = i\n mid = i + m - 1\n if i + (2 * m) - 1 < high\n to = i + (2 * m) - 1\n else\n to = high\n end\n\n array = merge(array, from, mid, to)\n i = i + (2*m)\n end\n m = 2*m\n end\n array\nend",
"def merge_sort(a)\n return a if a.length <= 1\n\n half_length = a.length / 2\n front = a.take half_length\n back = a.drop half_length\n\n combine(merge_sort(front), merge_sort(back))\nend",
"def merge_sort(arr)\n return arr if arr.length == 1 \n mid = (arr.length/2).floor\n left = merge_sort(arr[0..mid - 1])\n right = merge_sort(arr[mid..-1])\n merge(left, right)\nend",
"def merge_sort(array)\n if array.length <= 1\n return array\n end\n merge(merge_sort(array[0...array.length/2]), merge_sort(array[array.length/2...array.length]))\nend",
"def merge(arr1, arr2)\n return arr2 if arr1.size < 1\n return arr1 if arr2.size < 1\n\n merged_lists = []\n counter1 = 0\n counter2 = 0\n iterations = arr1.size + arr2.size\n\n iterations.times do |n|\n if arr1[counter1] == nil\n merged_lists << arr2[counter2]\n elsif arr2[counter2] == nil\n merged_lists << arr1[counter1]\n elsif arr1[counter1] <= arr2[counter2]\n merged_lists << arr1[counter1]\n counter1 += 1\n else\n merged_lists << arr2[counter2]\n counter2 += 1\n end\n end\n\n merged_lists\nend",
"def merge_sort(array)\n length_of_array = array.length\n\n if length_of_array < 2\n sorted_array = array\n return sorted_array\n end\n\n array_half_a = array.slice(0, (length_of_array.to_f / 2).round)\n array_half_b = array.slice((length_of_array.to_f / 2).round, length_of_array / 2)\n sorted_array_a = merge_sort(array_half_a)\n sorted_array_b = merge_sort(array_half_b)\n merged_sorted_array = []\n index_array_a = 0\n index_array_b = 0\n\n while index_array_a < sorted_array_a.length && index_array_b < sorted_array_b.length\n if sorted_array_a[index_array_a] < sorted_array_b[index_array_b]\n merged_sorted_array << sorted_array_a[index_array_a]\n index_array_a += 1\n else\n merged_sorted_array << sorted_array_b[index_array_b]\n index_array_b += 1\n end\n end\n\n merged_sorted_array += if index_array_a == sorted_array_a.length\n sorted_array_b.slice(index_array_b, sorted_array_b.length)\n else\n sorted_array_a.slice(index_array_a, sorted_array_a.length)\n end\n\n merged_sorted_array\nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n mid_idx = arr.length/2\n left = arr[0...mid_idx]\n right = arr[mid_idx..-1]\n return merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(array)\n return array if array.length <= 1 \n mid = array.length / 2\n sorted_left = merge_sort(array.take(mid))\n sorted_right = merge_sort(array.drop(mid))\n \n merge(sorted_left, sorted_right)\n \nend",
"def merge_sort(lst)\n if lst.length <= 1\n lst\n else\n mid = (lst.length / 2).floor\n left = merge_sort(lst[0..mid - 1])\n right = merge_sort(lst[mid..lst.length])\n merge(left, right)\n end\nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n\n arr1 = merge_sort(arr.take(arr.length/2))\n arr2 = merge_sort(arr.drop(arr.length/2))\n\n return merge(arr1,arr2)\nend",
"def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n middle = arr.length / 2\n half1 = arr[0...middle]\n half2 = arr[middle..-1]\n merge(merge_sort(half1), merge_sort(half2))\nend",
"def merge_sort(array)\n return array if array.length == 1\n l, r = array.take(array.count / 2), array.drop(array.count / 2)\n merge(merge_sort(l), merge_sort(r))\nend",
"def merge_sort(array)\n return array if array.size <= 1\n mid = array.size / 2\n left = array[0...mid]\n right = array[mid...array.size]\n merge(merge_sort(left), merge_sort(right))\nend",
"def mergesort(list)\n return list if list.size <= 1\n mid = list.size / 2\n left = list[0...mid]\n right = list[mid...list.size]\n merge(mergesort(left), mergesort(right))\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left = merge_sort(arr[0...mid])\n right = merge_sort(arr[mid..-1])\n merge(left, right)\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle..-1]\n merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n mid = arr.length / 2\n\n left = arr[0...mid]\n right = arr[mid..-1]\n\n my_merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(ary)\n# base case\n return ary if ary.size < 2\n\n# divide(recursively dividing the array)\n left = merge_sort(ary[0...ary.size/2])\n right = merge_sort(ary[ary.size/2...ary.size])\n\n sorted = []\n# conquer(sort)\n while left.length > 0 && right.length > 0\n# until left.empty? || right.empty? # until one array is empty. In other words, when both are not empty.\n sorted << (left.first > right.first ? right.shift : left.shift)\n end\n\n# if one of the array is empty, add the other array to the sorted list\n left.empty? ? sorted += right : sorted += left\nend",
"def merge_sort(nums)\n len = nums.length\n return nums if len < 2\n mid_index = len / 2\n\n left_sorted = merge_sort(nums[0...mid_index])\n right_sorted = merge_sort(nums[mid_index...len])\n merge(left_sorted, right_sorted)\nend",
"def merge_sort(arr)\n if arr.length == 1\n return arr\n elsif arr.empty?\n return arr\n else\n first_half = merge_sort(arr[0..arr.length/2-1])\n second_half = merge_sort(arr[arr.length/2..-1])\n sorted_array = []\n idx_first = 0\n idx_second = 0\n until idx_first == first_half.length || idx_second == second_half.length\n if first_half[idx_first] < second_half[idx_second]\n sorted_array << first_half[idx_first]\n idx_first += 1\n elsif first_half[idx_first] > second_half[idx_second]\n sorted_array << second_half[idx_second]\n idx_second += 1\n end\n end\n\n if idx_first == first_half.length\n sorted_array += second_half[idx_second..-1]\n else sorted_array += first_half[idx_first..-1]\n end\n return sorted_array\n end\nend",
"def merge_sort(array)\n return array if array.length == 1\n mid = array.length / 2\n merge(merge_sort(array[0..mid -1]), merge_sort(array[(mid)..-1]))\nend",
"def merge_sort(array)\n return array if array.length <= 1\n middle = array.length / 2\n merge(merge_sort(array[0...middle]), merge_sort(array[middle..-1]))\nend",
"def merge_sort(array)\n return array if array.length == 1\n\n # Divide & conquer\n half1 = merge_sort(array[0..array.length/2 - 1])\n half2 = merge_sort(array[array.length/2..-1])\n\n # Initialize result array\n sorted = []\n \n while half1.length > 0 && half2.length > 0\n if half1[0] <= half2[0]\n sorted << half1.shift\n else\n sorted << half2.shift\n end\n end\n if half1.length > 0\n sorted.concat half1\n elsif half2.length > 0\n sorted.concat half2\n end\n \n return sorted\nend",
"def merge_sort(list)\n if list.length <= 1\n list\n else\n mid = (list.length / 2).floor\n left = merge_sort(list[0..mid - 1])\n right = merge_sort(list[mid..list.length])\n merge(left, right)\n end\nend",
"def insertionsort! arr\n (1..arr.size - 1).each do |i|\n j = i\n while j > 0 && arr[j] < arr[j - 1] do\n arr[j], arr[j - 1] = arr[j - 1], arr[j]\n j -= 1\n end\n end\n arr\nend",
"def merge_sort(array)\n \n middle = array.length/2-1\n left = [0..middle]\n right = [middle+1..[-1]]\n merge_sort(left) + merge_sort(right)\nend",
"def mergeSort(arr)\n\n if (arr.length == 1)\n return arr\n end\n\n center = (arr.length / 2).floor\n left = arr[0...center] # takes values from 0 to center excluding the center index\n right = arr[center...arr.length] # takes values from center to end\n\n return merge( mergeSort(left), mergeSort(right) )\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left = merge_sort(arr[0...mid])\n right = merge_sort(arr[mid..-1])\n\n merge(left, right)\nend",
"def merge_sort(arr)\n return arr if arr.size < 2\n middle = arr.size / 2\n left = merge_sort(arr[0...middle])\n right = merge_sort(arr[middle..arr.size])\n merge(left, right)\n end",
"def merge_sort(arr)\n # [6]\n # arr[0] > arr[1]\n # arr[0], arr[1] = arr[1], arr[0]\n return arr if arr.length <= 1\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle..-1]\n a = merge_sort(left) \n b = merge_sort(right)\n merge(a,b)\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n first_half = arr[0...(arr.length / 2)]\n second_half = arr[(arr.length / 2)..-1]\n merge(merge_sort(first_half), merge_sort(second_half))\nend",
"def merge_sort(array)\r\n\tif array.length > 1\r\n\t\tleft_array = []\r\n\t\t\t(array.length/2).times { left_array << array.shift }\r\n\t\tright_array = array\r\n\t\tleft_sorted = merge_sort(left_array)\r\n\t\tright_sorted = merge_sort(right_array)\r\n\t\tresult = []\r\n\t\twhile left_sorted.length>0 && right_sorted.length>0\r\n\t\t\tif left_sorted[0] <= right_sorted[0]\r\n\t\t\t\tresult << left_sorted.shift\r\n\t\t\telse\r\n\t\t\t\tresult << right_sorted.shift\r\n\t\t\tend\r\n\t\tend\r\n\t\tif left_sorted.length>0\r\n\t\t\tleft_sorted.each { |e| result << e }\r\n\t\telsif right_sorted.length>0\r\n\t\t\tright_sorted.each { |e| result << e }\r\n\t\tend\r\n\t\treturn result\r\n\telse\r\n\t\treturn array\r\n\tend\r\nend",
"def merge_sort(array)\n # we split the array into 1 element long arrays\n return array if array.length <= 1\n\n mid = array.length / 2\n left = merge_sort(array[0..mid - 1])\n right = merge_sort(array[mid..-1])\n # once we have 1 element long arrays we start merging them\n if left.last <= right.first\n left + right\n else\n merge(left, right)\n end\n end",
"def merge_sorted(a, b)\n idx1 = 0\n idx1 += 1 until a[idx1 + 1].nil?\n idx2 = b.length - 1\n \n curr_idx = a.length - 1 - (a.length - (idx1 + idx2 + 2))\n \n while curr_idx >= 0\n if idx1 < 0 || (b[idx2] > a[idx1] && idx2 >= 0)\n a[curr_idx] = b[idx2]\n idx2 -= 1\n else\n a[curr_idx] = a[idx1]\n idx1 -= 1\n end\n\n curr_idx -= 1\n end\n a\nend",
"def merge_sort (array, &prc)\n return array if array.length <= 1\n\n mid_idx = array.length / 2\n merge(\n merge_sort(array.take(mid_idx), &prc),\n merge_sort(array.drop(mid_idx), &prc),\n &prc\n )\nend",
"def merge_sort(nums)\n # Base case, no sorting to do on a single element, collapses recursion branch\n return nums if nums.length <= 1\n # Divide\n a = nums[0..(nums.length/2)-1]\n b = nums[(nums.length/2)..-1]\n # Conquer\n result = merge(merge_sort(a), merge_sort(b))\nend",
"def merge_sort(list)\n return list if list.length <= 1\n\n middle = list.length / 2\n left = list[0..middle - 1]\n right = list[middle..-1]\n left = merge_sort(left)\n right = merge_sort(right)\n merge(left, right)\nend",
"def merge_sort(array)\n return [] if array.length == 0\n return array if array.length == 1\n middle_idx = array.length / 2\n arr_1 = array[0...middle_idx]\n arr_2 = array[middle_idx..-1]\n merge(merge_sort(arr_1), merge_sort(arr_2))\nend",
"def fast_sort(array, left_index, right_index)\n if left_index < right_index\n key = array[left_index]\n key_index = left_index\n (left_index + 1..right_index).each do |index|\n if array[index] < key\n temp = array[index]\n array.delete_at(index)\n array.insert(key_index, temp)\n key_index += 1\n end\n end\n fast_sort(array, left_index, key_index-1)\n fast_sort(array, key_index + 1, right_index)\n end\nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n middle_index = arr.length / 2\n one_half = arr[0...middle_index]\n two_half = arr[middle_index..-1]\n merge(merge_sort(one_half), merge_sort(two_half))\nend",
"def merge_sort(arr)\n return arr if arr.length == 1\n\n half_idx = arr.length / 2\n first_half = arr[0...half_idx]\n second_half = arr[half_idx..-1]\n\n merge(merge_sort(first_half), merge_sort(second_half))\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n mid_idx = arr.length / 2 # this is really for breaking down the array into singletons\n left_side = arr[0...mid_idx]\n right_side = arr[mid_idx..-1]\n\n left = merge_sort(left_side)\n right = merge_sort(right_side)\n\n merge(left, right) # this does the actual sorting\nend",
"def merge_sort(array)\n return array if array.length <= 1\n mid = array.length / 2\n left = merge_sort(array[0...mid])\n right = merge_sort(array[mid..-1])\n merge(left, right)\nend",
"def mergeSort(arr)\n\tif arr.length == 1\n\t\treturn arr\n\tend\n\n\tmidpoint = arr.length/2.round\n\tleft = arr[0...midpoint]\n\tright = arr[midpoint..-1]\n\tleft = mergeSort(left) #[4,6]\n\tright = mergeSort(right) #[8, 2]\n\n\treturn merge(left, right)\nend",
"def merge_sort arr\n if arr.size > 1\n mid = arr.size / 2\n left = arr[0, mid]\n right = arr[mid, arr.size-mid]\n \n merge_sort(left)\n merge_sort(right)\n\n i,j,k = 0,0,0\n\n while (i < left.size and j < right.size) do\n if left[i] < right[j]\n arr[k] = left[i]\n i+=1\n else\n arr[k] = right[j]\n j+=1\n end\n k+=1\n end\n\n while i < left.size do\n arr[k] = left[i]\n i+=1\n k+=1\n end\n\n while j < right.size do\n arr[k] = right[j]\n j+=1\n k+=1\n end\n\n end\nend",
"def merge_sort(array)\n return array if array.length == 1\n mid = (array.length - 1)/ 2\n left = array[0..mid]\n right = array[mid+1..array.length-1]\n merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(array)\n return array if array.length <= 1\n middle = array.length / 2\n sorted_left = merge_sort(array[0...middle])\n sorted_right = merge_sort(array[middle..-1])\n merge(sorted_right, sorted_left)\nend",
"def insertion_sort(array)\n # Takes n passes here.\n (1...array.size).each{ |i|\n j = i\n # and this also takes n, but the distance of the count decreases\n # each time.\n while j > 0 and array[j - 1] > array[j]\n temp = array[j]\n array[j] = array[j-1]\n array[j-1] = temp\n\n j -= 1\n end\n }\n array\nend",
"def merge_sort(arr)\n if arr.length == 1\n return arr\n end\n mid = arr.length / 2\n left = arr[0...mid]\n right = arr[mid..-1]\n\n left_half = merge_sort(left)\n right_half = merge_sort(right)\n merge(left_half,right_half)\nend",
"def merge_sort(array)\n return array if array.length <= 1\n mid = array.length/2\n\n left = merge_sort(array[0...mid])\n right = merge_sort(array[mid..-1])\n\n merge(left, right)\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n \n mid = arr.length / 2\n left, right = arr[0...mid], arr[mid..-1]\n left, right = merge_sort(left), merge_sort(right)\n\n merge(left, right)\nend",
"def merge_sort(array=@base)\n return array if array.size < 2\n mid = array.size/2\n left = array[0..mid-1]\n right = array[mid..-1]\n\n left_merge = merge_sort(left)\n right_merge = merge_sort(right)\n merge_sort_merge(left_merge, right_merge)\n end",
"def merge_sort(array)\n return array if array.length <= 1\n mid = array.size / 2\n left = array[0...mid]\n right = array[mid..-1]\n sorted_left = merge_sort(left)\n sorted_right = merge_sort(right)\n return merge(sorted_left, sorted_right)\nend",
"def merge_sort(numbers)\n return numbers if numbers.size == 1\n mid = numbers.size / 2\n left = numbers[0...mid]\n right = numbers[mid..-1]\n merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(numbers)\n return numbers if numbers.size == 1\n mid = numbers.size / 2\n left = numbers[0...mid]\n right = numbers[mid..-1]\n merge(merge_sort(left), merge_sort(right))\nend",
"def merge(left, right, i)\n sorted = []\n reference = i == 3 ? 1 : 0\n while !left.empty? && !right.empty?\n if left.first[reference] < right.first[reference] || right.empty?\n sorted.push(left.shift)\n elsif right.first[reference] <= left.first[reference] || left.empty?\n sorted.push(right.shift)\n end\n end\n right.each { |el| sorted.push(el) } unless right.empty?\n left.each { |el| sorted.push(el) } unless left.empty?\n sorted\nend",
"def merge_sort(array)\n return array if array.size == 1\n left_array,right_array = array.each_slice( (array.size/2.0).round ).to_a\n arr1 = merge_sort(left_array)\n arr2 = merge_sort(right_array)\n arr = merge(arr1, arr2)\n arr\nend",
"def sorted_merge(a, b)\n i = 0\n until b.empty?\n if a[i].nil? || b[0] <= a[i]\n shift(a, i)\n a[i] = b.delete_at(0)\n end\n i += 1\n end\n a\nend",
"def merge_sort list\n midpoint = list.length/2\n\n if list.length < 2\n return list\n else\n list_left = list[0..(midpoint - 1)]\n list_right = list[midpoint..-1]\n\n list_left = merge_sort(list_left)\n list_right = merge_sort(list_right)\n\n return result = merge_lists(list_left, list_right)\n end\nend",
"def merge_sort(array)\n total_length = array.length\n size = 2\n while size < total_length + 1\n sorted_array = []\n array.each_slice(size).to_a.each do |group|\n slice1 = group[0...(group.length / 2)]\n slice2 = group[(group.length / 2)..-1]\n combined = []\n \n while slice1.length > 0 || slice2.length > 0\n \n if slice1.empty? == false\n if slice2.empty? || slice1.first < slice2.first\n combined << slice1.shift\n elsif slice1.first == slice2.first\n combined << slice1.shift\n combined << slice2.shift\n else\n combined << slice2.shift\n end\n \n elsif slice2.empty? == false\n if slice1.empty? || slice2.first < slice1.first\n combined << slice2.shift\n elsif slice1.first == slice2.first\n combined << slice1.shift\n combined << slice2.shift\n else\n combined << slice1.shift\n end\n end\n end\n sorted_array << combined\n end\n array = sorted_array.flatten\n size += 2\n end\n p array\nend",
"def mergesort(elements)\n\t#Base Case \n return elements if elements.size == 1\n\n #Divide \n mid = elements.size / 2\n left = elements[0, mid]\n right = elements[mid, elements.size]\n \n left_sorted = mergesort(left)\n right_sorted = mergesort(right)\n\n #Conquer\n merge(left_sorted,right_sorted)\nend",
"def msort(arr)\n n = arr.length / 2\n if (n == 0)\n arr\n else\n merge msort(arr[0..n-1]), msort(arr[n..arr.length])\n end\nend",
"def merge_sort(array)\r\n if array.size == 1\r\n return array\r\n end\r\n\r\n arr1 = merge_sort(array[0...(array.length/2)])\r\n arr2 = merge_sort(array[(array.length/2)..-1])\r\n\r\n return merge1(arr1, arr2)\r\nend",
"def merge_sort(list)\n length = list.length\n\n if length <= 1\n\treturn list\n end\n \n mid = length/2\n a = list.slice(0...mid)\n b = list.slice(mid..-1)\n ma = merge_sort(a)\n mb = merge_sort(b)\n\n merge(ma, mb)\n end",
"def merge_sort(arr)\n return arr if arr.length <= 1\n left_half = arr[0...arr.length/2]\n right_half = arr[arr.length/2..-1]\n\n left = merge_sort(left_half) \n right = merge_sort(right_half)\n merge(left, right)\n \nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n middle_index = arr.length / 2\n left_arr = merge_sort(arr[0...middle_index])\n right_arr = merge_sort(arr[middle_index..-1])\n merge_fn(left_arr,right_arr)\nend",
"def mergeSort(arr)\n puts \"Running merge sort on array: \" + arr.to_s\n temp = copyArr(arr)\n #this block determines what the subproblems that should be merged are\n splitMerge(temp, 1, arr) do |a, t, n|\n if n == 1\n return a\n end\n jump = a.length/n\n i = 0\n while i < a.length\n lo = i\n mid = (i + jump) - 1\n hi = mid + jump\n merge(a, lo, mid, hi, t)\n i = i + (jump*2)\n end\n t\n end\nend",
"def merge_sort(arr)\n if arr.length <= 2\n return merge(arr[0], arr[-1])\n end\nend",
"def sort(arr)\n return arr unless arr.size > 1\n\n mid = arr.size / 2\n left, right = sort(arr[0...mid]), sort(arr[mid..-1])\n\n merge(left, right)\nend",
"def merge(arr, start_i, mid_i, end_i)\n sorted_arr = Array.new(end_i - start_i + 1, 0)\n i, j, k = start_i, mid_i, 0\n while i <= mid_i && j <= end_i\n if arr[i] < arr[j]\n sorted_arr[k] = arr[i]\n k += 1\n i += 1\n else\n sorted_arr[k] = arr[j]\n k += 1\n j += 1\n end\n end\n while i <= mid_i\n sorted_arr[k] = arr[i]\n k += 1\n i += 1\n end\n while j <= end_i\n sorted_arr[k] = arr[j]\n k += 1\n j += 1\n end\n sorted_arr\nend",
"def merge_sort(collection)\n if collection.length <= 1\n collection\n else\n mid = (collection.length / 2).floor\n left = merge_sort(collection[0..mid - 1])\n right = merge_sort(collection[mid..collection.length])\n merge(left, right)\n end\n end",
"def iterative_insertion_sort(arr)\r\n 1.upto(arr.length - 1) do |index|\r\n key = arr[index]\r\n pos = index - 1\r\n while pos >= 0 && key <= arr[pos]\r\n # this could also have been written by swapping repeatedly\r\n # instead of copying the bigger element to the empty slot\r\n arr[pos + 1] = arr[pos]\r\n pos = pos - 1\r\n end\r\n arr[pos + 1] = key\r\n end\r\n arr\r\nend",
"def merge_sort(array)\n return array if array.length < 2\n middle_idx = array.length / 2\n first_half = array.take middle_idx\n last_half = array.drop middle_idx\n\n merge_helper(merge_sort(first_half), merge_sort(last_half))\nend"
] |
[
"0.7339264",
"0.73165697",
"0.7294283",
"0.71749157",
"0.7169672",
"0.7167471",
"0.7110195",
"0.71067613",
"0.7083156",
"0.7082487",
"0.7074356",
"0.7057483",
"0.7050273",
"0.7022806",
"0.7019256",
"0.7013537",
"0.70094925",
"0.7003089",
"0.700068",
"0.6993116",
"0.6959356",
"0.695908",
"0.69556576",
"0.69432694",
"0.6930677",
"0.6924095",
"0.6923991",
"0.6922508",
"0.6908786",
"0.69056994",
"0.68991417",
"0.689867",
"0.6897376",
"0.68960536",
"0.6891515",
"0.6885101",
"0.68778396",
"0.68682814",
"0.6867474",
"0.68639463",
"0.6863076",
"0.68600845",
"0.6855701",
"0.6853079",
"0.6849454",
"0.6846927",
"0.6845253",
"0.6834386",
"0.68336195",
"0.68334806",
"0.6831446",
"0.68206674",
"0.6815053",
"0.68136936",
"0.680053",
"0.67954046",
"0.6787444",
"0.6785536",
"0.6777934",
"0.6774046",
"0.677058",
"0.676994",
"0.6759022",
"0.67573386",
"0.67550147",
"0.67509943",
"0.6745888",
"0.6741462",
"0.6739601",
"0.6738047",
"0.6737219",
"0.6734514",
"0.67297566",
"0.67219293",
"0.67184633",
"0.6718317",
"0.6718031",
"0.6705795",
"0.670144",
"0.6693166",
"0.66877466",
"0.66854936",
"0.66854936",
"0.66829586",
"0.6680054",
"0.66790575",
"0.6664713",
"0.66633916",
"0.66578114",
"0.6654542",
"0.6651722",
"0.6648436",
"0.66438836",
"0.6641134",
"0.6636296",
"0.66360664",
"0.6635175",
"0.66338366",
"0.66333383",
"0.6606256",
"0.65986544"
] |
0.0
|
-1
|
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_mailer.new_user.subject
|
def new_user(user, password)
@user = user
@password = password
mail to: user.email, subject: "[IMD- UFRN] Nova Conta no Gerenciador de Espaço Físico"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def message_subject=(value)\n @message_subject = value\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end",
"def subject=(subject); @message_impl.setSubject subject; end",
"def subject=(string)\n set('Subject', string)\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def subject_name=(value)\n @subject_name = value\n end",
"def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def user_added_email(user)\n ActsAsTenant.without_tenant do\n @course = user.course\n end\n @recipient = user.user\n\n I18n.with_locale(@recipient.locale) do\n mail(to: @recipient.email, subject: t('.subject', course: @course.title))\n end\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end",
"def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject_name\n subject_full_name\n end",
"def subject_name\n return @subject_name\n end",
"def set_subject(subject)\n\t\tend",
"def subject\n @options.fetch(:subject) { \"Invitation\" }\n end",
"def subject\n @mail.subject\n end",
"def subject\n self['subject']\n end",
"def subject\n message.subject\n end",
"def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def user_added_email(course, user)\n @course = course\n @recipient = user.user\n\n mail(to: @recipient.email, subject: t('.subject', course: @course.title))\n end",
"def get_email_subject(email_type)\n email_subject = email_type\n case(email_type)\n when \"welcome\"\n email_subject = \"Welcome to Aspera Files\"\n when \"reset\"\n email_subject = \"Password Reset\"\n end\n return email_subject\n end",
"def SetSubject(subject)\n\t\t#Subject of document\n\t\t@subject = subject\n\tend",
"def subject; @message_impl.getSubject; end",
"def custom_mail( user, subject, title, contents )\n @user = user\n @host = GogglesCore::AppConstants::WEB_MAIN_DOMAIN_NAME\n @contents = contents\n @title = title\n #subject: \"[#{ GogglesCore::AppConstants::WEB_APP_NAME }@#{ @host }] #{ subject }\",\n mail(\n subject: \"#{ subject } [#{GogglesCore::AppConstants::WEB_APP_NAME}]\",\n to: user.email,\n date: Time.now\n )\n end",
"def set_subject\n @subject = User.find(params[:id])\n end",
"def message_subject\n return @message_subject\n end",
"def subject\n title \n end",
"def get_subject\n\t\tend",
"def set_user_subject\n @user_subject = UserSubject.find(params[:id])\n end",
"def user_created(user)\n @user = user\n user_email_id = user.email\n mail to: \"#{user_email_id}\",subject: \"Account Has been created #{user.firstname + \" \" + user.lastname}\"\n end",
"def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def set_subject_and_message(form, subject, message)\n raise Impostor::MissingTemplateMethodError.new(\"set_subject_and_message must be implemented\")\n end",
"def newcompany_email(company)\n @company = company\n @message = t('mailers.company.created')\n \n emails = AdminUser.all.collect(&:email).join(\",\")\n\n mail(:to => emails, :subject => \"#{t('site_title')}: #{@message}\")\n \n end",
"def newsletter(user, subject, text)\n @user = user\n @text = text\n\n mail(to: user.email, subject: subject)\n end",
"def reminder_email(user)\n @user = user\n I18n.with_locale user.locale do\n mail to: @user.email\n end\n end",
"def admin_create_user_email(user)\n @user = user\n mail :to => \"#{user.name} <#{user.email}>\", :subject => \"An Account Has Been Created For You\"\n end",
"def set_title\n @title = t(:message_2, :scope => [:controller, :exams])\n end",
"def setup_email(user)\n @recipients = \"#{user.email}\"\n @from = AppConfig.app_email\n @subject = \"[#{AppConfig.app_name}] \"\n @sent_on = Time.now\n @body[:user] = user\n end",
"def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end",
"def normalize_subject_name\n self.subject = subject.downcase.titleize\n end",
"def subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end",
"def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end",
"def sign_up(new_user)\n @user = new_user\n @notify_subject = strip_tags \"NEW SIGN UP AT #{ENV['APPLICATION_CONFIG_name']}\"\n mail( :to => ENV['APPLICATION_CONFIG_admin_notification_address'], :subject => @notify_subject)\n end",
"def i18n_label\n \"email.#{name}_label\"\n end",
"def email_subject(&blk)\n @email_subject_block = blk if blk\n @email_subject_block\n end",
"def create_subject(options = {})\n default_values = { :name => 'Test subject' }\n Subject.create(default_values.merge(options))\n end",
"def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end",
"def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end",
"def subject\n @subject=EzCrypto::Name.new(@cert.subject) unless @subject\n @subject\n end",
"def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\n email_subject = \"Payroll report for #{sponsor_name}: #{display_date}\"\n end\n return email_subject\n end",
"def notify_course_teaching_assignment( user , course ) \n @course = course\n @subject = @course.subject \n @school = @subject.school\n @user = user\n mail( :to => user.email, \n :subject => \"potoSchool | Tuga Mengajar pelajaran #{@subject.name}, kelas #{@course.name} \" )\n end",
"def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end",
"def send_ta_notification(user, msg)\n\t\t@user = user\n\t\t@msg = msg\n\t\tmail( :to => @user.email, :subject => 'You have just been assigned to a course!')\n\tend",
"def user_rejected_email(course, user)\n ActsAsTenant.without_tenant do\n @course = course\n end\n @recipient = user\n\n I18n.with_locale(@recipient.locale) do\n mail(to: @recipient.email, subject: t('.subject', course: @course.title))\n end\n end",
"def send_signup_email(user)\n @user = user\n mail(to: @user.email, subject: \"Welcome to blah blah blah #{@user.first_name}\")\n end",
"def new\n @subject = current_user.subjects.where(project_id: @project.id).new(subject_params)\n end",
"def user_new(user)\n @user = user\n\n mail to: \"nandisuper2@gmail.com\" ,\n subject: \"New User Created!!\"\n end",
"def new_participant(user, testmail=nil)\n @user = user\n @study = user.study\n email_with_name = testmail || \"#{@user.name} <#{user.email}>\"\n mail(:to => email_with_name, :subject => I18n.t('users.participant.new.mail.subject', :study => @study.title))\n end",
"def get_subject_name\n subject_name = subject_header.text.sub! 'Subject:', ''\n subject_name = subject_name.strip!\n subject_name\n end",
"def new_contact_intro_email(user, contact)\n if user.name.present?\n @name = user.name.titlecase\n else\n @name = user.email\n end\n\n @signature = user.signature\n @email = user.email\n\n mail to: contact.email, reply_to: @email, from: \"\\\"#{@name}\\\" <#{@email}>\", subject: \"#{@name} wants to stay in touch with you!\"\n Email.create(:user_id => user.id, :sent_to => contact.id, :title => \"new_contact_intro_email\", :contacts => contact.id)\n end",
"def confirm_creation(user, welcome_message, host)\n locale = user.locale.blank? ? Ubiquo.default_locale : user.locale\n subject I18n.t('ubiquo.auth.new_user_created', \n :app_title => Ubiquo::Config.get(:app_title), \n :locale => locale)\n recipients user.email\n from Ubiquo::Config.get(:notifier_email_from)\n \n body :user => user, :host => host, :welcome_message => welcome_message, :locale => locale\n end",
"def set_subject\n @subject = Subject.friendly.find(params[:id])\n end",
"def data_subject=(value)\n @data_subject = value\n end",
"def subject\n @subject\n end",
"def subject\n @subject\n end",
"def subject\n @subject\n end",
"def signup_notification(user)\n setup_email(user)\n @subject += I18n.t 'mailer.signup.subject'\n \n @body[:url] = \"http://www.dripplet.com/#{user.locale}/activate/#{user.activation_code}\"\n \n end",
"def send_signup_email(user)\n\t\tuser = user\n subject = \"Thank you for sign up on miniflix.\"\n merge_vars = {\n \"USER_NAME\" => user.name\n }\n body = mandrill_template(\"Paid-user-signup-mail\", merge_vars)\n\n send_mail(user.email, subject, body)\n\tend",
"def new_user(user) \n @user = user\n if Rails.env.production?\n \tmail to: \"info@showandtour.com\", subject: \"New User Signup!\"\n else\n \tmail to: \"foster154@gmail.com\", subject: \"(DEV) New User Signup!\"\n\t\tend\n end",
"def welcome_email(resource)\n \n @resource = resource\n\n mail :to => @resource.email, :from => \"email@domain.com\", :subject => \"Subject line\"\n \n end",
"def subject_params\n params[:subject].permit(:name, :user_id, :user)\n end",
"def generate_message(user)\n message = {\n subject: 'Test',\n from_name: 'The Digest!',\n text: 'This is a testing email',\n to: [\n {\n email: user.email,\n name: user.firstname\n }\n ],\n\n html: '',\n from_email: 'admin@thedigest.com'\n }\n end",
"def adhoc_test_subj_call\n ->(candidate) { I18n.t('email.test_adhoc_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def signup_email(user)\n mail(\n to: \"terry.p.dignon@gmail.com\",\n subject: 'Thanks for signing up'\n )\n end",
"def subject_titles\n @subject_titles ||= sw_subject_titles\n end",
"def signup_notification(user)\n\t\tsetup_email(user)\n\t\t subject self.site_name+\" : \"+I18n.t('mailer.signup_notification.subject')\n\t\t body :url => self.daurl+\"/admin/activate/#{user.activation_code}\",\n\t\t\t:site => self.site_name,\n\t\t\t:user_login => user.login,\n\t\t\t:user_password => user.password\n end",
"def getEmailDefaults(subject, toEmail, ccEmail = nil)\n if Rails.env.eql? 'development'\n subject = \"[BASL-DEV] #{subject}\"\n toEmail = 'paigepon@gmail.com'\n ccEmail = toEmail\n else\n subject = \"[BASL] #{subject}\"\n end\n mailInfo = {\n :to => toEmail,\n :subject => subject,\n :cc => ccEmail\n }\n mailInfo\n end"
] |
[
"0.6990674",
"0.6856709",
"0.67584145",
"0.67539895",
"0.67429304",
"0.67183256",
"0.66673976",
"0.6666333",
"0.6649909",
"0.6631236",
"0.6611191",
"0.6599827",
"0.65988386",
"0.6578426",
"0.648208",
"0.648208",
"0.648208",
"0.648208",
"0.6481469",
"0.6481469",
"0.6481469",
"0.6481469",
"0.6481469",
"0.6481469",
"0.6481469",
"0.6481469",
"0.64765066",
"0.6433364",
"0.64265794",
"0.64265794",
"0.64265794",
"0.64265794",
"0.64265794",
"0.64265794",
"0.6374537",
"0.632745",
"0.6318893",
"0.62973934",
"0.6295968",
"0.6268823",
"0.62536824",
"0.6189797",
"0.61490273",
"0.60916233",
"0.6075653",
"0.60738534",
"0.6072171",
"0.60676235",
"0.60654825",
"0.6052423",
"0.6041673",
"0.59978324",
"0.5989146",
"0.59640944",
"0.59609324",
"0.5946359",
"0.59292555",
"0.5911492",
"0.590654",
"0.5896219",
"0.5869331",
"0.5863161",
"0.58405256",
"0.58391833",
"0.58327186",
"0.58060604",
"0.58017045",
"0.57953227",
"0.5792107",
"0.57911706",
"0.57806945",
"0.57789254",
"0.57699513",
"0.5752978",
"0.5739693",
"0.57388216",
"0.5733602",
"0.57330334",
"0.5728923",
"0.5716269",
"0.57130915",
"0.5705827",
"0.5697941",
"0.56971",
"0.5691638",
"0.56879115",
"0.56668144",
"0.5664718",
"0.56562614",
"0.56562614",
"0.5644268",
"0.56431466",
"0.5634289",
"0.56292003",
"0.56280357",
"0.5617621",
"0.5617278",
"0.5616",
"0.5612441",
"0.56038386",
"0.56038266"
] |
0.0
|
-1
|
Redirect to '/spslo' is required for SP initiated Single Logout
|
def after_sign_out_path_for(_)
if session['saml_uid'] && session['saml_session_index'] && SAML_SETTINGS.idp_slo_service_url
user_saml_omniauth_authorize_path(locale: nil) + '/spslo'
else
super
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def logout \n sign_out\n# render :text => \"single sign off\" and return unless params[\"from_sso\"].nil?\n redirect_to \"#{my_addr}/#{app.name}/home\"\n end",
"def sp_logout_request\n # LogoutRequest accepts plain browser requests w/o paramters\n settings = saml_settings(url_base)\n\n if settings.idp_slo_target_url.nil?\n logger.info \"SLO IdP Endpoint not found in settings, executing then a normal logout'\"\n\n # Devise sign_out\n sign_out current_user\n else\n\n # Since we created a new SAML request, save the transaction_id\n # to compare it with the response we get back\n logout_request = OneLogin::RubySaml::Logoutrequest.new\n session[:transaction_id] = logout_request.uuid\n logger.info \"New SP SLO for User ID: '#{session[:nameid]}', Transaction ID: '#{session[:transaction_id]}'\"\n\n settings.name_identifier_value = session[:nameid] if settings.name_identifier_value.nil?\n\n relay_state = url_for controller: \"saml\", action: \"index\"\n redirect_to(logout_request.create(settings, RelayState: relay_state))\n end\n end",
"def sp_logout_request\n # LogoutRequest accepts plain browser requests w/o paramters\n settings = saml_settings\n\n if settings.idp_slo_target_url.nil?\n logger.info \"SLO IdP Endpoint not found in settings, executing then a normal logout'\"\n delete_session\n else\n\n # Since we created a new SAML request, save the transaction_id\n # to compare it with the response we get back\n logout_request = OneLogin::RubySaml::Logoutrequest.new()\n session[:transaction_id] = logout_request.uuid\n logger.info \"New SP SLO for userid '#{session[:userid]}' transactionid '#{session[:transaction_id]}'\"\n\n if settings.name_identifier_value.nil?\n settings.name_identifier_value = session[:userid]\n end\n\n relay_state = url_for controller: 'saml', action: 'show'\n redirect_to(logout_request.create(settings, RelayState: relay_state))\n end\n end",
"def sp_logout_request\n # LogoutRequest accepts plain browser requests w/o paramters\n\n if settings.idp_slo_target_url.nil?\n logger.info \"SLO IdP Endpoint not found in settings, executing then a normal logout'\"\n reset_session\n else\n\n # Since we created a new SAML request, save the transaction_id\n # to compare it with the response we get back\n logout_request = OneLogin::RubySaml::Logoutrequest.new()\n session[:transaction_id] = logout_request.uuid\n logger.info \"New SP SLO for User ID: '#{session[:nameid]}', Transaction ID: '#{session[:transaction_id]}'\"\n\n if settings.name_identifier_value.nil?\n settings.name_identifier_value = session[:nameid]\n end\n\n relayState = url_for controller: 'saml', action: 'index'\n redirect_to(logout_request.create(settings, :RelayState => relayState))\n end\n end",
"def ssoe_slo_url\n Settings.saml_ssoe.logout_url\n end",
"def sp_logout_request\n # LogoutRequest accepts plain browser requests w/o paramters\n settings = Account.get_saml_settings(get_url_base)\n\n if settings.idp_slo_target_url.nil?\n logger.info \"SLO IdP Endpoint not found in settings, executing then a normal logout'\"\n reset_session\n else\n\n # Since we created a new SAML request, save the transaction_id\n # to compare it with the response we get back\n logout_request = OneLogin::RubySaml::Logoutrequest.new()\n session[:transaction_id] = logout_request.uuid\n logger.info \"New SP SLO for User ID: '#{session[:nameid]}', Transaction ID: '#{session[:transaction_id]}'\"\n\n if settings.name_identifier_value.nil?\n settings.name_identifier_value = session[:nameid]\n end\n\n relayState = url_for controller: 'saml', action: 'index'\n redirect_to(logout_request.create(settings, :RelayState => relayState))\n end\n end",
"def after_sign_out_path_for(_)\n idp_entity_id = get_idp_entity_id(params)\n logout_request = OneLogin::RubySaml::Logoutrequest.new\n saml_settings = saml_config(idp_entity_id, request).dup\n\n # Add attributes to saml_settings which will later be used to create the SP\n # initiated logout request\n unless Devise.saml_config.name_identifier_format == 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient'\n saml_settings.name_identifier_value = @name_identifier_value_for_sp_initiated_logout\n saml_settings.sessionindex = @sessionindex_for_sp_initiated_logout\n end\n\n logout_request.create(saml_settings)\n end",
"def clear_external_site_session_info\n params.delete(\"#{session.delete(:came_from)}_url\")\n session.delete(:return_url)\n\n referrer = request.headers[\"Referer\"]\n target = referrer.blank? ? '/home' : URI.parse(referrer).path\n\n respond_to do |format|\n format.html { redirect_to target, (referrer.blank? ? nil : params) }\n end\n end",
"def logout\r\n clear_login_data\r\n redirect_to(params[:return_to] || '/', allow_other_host: true)\r\nend",
"def sign_out_and_redirect(resource_or_scope); end",
"def destroy\n log_out\n redirected_to root_url\n end",
"def sso\n @xdcomm_uri = \"#{my_addr}/#{app.name}/xdcomm\"\n @logout_uri = \"#{my_addr}/#{app.name}/logout?from_sso=1\"\n @redirect_uri = api_args[\"redirect_uri\"]\n @use_sso = !app.sso_server.nil? && @use_sso \n end",
"def log_out \n get '/sessions/destroy'\nend",
"def log_out \n get '/sessions/destroy'\nend",
"def log_out \n get '/sessions/destroy'\nend",
"def log_out \n get '/sessions/destroy'\nend",
"def log_out \n get '/sessions/destroy'\nend",
"def logout\n cookies.delete SL_CONFIG[:USER_EMAIL_COOKIE]\n cookies.delete SL_CONFIG[:USER_HASH_COOKIE]\n redirect_to Site.full_url\n end",
"def logout\n session.delete(:subscription_id)\n session.delete(:customer_id)\n redirect_to \"/ssp/index\"\n end",
"def idp_logout_request\n logout_request = OneLogin::RubySaml::SloLogoutrequest.new(params[:SAMLRequest], settings: saml_settings)\n\n if !logout_request.is_valid?\n render_logout_failure(logout_request.errors)\n else\n session.destroy\n logout_response = OneLogin::RubySaml::SloLogoutresponse.new.create(saml_settings, logout_request.id, nil, RelayState: params[:RelayState])\n redirect_to logout_response\n end\n end",
"def idp_logout_request\n settings = saml_settings(url_base)\n logout_request = OneLogin::RubySaml::SloLogoutrequest.new(\n params[:SAMLRequest], settings: settings\n )\n unless logout_request.is_valid?\n error_msg = \"IdP initiated LogoutRequest was not valid!. Errors: #{logout_request.errors}\"\n logger.error error_msg\n render inline: error_msg\n end\n logger.info \"IdP initiated Logout for #{logout_request.nameid}\"\n\n # Devise sign_out\n sign_out current_user\n\n logout_response = OneLogin::RubySaml::SloLogoutresponse.new.create(\n settings, logout_request.id, nil, RelayState: params[:RelayState]\n )\n redirect_to logout_response\n end",
"def idp_logout_request\n settings = Account.get_saml_settings(get_url_base)\n logout_request = OneLogin::RubySaml::SloLogoutrequest.new(params[:SAMLRequest], :settings => settings)\n if not logout_request.is_valid?\n error_msg = \"IdP initiated LogoutRequest was not valid!. Errors: #{logout_request.errors}\"\n logger.error error_msg\n render :inline => error_msg\n end\n logger.info \"IdP initiated Logout for #{logout_request.nameid}\"\n\n # Actually log out this session\n reset_session\n\n logout_response = OneLogin::RubySaml::SloLogoutresponse.new.create(settings, logout_request.id, nil, :RelayState => params[:RelayState])\n redirect_to logout_response\n end",
"def destroy\n log_out if logged_in? #FIXES SUBTLE ISSUE W LOGOUT\n redirect_to root_url\n # normally do root_path but w redirect we want full url\n\n end",
"def idp_logout_request\n logout_request = OneLogin::RubySaml::SloLogoutrequest.new(params[:SAMLRequest], :settings => settings)\n if not logout_request.is_valid?\n error_msg = \"IdP initiated LogoutRequest was not valid!. Errors: #{logout_request.errors}\"\n logger.error error_msg\n render :inline => error_msg\n end\n logger.info \"IdP initiated Logout for #{logout_request.nameid}\"\n\n # Actually log out this session\n reset_session\n\n logout_response = OneLogin::RubySaml::SloLogoutresponse.new.create(settings, logout_request.id, nil, :RelayState => params[:RelayState])\n redirect_to logout_response\n end",
"def verify_signed_out_user\n if all_signed_out?\n set_flash_message! :notice, :already_signed_out\n\n redirect_to (Devise.saml_sign_out_success_url.presence ||\n Devise::SessionsController.new.after_sign_out_path_for(resource_name)), allow_other_host: true\n end\n end",
"def log_out\n get '/sessions/destroy'\nend",
"def log_out\n get '/sessions/destroy'\nend",
"def after_sign_out_path_for(resource)\n #if current_user_signed_in?\n # redirect_to home_path \n # else\n redirect_to site_index_path \n #end \n end",
"def call(params)\n session[:user] = nil #\n redirect_to '/'\n end",
"def logout(env)\n env['rack.session'].delete(:balrog)\n [302, {\"Location\" => '/'}, [\"\"]]\n end",
"def logout\n session[:user]=nil\nsession[:ts_email]=nil\n redirect_to \"/schools/homepage\",sussces:\"you are susscesfully logout\"\nend",
"def logout\r\n clear_login_data\r\n redirect_to params[:return_to] || '/'\r\nend",
"def signout\n flash[:error] = params[:error]\n\n # def dont want this around (API tries to kill it, too)\n cookies.delete(:_shelby_gt_common, :domain => '.shelby.tv')\n\n redirect_to Settings::ShelbyAPI.url + \"/sign_out_user\"\n end",
"def after_sign_out_path_for(resource_or_scope)\n cookies.delete :pa_auth_token\n \n \"#{Civiccommons::PeopleAggregator.URL}/logout.php?redirect=http://#{request.host}#{request.port == \"80\" ? nil : \":#{request.port}\"}\"\n end",
"def clear_session_user\n return if current_user && current_user.email == saml_user\n request.env['warden'].logout\n redirect_to(root_path)\n end",
"def clear_session_cookie\n if request.referer.starts_with?(Rails.application.secrets.sso_url)\n reset_session\n end\n render nothing: true\n end",
"def exec_logout\n core_destroySession\n redirect_to lato_core.login_path\n end",
"def logout\n session[:ccc9527] = nil\n redirect_to root_path\n end",
"def logout\n session.clear\n redirect_referer\n end",
"def signout\n #create a signout action at admin_helper\n logout\n redirect_to :controller=>:home, :action=>:index\n end",
"def logout_path\n nil\n end",
"def after_sign_out_path_for(resource_or_scope)\n if request.params[:type] == \"sso\"\n Rails.configuration.devise[:sign_out_redirect_url]\n else\n super\n end\n end",
"def logout\n self.current_user = nil\n \n #flash[:notice] = \"You have been logged out.\"\n session[:return_to] = '/' if session[:return_to] && session[:return_to] =~ /server/\n redirect_back_or_default(:controller => '/account', :action => 'index')\n end",
"def logout\n logout_redirect = Settings.logout_redirect\n if logout_redirect == 'NONE'\n page_not_found\n return\n end\n MarkusLogger.instance.log(\"User '#{real_user.user_name}' logged out.\")\n clear_session\n if logout_redirect == 'DEFAULT'\n redirect_to action: 'login'\n else\n redirect_to logout_redirect\n end\n end",
"def log_out_behavior\n session[:user_id] = nil\n redirect_to \"/\"\n end",
"def redirect_internal() redirect_to \"/nothing\"; end",
"def signout\n self.oaw_signout\n redirect_to root_url\n end",
"def login\n if fetch_subscription(params) \n redirect_to \"/ssp/subscription\"\n else\n redirect_to \"/ssp/index?login=failed\"\n end \n end",
"def logout \n reset_session \n redirect_to :controller => 'admin' , :action => 'signin'\n end",
"def auth_after\n url = session[:auth_redirect] || root_path\n redirect_to url\n end",
"def signed_out_user\n redirect_to root_path unless !user_signed_in?\n end",
"def redirect_last\n if session[:redirect_to]\n redirect_url = session[:redirect_to]\n session[:redirect_to] = nil\n redirect redirect_url\n else\n redirect \"/\"\n end \n end",
"def redirect_to_ssl\n url_to_return = params[:return_to] ? CGI.unescape(params[:return_to]).strip : nil\n unless request.ssl? || local_request?\n if url_to_return && url_to_return[0...1] == '/' #return to local url\n redirect_to :protocol => \"https://\", :return_to => url_to_return, :method => request.method, :status => :moved_permanently\n else\n redirect_to :protocol => \"https://\", :method => request.method, :status => :moved_permanently\n end\n end\n end",
"def send_unstarted_claiments_to_the_start\n redirect_to root_url unless current_policy_routing_name\n end",
"def logout\n session[:user_id] = nil\n\n flash[:notice] = 'You have logged off'\n return_to = params[:return_to] || root_url\n redirect_to \"#{CUSTOM_PROVIDER_URL}/users/sign_out?redirect_uri=#{CGI.escape return_to}\"\n end",
"def redirect_last\n if session[:redirect_to]\n redirect_url = session[:redirect_to]\n session[:redirect_to] = nil\n redirect redirect_url\n else\n redirect '/'\n end\n end",
"def redirect_to(url)\n raise DoubleRenderError if already_built_response?\n res.header['location'] = url\n res.status = 302\n @already_built_response = true\n session.store_session(res)\n end",
"def link\n id = session[:id].to_s\n url =\"http://ourco2.org/dopplr/?userid=\"+id\n redirect_to \"https://www.dopplr.com/api/AuthSubRequest?scope=http://www.dopplr.com&next=\"+url+\"&session=1\"\n end",
"def redirect_if_logged_in\n if current_user && session[:url_on_missing_user_session]\n url = session[:url_on_missing_user_session]\n session[:url_on_missing_user_session] = nil\n redirect_to url\n end\n end",
"def after_sign_out_path_for(resource)\r\n app_root + \"/sessions/new\"\r\n end",
"def logout\n session[:authID] = nil;\n redirect_to root_path :notice => \"Utloggad\"\n end",
"def logout\n session[:user_id] = nil\n redirect_to :index, notice: \"Signed out successfully\"\n end",
"def destroy\n\t\tlog_out\n\t\tUTEPSSO.deauthenticate(cookies[:UTEP_SE], cookies[:UTEP_SA])\n\t\tredirect_to root_url\n\tend",
"def logout\n reset_session\n redirect_to '/'\n return\n end",
"def redirects; end",
"def sign_out\n # Make a delete request\n page.driver.delete destroy_educator_session_path\n\n # Follow https, make same delete request.\n page.driver.delete page.driver.response.location\n\n # Follow redirection back to root.\n page.visit page.driver.response.location\nend",
"def sdestroy\n\t\tsession[:user_id] = nil\n\t\tredirect_to \"/summary/login\"\n\tend",
"def sso_logout\n # Logout of Bobcat first while we still have the PDS_HANDLE cookie\n bobcat_logout.logout!\n # Then clear all library.nyu.edu cookies\n cookies.clear(domain: ENV['LOGIN_COOKIE_DOMAIN'])\n # If a user logs into client application and then logs out of that application\n # and then tries to login to another SSO client application, passive shibboleth\n # will be called and log them in automatically, this stops that\n session[:_check_passive_shibboleth] = true\n end",
"def logout\n session[:user] = nil\n session[:permissions] = {}\n session[:admin_user_id] = nil\n redirect_to '/'\n end",
"def sp_logout_request(user_email)\n settings = saml_settings\n\n if logout_url_configured?\n settings.name_identifier_value = user_email\n OneLogin::RubySaml::Logoutrequest.new.create(settings)\n else\n raise \"SLO IdP Endpoint not found in settings for #{@organization}\"\n end\n end",
"def logout\n session[:user_id]=nil \n\t\tredirect_to(:controller=>\"neurons\", :action=>\"index\")\n end",
"def destroy\n session[:user_id] = nil\n\n redirect_to(URI(Rails.application.config.apslabs_federation_url).merge('/users/sign_out').to_s, :notice => 'You have successfully signed out!')\n end",
"def logout\n session[:shopify] = nil\n flash[:notice] = 'Successfully logged out.'\n\n redirect_to :action => 'index'\n end",
"def redirect?; end",
"def decode_slo_request\n slo = SingleLogoutService.new(params, test_saml_settings)\n\n return decode_response if slo.response?\n\n return unless slo.valid_request?\n\n slo.log_event\n redirect_to slo.slo_response\n end",
"def signout \n if current_user\n session[:user_id] = nil\n session[:service_id] = nil\n session.delete :user_id\n session.delete :service_id\n flash[:notice] = 'You have been signed out!'\n end \n redirect_to root_url\n end",
"def logout\n # If we're given a logout request, handle it in the IdP logout initiated method\n if params[:SAMLRequest]\n idp_logout_request\n\n # We've been given a response back from the IdP\n elsif params[:SAMLResponse]\n process_logout_response\n elsif params[:slo]\n sp_logout_request\n else\n # Devise sign_out\n sign_out current_user\n end\n end",
"def after_sign_out_path_for user\n reset_session\n\n # for hijacking\n # cookies.delete :secure_user_id\n\n new_user_session_path\n # root_path\n end",
"def redirect_to_path(path)\n url = Rails.env.production? ? \"https://simonsomlai.com\" : request.protocol + request.host_with_port\n redirect_to \"#{url}#{path.chomp(\"/\")}\", :status => :moved_permanently \n end",
"def logout\n \"/users/logout\"\nend",
"def verify_user\n ## redirect to appropriate path\n redirect_to root_url, notice: 'You have already signed out. Please sign in again.' unless !current_user.nil?\n end",
"def redirect_to(url)\n if already_built_response?\n raise \"DoubleRenderError\" \n else \n @res.status = 302 \n # @res.set_header('Content-Type', content_type)\n @res.set_header('location', url)\n # @res.write(content) \n session.store_session(res)\n # debugger\n @already_built_response = true \n # debugger\n end \n end",
"def redirects_to_page\n nil\n end",
"def redirects_to_page\n nil\n end",
"def logout\n session[:user] = nil\n redirect_to '/'\n end",
"def logout\n session[:user] = nil\n redirect_to '/'\n end",
"def logout\n url_logout = File.join(session['dominio'],\"autenticazione/logout\")\n reset_session\n redirect_to url_logout\n end",
"def disconnect\n reset_session\n redirect = \"#{ENV['LOGOUT_ENDPOINT']}\"\\\n \"?post_logout_redirect_uri=#{ERB::Util.url_encode(root_url)}\"\n logger.info 'REDIRECT: ' + redirect\n redirect_to redirect\n end",
"def login_checkpoint\n redirect to '/' if !logged_in?\n end",
"def redirect_to(url)\n check_already_rendered\n session.store_session(response)\n response.status = 302\n response['Location'] = url\n @already_rendered = true\n end",
"def redirect(location, status = '302'); request.redirect(location, status); end",
"def logout\n clear_login_state\n redirect_to '/'\n end",
"def end_session\n\treset_session\n\tredirect_to '/'\nend",
"def sign_out\n \t session[:user_id]=nil\n \t flash[:notice]=\"You have been successfully logged out\"\n \t redirect_to root_url\n end",
"def redirect_to(url)\n raise 'Already responded' if already_built_response?\n flash.store_flash(res)\n res['Location'] = url\n res.status = 302\n @already_built_response = true\n session.store_session(res)\n end",
"def destroy\n @current_user = nil\n\n # Remove the hip_session id, since that kind of goes along\n # with login. Yeah, this code is far away from where hip_session\n # gets created making for confusion, sorry.\n #session.delete(:hip_session_id)\n # actually, destroy the whole damn session, why not, we're redirecting\n # them elsewhere anyway.\n reset_session\n\n # Remove shib cookies to log out of local Shib Service Provider.\n # But this doesn't work anyway, not sure why.\n #cookies.keys.find_all {|k| k =~ /^_shibsession_/ || k =~ /^_shibstate_/}.each { |cookie| cookies.delete(cookie) }\n\n redirect_to \"https://login.johnshopkins.edu/cgi-bin/logoff.pl\"\n\n end",
"def redirect_csrs\n if current_user6.email != \"admin\"\n redirect_to action: \"list\"\n end\n end",
"def session!\n redirect(settings.session_fail) unless session? || settings.session_fail == request.path_info\n end",
"def after_sign_in_path_for(user)\n if resource_params[:uv_login].present?\n # Redirect to UserVoice with sso token\n user_voice_url(user)\n else\n # ..just redirect to the app\n app_url(subdomain: current_company.subdomain)\n end\n end",
"def redirect_to(url)\n raise \"double render error\" if @already_built_response\n # Issuing a redirect consists of two parts, setting the 'Location'\n # field of the response header to the redirect url and setting the\n # response status code to 302\n @already_built_response = true\n res.location = url\n res.status = 302\n @session.store_session(res)\n end"
] |
[
"0.7160668",
"0.7114328",
"0.71089625",
"0.7065243",
"0.70365137",
"0.7002275",
"0.652105",
"0.63999045",
"0.6385099",
"0.6297313",
"0.6290662",
"0.62903583",
"0.62686753",
"0.62686753",
"0.62686753",
"0.62686753",
"0.62686753",
"0.62625086",
"0.624771",
"0.62417823",
"0.62407714",
"0.62354124",
"0.6225545",
"0.6220459",
"0.6211411",
"0.6210061",
"0.6210061",
"0.6179126",
"0.6171891",
"0.6160134",
"0.6151181",
"0.6102451",
"0.605923",
"0.6059201",
"0.60586053",
"0.60560846",
"0.60513055",
"0.6048332",
"0.60482633",
"0.6040936",
"0.60344696",
"0.6024104",
"0.60000634",
"0.59624505",
"0.5954098",
"0.59536713",
"0.5945777",
"0.5937733",
"0.5927847",
"0.592643",
"0.5923187",
"0.59208554",
"0.59084326",
"0.5903398",
"0.589406",
"0.58912134",
"0.5887182",
"0.58743346",
"0.58637196",
"0.58636653",
"0.5862545",
"0.5858641",
"0.58565104",
"0.58544886",
"0.58484167",
"0.5848134",
"0.58385986",
"0.5831853",
"0.58299214",
"0.58279485",
"0.5822119",
"0.58127254",
"0.5808045",
"0.58079505",
"0.580597",
"0.5804108",
"0.579977",
"0.5799705",
"0.5799204",
"0.5786689",
"0.5778262",
"0.5766513",
"0.57629955",
"0.57629955",
"0.5762672",
"0.5762672",
"0.5762224",
"0.5758854",
"0.57571965",
"0.57566774",
"0.57561994",
"0.57457995",
"0.5734275",
"0.57315004",
"0.5730102",
"0.57265466",
"0.5724475",
"0.57203215",
"0.5716604",
"0.5716492"
] |
0.7493845
|
0
|
GET /reports GET /reports.json
|
def index
@reports = Report.page(params[:page])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def my_reports\n @reports ||= Report.user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def reports\n collection(\"reports\")\n end",
"def list\n @reports_fetch = Report.all\n @reports = []\n\n @reports_fetch.each do |report|\n @reports << report if current_user == report.submitter\n end\n\n render status: 200, json: @reports.as_json(methods: [:url_title_string, :report_time_ms], include: { report_status_type: {}, report_type: {}, specified_submit_to_role: {} })\n end",
"def reports\n get(:reports)['Reports'].map do |details|\n Report.new(details['Url'], party: self, details: details)\n end\n end",
"def show_user_reports\n reports = User.find(params[:id]).reports\n render :json => reports\n end",
"def report(id)\n get(\"reports/#{id}\")\n end",
"def index\n @inventory_reports = InventoryReport.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventory_reports }\n end\n end",
"def index\n if params[:date].present?\n begin\n @date = Date.parse(params[:date])\n rescue => e\n Rails.logger.debug [e.class, e.message].join(' ')\n end\n end\n\n @date ||= (Report.latest_date.presence || Date.today)\n @reports = Report.date(@date).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def index\n\t\treports = Report.all\n\t\tif !reports.nil?\n\t\t\trender :json => {:success => \"true\", :reports => reports}\n\t\telse\n\t\t\trender :json => {:success => \"false\"}\n\t\tend\n\tend",
"def index\n\n # render :json => users.to_json(include: :reports)\n\n reports = current_user.reports\n # render :json => reports\n\n render :json => reports.to_json(include: :inputs)\n end",
"def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end",
"def index\n @reports = Report.where(user_id: current_user.id, patient_id:@patient.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def show_report\n report = User.find(params[:id]).reports.find(params[:r_id])\n render :json => report\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def reports\n backend.reports\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def index\n @client_reports = Client::Report.all\n end",
"def get_reports(opts = {})\n data, _status_code, _headers = get_reports_with_http_info(opts)\n data\n end",
"def show\n @report = Rails.cache.fetch(\"reports/#{params[:id]}\", :expires_in => 1.week) do\n Report.without(:email).find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n @report = current_user.reports.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end",
"def get_report_list\n res=api_call('GetReportList')[:data]\n end",
"def types\n @client.make_request :get, reports_path\n end",
"def get_reports_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReportApi.get_reports ...'\n end\n # resource path\n local_var_path = '/api/3/reports'\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageOfReport')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ReportApi#get_reports\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @dynamic_reports = DynamicReport.all\n end",
"def show\n @report = Report.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def index\n if !params[:email].nil?\n reports = Report.where(user_email: params[:email]).order('created_at DESC')\n if reports\n render json: reports, include: :pet, status: :ok\n else\n render json: {message: 'There are no reports to show'}, status: :ok\n end\n else\n render json: {message: 'Please provide user email and try again'}, status: :bad_request\n end\n end",
"def show\n report_id = params[:id]\n render json: Record.where(report_id: report_id)\n end",
"def index\n @reports = current_user.reports.all\n end",
"def report\n @report = Report.create(reports_params)\n if @report.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create report' }, status: :internal_server_error\n end\n end",
"def show\n\t\t@report = Report.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @report }\n\t\tend\n\tend",
"def getReportableType\n @reports = Report.where(\"reportable_type = ?\", params[:reportable_type])\n render json: @reports\n end",
"def index\n @reports = Report.find :all, :order => \"category desc, name\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def index\n if params[:user_id]\n raise BlogException.new(:not_found, \"not find request page\") unless User.find_by_id(params[:user_id])\n @reports = Report.where(:user_id => params[:user_id]).all\n else\n @reports = Report.all\n end\n\n @user = current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n rescue => e\n @message = e.message\n status = (e.class == BlogException ? e.code : :internal_server_error)\n respond_to do |format|\n format.html { render :template => 'error', :status => status }\n format.json { render json: @message, :status => status }\n end\n end",
"def index\n\t\t@header = 'Report'\n\t\t@per_page = params[:per_page] ||= Settings.pagination.per_page\n\n\t\tunless params[:search].nil?\n\t\t\tparams[:search][:patient_last_name_starts_with] = params[:search][:patient_last_name_starts_with].upcase unless params[:search][:patient_last_name_starts_with].nil?\n\t\t\tparams[:search][:patient_first_name_starts_with] = params[:search][:patient_first_name_starts_with].upcase unless params[:search][:patient_first_name_starts_with].nil?\n\t\t\tparams[:search][:contact_last_name_starts_with] = params[:search][:contact_last_name_starts_with].upcase unless params[:search][:contact_last_name_starts_with].nil?\n\t\t\tparams[:search][:contact_first_name_starts_with] = params[:search][:contact_first_name_starts_with].upcase unless params[:search][:contact_first_name_starts_with].nil?\n\t\tend\n\n\t\t@search = Report.includes(:patient, :contact, :client).search(params[:search])\n\t\t@reports = @search.order(\"report_log.report_id DESC\").paginate(:per_page => @per_page, :page => params[:page])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @reports }\n\t\tend\n\tend",
"def show\n\n if !params[:id].nil?\n report = Report.find_by_id(params[:id])\n if report\n render json: report, status: :ok\n else\n render json: {message: 'Report doesn\\'t exist'}, status: :bad_request\n end\n else\n render json: {message: 'There was an error getting report detail, please try it again'}, status: :bad_request\n end\n end",
"def index\n @reports = current_user.reports.all\n\n end",
"def show\n @custom_report = CustomReport.find(params[:id])\n\n render json: @custom_report\n end",
"def index\n @reporting = Reporting.without_status(:deleted).all\n @category = Reporting::CATEGORY_REPORTS\n\n puts @reporting.inspect\n puts @category.inspect\n\n respond_to do |format|\n format.html\n format.json { render json: @reporting }\n end\n end",
"def reports\r\n ReportsController.instance\r\n end",
"def index\n @admin_reports = Admin::Report.all\n end",
"def index\n @daily_reports = DailyReport.all\n end",
"def index\n @reports = filter_reports.order(updated_at: 'desc').eager_load(:reporter)\n end",
"def reports(from_id, start_date = nil, end_date = nil)\n params = []\n\n if from_id\n params << \"from_id=#{from_id}\"\n end\n\n if start_date and not end_date\n raise 'must include both start_date and end_date'\n end\n if end_date and not start_date\n raise 'must include both start_date and end_date'\n end\n\n if start_date and end_date\n params << \"start_date=#{start_date.strftime('%FT%T.%L%z')}\"\n params << \"end_date=#{end_date.strftime('%FT%T.%L%z')}\"\n end\n\n query = \"#{@endpoint}?\"\n\n if params.size > 0\n query << params.join('&')\n end\n\n get query\n end",
"def index\n @project_reports = ProjectReport.all\n end",
"def reports(since: 3.days.ago)\n raise ArgumentError, \"Program cannot be nil\" unless program\n response = self.class.hackerone_api_connection.get do |req|\n options = {\n \"filter[state][]\" => \"new\",\n \"filter[program][]\" => program,\n \"filter[created_at__gt]\" => since.iso8601\n }\n req.url \"reports\", options\n end\n\n data = JSON.parse(response.body, :symbolize_names => true)[:data]\n if data.nil?\n raise RuntimeError, \"Expected data attribute in response: #{response.body}\"\n end\n\n data.map do |report|\n Report.new(report)\n end\n end",
"def reports_schedule_detail\n @reports = ReportSchedule.find(params[:schedule_id]).reports.order(:id).reverse[0..50]\n\n respond_to do |format|\n format.json { render json: @reports} \n end\n end",
"def index\n @backend_user_content_reports = Backend::UserContentReport.paginate(:order => 'created_at DESC', :page => params[:page], :per_page => 50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @backend_user_content_reports }\n end\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = UserReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def reports_schedule\n \n @schedule = ReportSchedule.find(params[:schedule_id])\n \n respond_to do |format|\n format.html\n format.json { render json: @schedule }\n end\n end",
"def get_report(report_id, params = {})\n response = get(\"/\", {\"Action\" => \"GetReport\", \"ReportId\" => report_id})\n # TODO format response\n end",
"def index\n @reports = Report.last(7)\n @diaries = Report.order(:created_at)\n respond_to do |format|\n format.html\n format.csv { send_data @diaries.to_csv }\n format.xls { send_data @diaries.to_csv(col_sep: \"\\t\") }\n end\n end",
"def index\n if params[:report_id]\n @transfer_slips = TransferSlip.where([\"report_id = ?\", params[:report_id]]).all\n @report = Report.find(params[:report_id])\n elsif params[:year] && params[:month] && params[:day]\n @transfer_slips = TransferSlip.where([\"user_id = ? AND date = ?\", current_user.id, \"#{params[:year]}-#{params[:month]}-#{params[:day]}\"])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transfer_slips }\n end\n end",
"def fetch_report\n\t\t\t\tbegin\n\t\t\t\t\treport = fetch(\"#{Middlecoin::MIDDLECOIN_URL}/json\")\n\t\t\t\t\t@report = JSON.parse(report.body)[\"report\"]\n\t\t\t\trescue => e\n\t\t\t\t\traise Middlecoin::MiddlecoinAPIError, \"Unable to collect JSON report from middlecoin.com\"\n\t\t\t\tend\n\t\t\tend",
"def index\n @accounting_reports = AccountingReport.all\n end",
"def index\n @reports = Report.all\n # @reports = Array.new\n end",
"def reports\n @reports ||= EbanqApi::Reports.new(self)\n end",
"def show\n @survey_report = SurveyReport.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_report }\n end\n end",
"def get_all_reports(type)\n \n LOGGER.info \"get all reports of type '\"+type.to_s+\"'\"\n check_report_type(type)\n @persistance.list_reports(type).collect{ |id| get_uri(type,id) }.join(\"\\n\")\n end",
"def index\n @reports = Report.user_reports(current_user).order('created_at DESC').paginate(page: params[:page], per_page: 10)\n @report = Report.new(report_params)\n end",
"def get\n\t\treport = Report.find(params[:id])\n\t\tif !report.nil?\n\t\t\trender :json => {:success => \"true\", :report => report, :images => report.report_images}\n\t\telse\n\t\t\trender :json => {:success => \"false\"}\n\t\tend\n\tend",
"def index\n @et_reports = EtReport.all\n end",
"def view\n if params[:report_date].present? && params[:report_type].present?\n @report_contents = current_user.get_reports(params[:report_date], params[:report_type])\n else\n respond_to do |format|\n format.html { redirect_to current_user, method: :get, alert: 'Either report date or report type is empty' }\n format.json { render :show, status: :bad_request, location: @user }\n end\n end\n end",
"def show\n @report = Report.find(params[:id])\n if @report\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n else\n render action: \"new\"\n end\n end",
"def show\n @stores_report = Stores::Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stores_report }\n end\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = BgWorkerReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def queries\n parse_ga_response(authenticated_service.batch_get_reports(reports_request))\n end",
"def index\n @reports = Report.all.paginate(page: params[:page], per_page: 10)\n @report = Report.new(report_params)\n end",
"def index\n @reportars = Reportar.all\n end",
"def report_list_hash\n\t\t\tpost= { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('report/list', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\t#puts docxml\n\t\t\treports=Array.new\n\t\t\tdocxml.root.elements['contents'].elements['reports'].each_element('//report') {|report|\n\t\t\t\tentry=Hash.new\n\t\t\t\tentry['id']=report.elements['name'].text if report.elements['name']\n\t\t\t\tentry['name']=report.elements['readableName'].text if report.elements['readableName']\n\t\t\t\tentry['status']=report.elements['status'].text if report.elements['status']\n\t\t\t\tentry['timestamp']=report.elements['timestamp'].text if report.elements['timestamp']\n\t\t\t\treports.push(entry)\n\t\t\t}\n\t\t\treturn reports\n\t\tend",
"def index\n @post_reports = PostReport.all\n end",
"def index\n @reports = Report.all.order(\"updated_at DESC\").page(params[:page])\n end",
"def index\n @reports = Report.order(created_at: :desc).all\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = DevFeedbackReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def get_report_list(params = {})\n response = get(\"/\", {\"Action\" => \"GetReportList\"}.merge(params))\n GetReportListResponse.format(response)\n end",
"def report_as_json\n api_model = Report.new(params[:distribution_center_id])\n # Skipping querying if parameters are invalid.\n if not api_model.valid?\n return render status: 422, json: { message: api_model.errors }.to_json\n end\n \n begin\n query_results = api_model.query()\n json_response(query_results)\n rescue ActiveRecord::StatementInvalid => ex\n return render status: 409, json: { message: \"Unknown database error.\" }.to_json\n end\n end",
"def index\n @journal_doc_reports = JournalDocReport.all\n end",
"def report\n @employees=Employee.all\n @routing_sheets=RoutingSheet.find(:all, :conditions=> \"routing_sheet_state_id=1\") ## 1 = \"En Proceso\"\n $routing_sheets_details=Array.new\n respond_to do |format|\n format.html # report.html.erb\n format.json {render json: @routing_sheet }\n end\n end",
"def show\n @inventory_report = InventoryReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inventory_report }\n end\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"count_of_table_sid_by_field_sid\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = AccessReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def new\n @report = current_user.reports.new\n @sources = current_user.sources\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def index\n @expense_reports = ExpenseReport.all\n end"
] |
[
"0.7896447",
"0.78636414",
"0.77486503",
"0.7707248",
"0.7619338",
"0.7569814",
"0.75290066",
"0.74211705",
"0.73762834",
"0.73735154",
"0.73633385",
"0.7334833",
"0.733009",
"0.72732675",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7220281",
"0.7220281",
"0.7196912",
"0.71185154",
"0.70570904",
"0.70495635",
"0.7045736",
"0.70442414",
"0.70172673",
"0.69997096",
"0.69867194",
"0.6982625",
"0.6973249",
"0.6963129",
"0.69545126",
"0.69545126",
"0.69545126",
"0.69530445",
"0.692651",
"0.69183797",
"0.6911774",
"0.6892863",
"0.6872725",
"0.68709874",
"0.68462694",
"0.68345034",
"0.68145084",
"0.67880267",
"0.6769313",
"0.67657024",
"0.67274606",
"0.66859215",
"0.6678358",
"0.6663734",
"0.666353",
"0.66620404",
"0.66536283",
"0.66485655",
"0.6646103",
"0.66367286",
"0.6615949",
"0.6610601",
"0.65941876",
"0.658557",
"0.6576175",
"0.6575099",
"0.65725046",
"0.65639985",
"0.65607524",
"0.6556346",
"0.6554839",
"0.6550212",
"0.65453386",
"0.65337795",
"0.6521311",
"0.6517734",
"0.6515817",
"0.65090096",
"0.65008914",
"0.64877355",
"0.6486836",
"0.6473606",
"0.64594173",
"0.64527017",
"0.64415574",
"0.6439051",
"0.64366275",
"0.64365345",
"0.6426236",
"0.6426014",
"0.64193887",
"0.64083993",
"0.6407205"
] |
0.689446
|
48
|
GET /reports/1 GET /reports/1.json
|
def show; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def report(id)\n get(\"reports/#{id}\")\n end",
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def show_report\n report = User.find(params[:id]).reports.find(params[:r_id])\n render :json => report\n end",
"def my_reports\n @reports ||= Report.user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def show\n @report = Rails.cache.fetch(\"reports/#{params[:id]}\", :expires_in => 1.week) do\n Report.without(:email).find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n report_id = params[:id]\n render json: Record.where(report_id: report_id)\n end",
"def show_user_reports\n reports = User.find(params[:id]).reports\n render :json => reports\n end",
"def index\n if params[:date].present?\n begin\n @date = Date.parse(params[:date])\n rescue => e\n Rails.logger.debug [e.class, e.message].join(' ')\n end\n end\n\n @date ||= (Report.latest_date.presence || Date.today)\n @reports = Report.date(@date).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n @report = Report.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def index\n @reports = Report.where(user_id: current_user.id, patient_id:@patient.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def show\n\n if !params[:id].nil?\n report = Report.find_by_id(params[:id])\n if report\n render json: report, status: :ok\n else\n render json: {message: 'Report doesn\\'t exist'}, status: :bad_request\n end\n else\n render json: {message: 'There was an error getting report detail, please try it again'}, status: :bad_request\n end\n end",
"def show\n @report = current_user.reports.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def list\n @reports_fetch = Report.all\n @reports = []\n\n @reports_fetch.each do |report|\n @reports << report if current_user == report.submitter\n end\n\n render status: 200, json: @reports.as_json(methods: [:url_title_string, :report_time_ms], include: { report_status_type: {}, report_type: {}, specified_submit_to_role: {} })\n end",
"def show\n\t\t@report = Report.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @report }\n\t\tend\n\tend",
"def show\n @custom_report = CustomReport.find(params[:id])\n\n render json: @custom_report\n end",
"def index\n @inventory_reports = InventoryReport.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventory_reports }\n end\n end",
"def reports\n collection(\"reports\")\n end",
"def index\n\t\treports = Report.all\n\t\tif !reports.nil?\n\t\t\trender :json => {:success => \"true\", :reports => reports}\n\t\telse\n\t\t\trender :json => {:success => \"false\"}\n\t\tend\n\tend",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def reports\n get(:reports)['Reports'].map do |details|\n Report.new(details['Url'], party: self, details: details)\n end\n end",
"def get_report(report_id, params = {})\n response = get(\"/\", {\"Action\" => \"GetReport\", \"ReportId\" => report_id})\n # TODO format response\n end",
"def index\n\n # render :json => users.to_json(include: :reports)\n\n reports = current_user.reports\n # render :json => reports\n\n render :json => reports.to_json(include: :inputs)\n end",
"def index\n @reporting = Reporting.without_status(:deleted).all\n @category = Reporting::CATEGORY_REPORTS\n\n puts @reporting.inspect\n puts @category.inspect\n\n respond_to do |format|\n format.html\n format.json { render json: @reporting }\n end\n end",
"def show\n @report = Report.find(params[:id])\n if @report\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n else\n render action: \"new\"\n end\n end",
"def show\n @survey_report = SurveyReport.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_report }\n end\n end",
"def reports_schedule_detail\n @reports = ReportSchedule.find(params[:schedule_id]).reports.order(:id).reverse[0..50]\n\n respond_to do |format|\n format.json { render json: @reports} \n end\n end",
"def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end",
"def index\n @client_reports = Client::Report.all\n end",
"def getReportableType\n @reports = Report.where(\"reportable_type = ?\", params[:reportable_type])\n render json: @reports\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def index\n @reports = Report.find :all, :order => \"category desc, name\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def get\n\t\treport = Report.find(params[:id])\n\t\tif !report.nil?\n\t\t\trender :json => {:success => \"true\", :report => report, :images => report.report_images}\n\t\telse\n\t\t\trender :json => {:success => \"false\"}\n\t\tend\n\tend",
"def get_reports_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReportApi.get_reports ...'\n end\n # resource path\n local_var_path = '/api/3/reports'\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageOfReport')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ReportApi#get_reports\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end",
"def index\n @reports = Report.page(params[:page])\n end",
"def reports\n backend.reports\n end",
"def show\n @report_file = ReportFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report_file }\n end\n end",
"def types\n @client.make_request :get, reports_path\n end",
"def show\n @stores_report = Stores::Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stores_report }\n end\n end",
"def reports_schedule\n \n @schedule = ReportSchedule.find(params[:schedule_id])\n \n respond_to do |format|\n format.html\n format.json { render json: @schedule }\n end\n end",
"def show\n @reports_part = ReportsPart.find(params[:id])\n\n render json: @reports_part\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def show\n @inventory_report = InventoryReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inventory_report }\n end\n end",
"def get_report_list\n res=api_call('GetReportList')[:data]\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = UserReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def get_report(id_or_name, options={})\n request_params = options.inject({}) do |params, (key, val)|\n xero_key = key.to_s.camelize.gsub(/id/i, \"ID\").to_sym\n params[xero_key] = val\n params\n end\n response_xml = http_get(@client, \"#{@xero_url}/reports/#{id_or_name}\", request_params)\n parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/reports'})\n end",
"def show\n @report = Report.find(params[:id])\n end",
"def show\n @report = Report.find(params[:id])\n end",
"def reports\r\n ReportsController.instance\r\n end",
"def fetch(id)\n response = api_get('/report/', query: {\n action: 'fetch',\n id: id\n })\n\n # check if report exist\n return unless response.parsed_response.keys.include?('ASSET_DATA_REPORT')\n\n Report.new(response.parsed_response)\n end",
"def index\n @dynamic_reports = DynamicReport.all\n end",
"def index\n @reports = filter_reports.order(updated_at: 'desc').eager_load(:reporter)\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = BgWorkerReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def index\n @project_reports = ProjectReport.all\n end",
"def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n format.csv { send_data @report.to_csv, :filename => @report.title + '.csv' }\n format.xls { send_data @report.to_xls, :filename => @report.title + '.xls' }\n end\n end",
"def show\n @report = Report.find(params[:id])\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"count_of_table_sid_by_field_sid\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = AccessReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def show\n @reports = @patient.reports.order(\"created_at DESC\").page(params[:page]).per(3)\n end",
"def report\n @report = Report.create(reports_params)\n if @report.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create report' }, status: :internal_server_error\n end\n end",
"def report_get id\n call! report_get, id\n end",
"def view\n if params[:report_date].present? && params[:report_type].present?\n @report_contents = current_user.get_reports(params[:report_date], params[:report_type])\n else\n respond_to do |format|\n format.html { redirect_to current_user, method: :get, alert: 'Either report date or report type is empty' }\n format.json { render :show, status: :bad_request, location: @user }\n end\n end\n end",
"def show_report_inputs\n inputs = User.find(params[:id]).reports.find(params[:r_id]).inputs\n render :json => inputs\n end",
"def external_report\n return external_reports.first\n end",
"def index\n if params[:report_id]\n @transfer_slips = TransferSlip.where([\"report_id = ?\", params[:report_id]]).all\n @report = Report.find(params[:report_id])\n elsif params[:year] && params[:month] && params[:day]\n @transfer_slips = TransferSlip.where([\"user_id = ? AND date = ?\", current_user.id, \"#{params[:year]}-#{params[:month]}-#{params[:day]}\"])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transfer_slips }\n end\n end",
"def fetch_report\n\t\t\t\tbegin\n\t\t\t\t\treport = fetch(\"#{Middlecoin::MIDDLECOIN_URL}/json\")\n\t\t\t\t\t@report = JSON.parse(report.body)[\"report\"]\n\t\t\t\trescue => e\n\t\t\t\t\traise Middlecoin::MiddlecoinAPIError, \"Unable to collect JSON report from middlecoin.com\"\n\t\t\t\tend\n\t\t\tend",
"def index\n @reports = Report.last(7)\n @diaries = Report.order(:created_at)\n respond_to do |format|\n format.html\n format.csv { send_data @diaries.to_csv }\n format.xls { send_data @diaries.to_csv(col_sep: \"\\t\") }\n end\n end",
"def new\n @report = current_user.reports.new\n @sources = current_user.sources\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def index\n if !params[:email].nil?\n reports = Report.where(user_email: params[:email]).order('created_at DESC')\n if reports\n render json: reports, include: :pet, status: :ok\n else\n render json: {message: 'There are no reports to show'}, status: :ok\n end\n else\n render json: {message: 'Please provide user email and try again'}, status: :bad_request\n end\n end",
"def get_report(api_key, client_api_id, interval, query = \"\")\n uri = URI(API_ENDPOINT) + URI.escape(\"?api_key=#{api_key}&client_api_id=#{client_api_id}&interval=#{interval}&query=#{query}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n raise \"Server returned error #{response.code} processing your API request\" if response.code != \"200\"\n JSON.parse(response.body)\nend",
"def show\n @team_report = TeamReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_report }\n end\n end",
"def index\n @reports = current_user.reports.all\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = DevFeedbackReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def index\n @reports = Report.all\n # @reports = Array.new\n end",
"def show\n @time_report = TimeReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_report }\n end\n end",
"def new\n @event = Event.find(params[:event_id])\n @report = @event.reports.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def index\n if params[:user_id]\n raise BlogException.new(:not_found, \"not find request page\") unless User.find_by_id(params[:user_id])\n @reports = Report.where(:user_id => params[:user_id]).all\n else\n @reports = Report.all\n end\n\n @user = current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n rescue => e\n @message = e.message\n status = (e.class == BlogException ? e.code : :internal_server_error)\n respond_to do |format|\n format.html { render :template => 'error', :status => status }\n format.json { render json: @message, :status => status }\n end\n end",
"def index\n @reports = Report.all.order(\"updated_at DESC\").page(params[:page])\n end",
"def show\n @fin_report = FinReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fin_report }\n end\n end",
"def get_report(params = {})\n values = params.slice(:vendor_number, :report_type, :report_sub_type, :date_type, :date).values\n if params[:version]\n values << params[:version]\n end\n\n fetch(@config[:sales_path], (['Sales.getReport'] + [values.join(',')]).join(', '))\n end",
"def index\n\t\t@header = 'Report'\n\t\t@per_page = params[:per_page] ||= Settings.pagination.per_page\n\n\t\tunless params[:search].nil?\n\t\t\tparams[:search][:patient_last_name_starts_with] = params[:search][:patient_last_name_starts_with].upcase unless params[:search][:patient_last_name_starts_with].nil?\n\t\t\tparams[:search][:patient_first_name_starts_with] = params[:search][:patient_first_name_starts_with].upcase unless params[:search][:patient_first_name_starts_with].nil?\n\t\t\tparams[:search][:contact_last_name_starts_with] = params[:search][:contact_last_name_starts_with].upcase unless params[:search][:contact_last_name_starts_with].nil?\n\t\t\tparams[:search][:contact_first_name_starts_with] = params[:search][:contact_first_name_starts_with].upcase unless params[:search][:contact_first_name_starts_with].nil?\n\t\tend\n\n\t\t@search = Report.includes(:patient, :contact, :client).search(params[:search])\n\t\t@reports = @search.order(\"report_log.report_id DESC\").paginate(:per_page => @per_page, :page => params[:page])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @reports }\n\t\tend\n\tend",
"def ajax_report\n @report = Reporting.find(params[:id])\n\n end"
] |
[
"0.77468234",
"0.7589185",
"0.74307674",
"0.7356083",
"0.7339539",
"0.7336524",
"0.72879505",
"0.72701365",
"0.7256166",
"0.7256166",
"0.7256166",
"0.7242371",
"0.71831805",
"0.71578735",
"0.715341",
"0.7150455",
"0.7138241",
"0.7122619",
"0.7100867",
"0.7061722",
"0.70123106",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69912875",
"0.69757193",
"0.69460106",
"0.6933303",
"0.6911662",
"0.68716645",
"0.68535984",
"0.68379474",
"0.6836538",
"0.683171",
"0.68304217",
"0.6809837",
"0.6809837",
"0.6778833",
"0.6762446",
"0.67592657",
"0.67502004",
"0.67385817",
"0.670919",
"0.67042774",
"0.66909564",
"0.66832507",
"0.66832",
"0.66826296",
"0.6679554",
"0.66604865",
"0.66602033",
"0.6645715",
"0.66398984",
"0.66310483",
"0.66310483",
"0.66305894",
"0.661649",
"0.6615793",
"0.6599785",
"0.6598518",
"0.6569101",
"0.6569101",
"0.6569101",
"0.6569101",
"0.6565791",
"0.655795",
"0.6554174",
"0.65479696",
"0.6545332",
"0.6543595",
"0.65240407",
"0.65027815",
"0.6496571",
"0.64929116",
"0.64920413",
"0.64901155",
"0.6475926",
"0.64749753",
"0.64633137",
"0.6457148",
"0.6449741",
"0.6442302",
"0.64401454",
"0.6429114",
"0.64270043",
"0.6424439",
"0.6422043",
"0.6415069",
"0.64140254",
"0.6412315",
"0.6410857",
"0.64101654"
] |
0.0
|
-1
|
POST /reports POST /reports.json
|
def create
@report = Report.new(report_params.merge(user_id: current_user.id))
if @report.save
redirect_to @report, notice: t("activerecord.attributes.report.created")
else
ender :new
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def report\n @report = Report.create(reports_params)\n if @report.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create report' }, status: :internal_server_error\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n \n @report.test_suite.test_cases.each do |test_case|\n @report.results.create({ status: 'Queued', report_id: @report, test_case_id: test_case.id})\n end\n \n format.html { redirect_to [:admin, @report], notice: 'Report was successfully created.' }\n format.json { render action: 'show', status: :created, location: @report }\n else\n format.html { render action: 'new' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # if report is valid, save it and set flag (no need to run it b/c it will be redirected)\n @report.just_created = true if @report.errors.empty?\n \n # return data in json format\n render(:json => {:report => @report}.to_json)\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to admin_reports_path, notice: t('shared.msgs.success_created',\n obj: t('activerecord.models.report', count: 1)) }\n format.json { render :show, status: :created, location: @report }\n else\n set_date\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = current_user.reports.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to police_index_path, notice: 'Report was successfully created.' }\n format.json { render :index, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @custom_report = CustomReport.new(params[:custom_report])\n\n if @custom_report.save\n render json: @custom_report, status: :created, location: @custom_report\n else\n render json: @custom_report.errors, status: :unprocessable_entity\n end\n end",
"def create\n @report = current_user.reports.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: { message: 'Report was successfully created.'}, status: :created }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user.company.reports.any?\n if [\"Queued\", \"Running\"].include? current_user.company.reports.last.status\n redirect_to dashboard_path, notice: \"Looks like you already have a report queued. We'll get to it asap, promise!\"\n return\n end\n end\n \n @report = Report.new(report_params) \n\n respond_to do |format|\n if @report.save\n \n @report.test_suite.test_cases.order('id ASC').each do |test_case|\n @report.results.create({ status: 'Queued', report_id: @report, test_case_id: test_case.id})\n end\n \n ReportMailer.admin_requested_report_triggered_email(@report).deliver\n #ReportMailer.requested_report_triggered_email(@report).deliver\n \n format.html { redirect_to dashboard_path }\n format.json { render action: 'show', status: :created, location: @report }\n else\n format.html { render action: 'new' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'El Reporte fue creado Exitosamente.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user\n @report = @user.reports.build\n @report.attributes = params[:report]\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@report = Report.create(params[:report])\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @report.save\n\t\t\t\tformat.html { redirect_to @report, notice: 'Report was successfully created.' }\n\t\t\t\tformat.json { render json: @report, status: :created, location: @report }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @report.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n raise \"Disabled\"\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_report = Admin::Report.new(admin_report_params)\n\n respond_to do |format|\n if @admin_report.save\n format.html { redirect_to @admin_report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @admin_report }\n else\n format.html { render :new }\n format.json { render json: @admin_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@report = Report.new(report_params)\n\t\t@report.user=current_user\n\t\trespond_to do |format|\n\t\t\tif @report.save\n\t\t\t\tformat.html { redirect_to reports_url, notice: 'Report was successfully created.' }\n\t\t\t\t# format.json { render :show, status: :created, location: @report }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @report.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def create\n# @report = Report.new(report_params)\n @report = current_user.reports.build(report_params)\n respond_to do |format|\n if @report.save\n format.html { redirect_to reports_path, notice: 'Report was successfully created.' }\n format.json { render :index, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n data_report = DataReport.new(data_report_params)\n\n # For now the worker is synchronous. Eventually it can be run asynchronously\n if data_report.save && report_worker.perform(data_report.id)\n render json: {}, status: :ok\n elsif data_report.errors.present\n render json: data_report.errors, status: :unprocessable_entity\n else\n render json: {}, status: :internal_server_error\n end\n end",
"def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end",
"def create\n @client_report = Client::Report.new(client_report_params)\n\n respond_to do |format|\n if @client_report.save\n format.html { redirect_to @client_report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @client_report }\n else\n format.html { render :new }\n format.json { render json: @client_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.find(params[:event_id])\n @report = @event.reports.new(params[:report])\n @report.attributes = params[:report]\n @report.member_id = current_member.id\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to(event_path(@event)) }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = UserReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def list\n @reports_fetch = Report.all\n @reports = []\n\n @reports_fetch.each do |report|\n @reports << report if current_user == report.submitter\n end\n\n render status: 200, json: @reports.as_json(methods: [:url_title_string, :report_time_ms], include: { report_status_type: {}, report_type: {}, specified_submit_to_role: {} })\n end",
"def create\n if current_user.admin?\n @report = Report.new(report_params)\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_back :fallback_location => root_path, :alert => \"Access denied.\"\n end\n end",
"def reports\n collection(\"reports\")\n end",
"def create\n @report = Report.new(report_params)\n @report.user=current_user\n \n respond_to do |format|\n if @report.save\n format.html { redirect_to reports_url, notice: 'Report was successfully created.' }\n # format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dynamic_report = DynamicReport.new(dynamic_report_params)\n\n respond_to do |format|\n if @dynamic_report.save\n format.html { redirect_to @dynamic_report, notice: 'Dynamic report was successfully created.' }\n format.json { render :show, status: :created, location: @dynamic_report }\n else\n format.html { render :new }\n format.json { render json: @dynamic_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def report_test\n report_data = params.require(:api).permit(:code,:stdout,:project,:suite,:section)\n report = api_user.test_reports.create(report_data)\n if report.valid?\n render text: \"ok\"\n else\n raise \"Invalid report\"\n end\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = DevFeedbackReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def create\n @all_report = AllReport.new(all_report_params)\n\n respond_to do |format|\n if @all_report.save\n format.html { redirect_to @all_report, notice: 'All report was successfully created.' }\n format.json { render :show, status: :created, location: @all_report }\n else\n format.html { render :new }\n format.json { render json: @all_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if !params[:reporter_name].nil? && !params[:pet_id].nil? && !params[:lat].nil? && !params[:lon].nil? && (!params[:reporter_cel].nil? || !params[:reporter_phone].nil? || !params[:reporter_email].nil? || !params[:reporter_observations].nil?)\n pet = Pet.find_by_id(params[:pet_id])\n if pet\n report = pet.reports.create(reporterName: params[:reporter_name],\n reporterCel: params[:reporter_cel],\n reporterPhone: params[:reporter_phone],\n reporterEmail: params[:reporter_email],\n reporterObservations: params[:reporter_observations],\n lat: params[:lat],\n lon: params[:lon],\n user_email: pet.user.email)\n if report\n render json: report, include: :pet, status: :created #with user render json: report, :include => {:pet => {:include => :user}}, status: :created\n else\n render json: {message: 'There was an error saving report, please try it again'}, status: :bad_request\n end\n else\n render json: {message: 'There was an error saving report, please try it again'}, status: :bad_request\n end\n else\n render json: {message: 'There are some parameters missing'}, status: :bad_request\n end\n end",
"def create\n @hotel = Hotel.find_by(params[:hotel_id])\n @report = @hotel.reports.new(report_params)\n\n respond_to do |format|\n if @report.save\n flash[:success] = \"Report created successfuly.\"\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n flash[:alert] = \"Errors where found.\"\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n retval = @survey.create_report_mockup(params[:report_mockup])\n render_json_auto retval and return\n end",
"def create\n @stores_report = Stores::Report.new(params[:stores_report])\n\n respond_to do |format|\n if @stores_report.save\n format.html { redirect_to @stores_report, notice: 'Report was successfully created.' }\n format.json { render json: @stores_report, status: :created, location: @stores_report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stores_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def report\n # generate_report()\n ReportWorker.perform_async(\"07-01-2018\", \"08-01-2018\")\n render \\\n json: {status: 'SUCCESS', message:'REQUEST TO GENERATE A REPORT ADDED TO THE QUEUE'},\n status: :ok\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = BgWorkerReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def create\n @accounting_report = AccountingReport.new(accounting_report_params)\n\n respond_to do |format|\n if @accounting_report.save\n format.html { redirect_to @accounting_report, notice: 'Accounting report was successfully created.' }\n format.json { render :show, status: :created, location: @accounting_report }\n else\n format.html { render :new }\n format.json { render json: @accounting_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n\t\tuser_email = params[:user_email].presence\n\t\tuser = user_email && User.find_by_email(user_email)\n\n\t\treport = Report.new(report_params)\n\t\treport.user_id = user.id\n\n\t\tif report.save\n\t\t\trender :json => {:success => true, :report_id => report.id }\n\t\telse\n\t\t\trender :json => '{\"success\" : \"false\", \"error\" : \"problem saving report\"}'\n\t\tend\n\tend",
"def report(object)\n full_name = extract_full_name object\n post 'api/report', :id => full_name\n end",
"def create_report_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReportApi.create_report ...'\n end\n # resource path\n local_var_path = '/api/3/reports'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'report'])\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'CreatedReferenceintLink')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ReportApi#create_report\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @report = Report.new(report_params)\n @report.user = current_user\n\n # the report period is based on the created_at date\n # need to have current period be an enum or boolean for period - current, findby\n current_period = Period.first\n @report.period = current_period\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: \"Report was successfully created.\" }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @office_report = Office::Report.new(office_report_params)\n\n respond_to do |format|\n if @office_report.save\n format.html { redirect_to @office_report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @office_report }\n else\n format.html { render :new }\n format.json { render json: @office_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @event = Event.find(params[:event_id])\n @report = @event.reports.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def create\n @user = User.all\n \n \n # @report = Report.new(report_params)\n\n # respond_to do |format|\n # if @report.save\n # format.html { redirect_to @report, notice: 'Report was successfully created.' }\n # format.json { render :show, status: :created, location: @report }\n # else\n # format.html { render :new }\n # format.json { render json: @report.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @report = Mg::Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { flash[:notice] = 'Your report was successfully created, now add some report items.'; redirect_to(edit_mg_report_url @report) }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"count_of_table_sid_by_field_sid\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = AccessReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def submit_report(json, cookbookname)\n data = File.read(json)\n uri = URI.parse($SPEC_ENDPOINT)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(\"/api/reports\")\n request.add_field('Content-Type', 'application/json')\n request.body = {\n :spec_result => data,\n :hostname => `hostname`.chomp,\n :cookbook_name => cookbookname\n }.to_json\n response = http.request(request)\n end",
"def index\n\n # render :json => users.to_json(include: :reports)\n\n reports = current_user.reports\n # render :json => reports\n\n render :json => reports.to_json(include: :inputs)\n end",
"def create\n @event_report = EventReport.new(event_report_params)\n\n respond_to do |format|\n if @event_report.save\n format.html { redirect_to @event_report, notice: 'Event report was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event_report }\n else\n format.html { render action: 'new' }\n format.json { render json: @event_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_report\n report = Report.create(name: @name, start_date: @start_date,\n end_date: @end_date, type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end",
"def my_reports\n @reports ||= Report.user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def create\n @daily_report = DailyReport.new(daily_report_params)\n\n respond_to do |format|\n if @daily_report.save\n format.html { redirect_to @daily_report, notice: 'Daily report was successfully created.' }\n format.json { render :show, status: :created, location: @daily_report }\n else\n format.html { render :new }\n format.json { render json: @daily_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def reports\n get(:reports)['Reports'].map do |details|\n Report.new(details['Url'], party: self, details: details)\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @action_report = ActionReport.new(action_report_params)\n\n respond_to do |format|\n if @action_report.save\n format.html { redirect_to @action_report, notice: 'Action report was successfully created.' }\n format.json { render :show, status: :created, location: @action_report }\n else\n format.html { render :new }\n format.json { render json: @action_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize :report, :create?\n @report = Report.new(report_params)\n @report.user_id = current_user.id\n @report.resquest_criminal = @resquest_criminal\n @report.resquest_criminal.status = 1\n @report.resquest_criminal.save\n respond_to do |format|\n if @report.save\n format.html { redirect_to [@resquest_criminal,@report], notice: 'Report was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_report\n Report.transaction do\n report = Report.create(name: @name,\n start_date: @start_date,\n end_date: @end_date,\n type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def report\r\n if Post.exists?(params[:id])\r\n if params[:reports]\r\n @new_report = Report.create_new(params, @usr)\r\n if @new_report.errors.empty?\r\n unless Configs.get_config('mailing_list').blank?\r\n Configs.get_config('mailing_list').split(',').each do |email|\r\n ReportMailer.deliver_email(@new_report.user.name, email.strip, @new_report, request.env['HTTP_HOST'])\r\n end\r\n end\r\n redirecting t(:redir), session[:last_page]\r\n return\r\n end\r\n end\r\n else\r\n redirect_to_info_page\r\n end\r\n end",
"def create\n records = if file_upload?\n case file_upload_params['records']['file'].content_type\n when 'text/xml' then FileParser::XMLRecordParser.call( file_upload_params['records']['file'].path )\n when 'text/csv' then FileParser::CSVRecordParser.call( file_upload_params['records']['file'].path )\n when 'application/json' then FileParser::JSONRecordParser.call( file_upload_params['records']['file'].path )\n end\n else # non file upload\n form_submission_params['records'].is_a?(Array) ? form_submission_params['records'] : [ form_submission_params['records'] ]\n end\n\n begin\n @report = ReportCreator.new(records).results\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @report, status: :ok }\n end\n rescue => exception\n respond_to do |format|\n redirect_to :new, error: \"Invalid Information\", status: :unprocessable_entity\n\n format.json { render status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n\n @report = Report.new(params[:report])\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def report(id)\n get(\"reports/#{id}\")\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def reports\r\n ReportsController.instance\r\n end",
"def index\n @inventory_reports = InventoryReport.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventory_reports }\n end\n end",
"def create\n @journal_doc_report = JournalDocReport.new(journal_doc_report_params)\n\n respond_to do |format|\n if @journal_doc_report.save\n format.html { redirect_to @journal_doc_report, notice: 'Journal doc report was successfully created.' }\n format.json { render :show, status: :created, location: @journal_doc_report }\n else\n format.html { render :new }\n format.json { render json: @journal_doc_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project_report = ProjectReport.new(project_report_params)\n\n respond_to do |format|\n if @project_report.save\n format.html { redirect_to @project_report, notice: 'Project report was successfully created.' }\n format.json { render :show, status: :created, location: @project_report }\n else\n format.html { render :new }\n format.json { render json: @project_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reports_part = ReportsPart.new(params[:reports_part])\n\n if @reports_part.save\n render json: @reports_part, status: :created, location: @reports_part\n else\n render json: @reports_part.errors, status: :unprocessable_entity\n end\n end",
"def index\n if params[:date].present?\n begin\n @date = Date.parse(params[:date])\n rescue => e\n Rails.logger.debug [e.class, e.message].join(' ')\n end\n end\n\n @date ||= (Report.latest_date.presence || Date.today)\n @reports = Report.date(@date).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def create\n report = Report.new(params[:report])\n\n if report.save\n flash[:notice] = 'Report was successfully created.'\n redirect_to(report)\n else\n render :action => \"new\"\n end\n end",
"def create\n @user = User.find(params[:user_id])\n @report = @user.reports.create(report_params)\n @report.date = prepare_date(params[:date])\n prepare_report()\n @report.balance = @report_summary.working_hours_balance\n @report.workingHours = @report_summary.working_hours\n\n success = false\n begin\n if @report.save\n success = true\n end\n rescue ActiveRecord::RecordNotUnique\n flash[:alert] = I18n.t('controllers.reports.already_exists_for_date')\n end\n\n respond_to do |format|\n if success\n format.html { redirect_to [@report.user, @report], notice: I18n.t('controllers.reports.successfully_created') }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n\t\treports = Report.all\n\t\tif !reports.nil?\n\t\t\trender :json => {:success => \"true\", :reports => reports}\n\t\telse\n\t\t\trender :json => {:success => \"false\"}\n\t\tend\n\tend",
"def create\n add_parent_categories (params[:report][:category_ids])\n @report = Report.create(report_params)\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def create\n @user_report = UserReport.new(:reported_user => params[:reported_id], :user_id=>current_user.id, :description => params[:description])\n\n respond_to do |format|\n if @user_report.save\n format.html { redirect_to request.referer, notice: 'User report was successfully created.' }\n format.json { render json: @user_report, status: :created, location: @user_report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @reports = Report.all.paginate(page: params[:page], per_page: 10)\n @report = Report.new(report_params)\n end",
"def json_report(test_report)\n test_report.to_json\n end",
"def index\n @dynamic_reports = DynamicReport.all\n end",
"def new\n @report = current_user.reports.new\n @sources = current_user.sources\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def report_params\n params.require(:report).permit(\n :title,\n :description,\n :chart_type,\n :channel_id,\n :data_set_id,\n :color_scheme_id,\n :user_id,\n :last_updated_by,\n tags: []\n )\n end"
] |
[
"0.77267456",
"0.71440965",
"0.7033348",
"0.70297456",
"0.7006169",
"0.6989695",
"0.6989695",
"0.698222",
"0.6979302",
"0.6979302",
"0.6979302",
"0.6961894",
"0.6960234",
"0.695844",
"0.68224156",
"0.6808665",
"0.68054426",
"0.67791307",
"0.6777732",
"0.67731243",
"0.67679095",
"0.67508435",
"0.6746969",
"0.66917557",
"0.6681086",
"0.66784614",
"0.6661452",
"0.66542184",
"0.6653509",
"0.6651436",
"0.6645783",
"0.66446424",
"0.6633545",
"0.6629673",
"0.66146183",
"0.66073644",
"0.65965",
"0.6593443",
"0.6588078",
"0.6578451",
"0.65658617",
"0.65500414",
"0.6549918",
"0.6538192",
"0.6516743",
"0.65042835",
"0.65026104",
"0.6497986",
"0.64963937",
"0.6494756",
"0.6486668",
"0.6481851",
"0.6478844",
"0.6478525",
"0.6475318",
"0.6468754",
"0.6468117",
"0.64654857",
"0.6464442",
"0.64573073",
"0.6449238",
"0.64486754",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64342815",
"0.64200956",
"0.6418055",
"0.64167607",
"0.64144814",
"0.64139026",
"0.64101887",
"0.64101887",
"0.64101887",
"0.64101887",
"0.6405669",
"0.6388657",
"0.6375121",
"0.63695073",
"0.6366465",
"0.6347899",
"0.63444704",
"0.6338015",
"0.6336473",
"0.631614",
"0.6314127",
"0.63132924",
"0.63118654",
"0.63082796",
"0.63027024",
"0.63007975",
"0.62995565"
] |
0.0
|
-1
|
PATCH/PUT /reports/1 PATCH/PUT /reports/1.json
|
def update
@report.user = current_user
if @report.update(report_params)
redirect_to @report, notice: t("activerecord.attributes.report.updated")
else
render :edit
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Report.find(params[:id])\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to reports_path, notice: 'Report was successfully updated.' }\n format.json { render :index, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = current_user.reports.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to [:admin, @report], notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n # format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n # format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to admin_reports_path, notice: t('shared.msgs.success_updated',\n obj: t('activerecord.models.report', count: 1)) }\n format.json { render :show, status: :ok, location: @report }\n else\n set_date\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @custom_report = CustomReport.find(params[:id])\n\n if @custom_report.update(params[:custom_report])\n head :no_content\n else\n render json: @custom_report.errors, status: :unprocessable_entity\n end\n end",
"def update\n @report = Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n #format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.html { redirect_to action: \"index\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to report_path(@report.id), notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: report_path(@report.id) }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to reports_url, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update #only patch owned reports, do not edit client/user since their ids are in the routing\n @report = Report.find_by(id: params[:id])\n if current_user == @report.user\n #reset bool values that have n/a option\n @report.positive = nil\n @report.appointment = nil\n @report.payment = nil\n @report.update(report_params)\n @report.client_id = report_params[:client_id] if report_params[:client_id]\n redirect_to user_report_path(current_user, @report), notice: \"Report updated\"\n else\n redirect_to user_reports_path(current_user), alert: \"That's not your report\"\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render json: { message: 'Report was successfully updated.'}, status: :created }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: \"Report was successfully updated.\" }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Report.find(params[:id])\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to [@report.user, @report], notice: I18n.t('controllers.reports.successfully_updated') }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @report_requests = args[:report_requests] if args.key?(:report_requests)\n end",
"def update!(**args)\n @report_requests = args[:report_requests] if args.key?(:report_requests)\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @report.update(report_params)\n\t\t\t\tformat.html { redirect_to reports_url, notice: 'Report was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @report }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @report.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n # update the attribs\n @report.assign_attributes(params[:report])\n \n # if report is not valid, can't run it\n if @report.valid?\n # save\n @report.save\n # re-run the report, handling errors\n run_and_handle_errors\n end\n \n # return data in json format\n render(:json => {:report => @report}.to_json)\n end",
"def update\n respond_to do |format|\n if @all_report.update(all_report_params)\n format.html { redirect_to @all_report, notice: 'All report was successfully updated.' }\n format.json { render :show, status: :ok, location: @all_report }\n else\n format.html { render :edit }\n format.json { render json: @all_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_report.update(admin_report_params)\n format.html { redirect_to @admin_report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_report }\n else\n format.html { render :edit }\n format.json { render json: @admin_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client_report.update(client_report_params)\n format.html { redirect_to @client_report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @client_report }\n else\n format.html { render :edit }\n format.json { render json: @client_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @reports = args[:reports] if args.key?(:reports)\n end",
"def update\n @reports_part = ReportsPart.find(params[:id])\n\n if @reports_part.update(params[:reports_part])\n head :no_content\n else\n render json: @reports_part.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to(@report, :notice => 'Report was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n \n \n end\n end\n end",
"def update\n @report_file = ReportFile.find(params[:id])\n\n respond_to do |format|\n if @report_file.update_attributes(params[:report_file])\n format.html { redirect_to @report_file, notice: 'Report file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @report_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Mg::Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to(@report, :notice => 'Mg::Report was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # debugger\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n flash[:notice] = 'Report was successfully updated.'\n format.html { redirect_to(@report) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to(@report, :notice => 'Report was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @journal_doc_report.update(journal_doc_report_params)\n format.html { redirect_to @journal_doc_report, notice: 'Journal doc report was successfully updated.' }\n format.json { render :show, status: :ok, location: @journal_doc_report }\n else\n format.html { render :edit }\n format.json { render json: @journal_doc_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stores_report = Stores::Report.find(params[:id])\n\n respond_to do |format|\n if @stores_report.update_attributes(params[:stores_report])\n format.html { redirect_to @stores_report, notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stores_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @failure_report.update(failure_report_params)\n format.html { redirect_to @failure_report, notice: 'Failure report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @failure_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: \"Report was successfully updated.\" }\n format.json { render :show, status: :ok, location: @report }\n format.js\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_report_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReportApi.update_report ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling ReportApi.update_report\"\n end\n # resource path\n local_var_path = '/api/3/reports/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'report'])\n auth_names = []\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Links')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ReportApi#update_report\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to do |format|\n if @event_report.update(event_report_params)\n format.html { redirect_to @event_report, notice: 'Event report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event = Event.find(params[:event_id])\n @report = @event.reports.find(params[:id])\n @report.member_id = current_member.id\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to(event_path(@event))}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @project_report.update(project_report_params)\n format.html { redirect_to @project_report, notice: 'Project report was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_report }\n else\n format.html { render :edit }\n format.json { render json: @project_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to @report, notice: 'El Reporte fue Actualizado Exitosamente.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bugreport.update(bugreport_params)\n format.html { redirect_to @bugreport, notice: 'Bugreport was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bugreport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @crunch_report.update(crunch_report_params)\n format.html { redirect_to @crunch_report, notice: 'Crunch report was successfully updated.' }\n format.json { render :show, status: :ok, location: @crunch_report }\n else\n format.html { render :edit }\n format.json { render json: @crunch_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @inventory_report = InventoryReport.find(params[:id])\n\n respond_to do |format|\n if @inventory_report.update_attributes(params[:inventory_report])\n format.html { redirect_to @inventory_report, notice: 'Inventory report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inventory_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @accounting_report.update(accounting_report_params)\n format.html { redirect_to @accounting_report, notice: 'Accounting report was successfully updated.' }\n format.json { render :show, status: :ok, location: @accounting_report }\n else\n format.html { render :edit }\n format.json { render json: @accounting_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @office_report.update(office_report_params)\n format.html { redirect_to @office_report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @office_report }\n else\n format.html { render :edit }\n format.json { render json: @office_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @dynamic_report.update(dynamic_report_params)\n format.html { redirect_to @dynamic_report, notice: 'Dynamic report was successfully updated.' }\n format.json { render :show, status: :ok, location: @dynamic_report }\n else\n format.html { render :edit }\n format.json { render json: @dynamic_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @reporte = Reporte.find(params[:id])\n\n respond_to do |format|\n if @reporte.update_attributes(params[:reporte])\n format.html { redirect_to @reporte, notice: 'Reporte fue actualizado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reporte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ee_report.update(ee_report_params)\n format.html { redirect_to @ee_report, notice: 'Ee report was successfully updated.' }\n format.json { render :show, status: :ok, location: @ee_report }\n else\n format.html { render :edit }\n format.json { render json: @ee_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question_report.update(question_report_params)\n format.html { redirect_to @question_report, notice: 'Question report was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_report }\n else\n format.html { render :edit }\n format.json { render json: @question_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@team_report = TeamReport.find(params[:id])\n\n respond_to do |format|\n if @team_report.update_attributes(params[:team_report])\n format.html { redirect_to team_team_report_path(:team_id => @team.id,:id => @team_report.id), notice: 'Team report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report_date.update(report_date_params)\n format.html { redirect_to @report_date, notice: 'Report date was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @report_date.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post_report.update(post_report_params)\n format.html { redirect_to @post_report, notice: 'Post report was successfully updated.' }\n format.json { render :show, status: :ok, location: @post_report }\n else\n format.html { render :edit }\n format.json { render json: @post_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @expense_report\n\n\n @expense_report.actual_expenses.each do |exp|\n exp.requests.each do |req|\n req.amount_from_total = req.percentrequested * exp.total\n req.destination = @expense_report.trip.destination\n req.expense_type = 'actual'\n end\n end\n\n\n respond_to do |format|\n if @expense_report.update(expense_report_params)\n format.html { redirect_to @expense_report, notice: 'Expense report was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense_report }\n else\n format.html { render :edit }\n format.json { render json: @expense_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to patient_report_path(@patient, @report, equipmet: @report[:equipment],label: @report[:label]), notice: 'Report was successfully updated.' }\n #format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n #format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @daily_report.update(daily_report_params)\n format.html { redirect_to @daily_report, notice: 'Daily report was successfully updated.' }\n format.json { render :show, status: :ok, location: @daily_report }\n else\n format.html { render :edit }\n format.json { render json: @daily_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_report\n prepare_params\n end",
"def update\n respond_to do |format|\n if @theft_report.update(theft_report_params)\n format.html { redirect_to @theft_report, notice: 'Theft report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @theft_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pet_report.update(pet_report_params)\n format.html { redirect_to @pet_report, notice: \"Pet report was successfully updated.\" }\n format.json { render :show, status: :ok, location: @pet_report }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @pet_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fin_report = FinReport.find(params[:id])\n\n respond_to do |format|\n if @fin_report.update_attributes(params[:fin_report])\n format.html { redirect_to @fin_report, notice: 'Fin report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fin_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @batch_progress_report.update(batch_progress_report_params)\n format.html { redirect_to [@batch, @batch_progress_report], notice: 'Batch progress report was successfully updated.' }\n format.json { render :show, status: :ok, location: @batch_progress_report }\n else\n format.html { render :edit }\n format.json { render json: @batch_progress_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @authenticated = authenticated?\n @me = me if authenticated?\n @pdf_report = PdfReport.find(params[:id])\n\n respond_to do |format|\n if @pdf_report.update_attributes(params[:pdf_report])\n format.html { redirect_to @pdf_report, notice: 'Pdf report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pdf_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report_subscription.update(report_subscription_params)\n format.html { redirect_to @report_subscription, notice: 'Report subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @report_subscription }\n else\n format.html { render :edit }\n format.json { render json: @report_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_reports = UserReport.find(params[:id])\n\n respond_to do |format|\n if @user_reports.update_attributes(params[:user_report])\n flash[:notice] = 'UserReport was successfully updated.'\n format.html { redirect_to(@user_reports) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_reports.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @quarterly_report = QuarterlyReport.find(params[:id])\n\n respond_to do |format|\n if @quarterly_report.update_attributes(params[:quarterly_report])\n format.html { redirect_to(@quarterly_report, :notice => 'Quarterly report was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quarterly_report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @report_question = ReportQuestion.find(params[:id])\n\n respond_to do |format|\n if @report_question.update_attributes(params[:report_question])\n format.html { redirect_to @report_question, notice: 'Report question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @report_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @applicant_report.update(applicant_report_params)\n format.html { redirect_to @applicant_report, notice: 'Reporte de becario actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @applicant_report }\n else\n format.html { render :edit }\n format.json { render json: @applicant_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n attrs = admin_report_params\n\n if !@report.reunion_confirmed && attrs[:reunion_confirmed]\n @report.reunion_confirmed_at = Time.now\n end\n\n if @report.update(attrs)\n format.html { redirect_to @report, notice: 'Report was successfully updated.' }\n format.json { render :show, status: :ok, location: @report }\n else\n format.html { render :edit }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @statusreport = current_user.organization.statusreports.find(params[:id])\n#for update time change date format params\n #params[:statusreport][:report_date] = change_date_format(params[:statusreport][:report_date]) if !(params[:statusreport][:report_date]).blank?\n\n\n respond_to do |format|\n if @statusreport.update_attributes(params[:statusreport])\n format.html { redirect_to @statusreport, notice: 'Statusreport was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @statusreport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @time_report = TimeReport.find(params[:id])\n\n respond_to do |format|\n if @time_report.update_attributes(params[:time_report])\n format.html { redirect_to @time_report, notice: 'Time report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @report_content.update(report_content_params)\n format.html { redirect_to @report_content, notice: 'Report content was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @report_content.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reporte.update(reporte_params)\n format.html { redirect_to @reporte, notice: 'Reporte was successfully updated.' }\n format.json { render :show, status: :ok, location: @reporte }\n else\n format.html { render :edit }\n format.json { render json: @reporte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @rest = Rest.where([\"id = ? AND report_id = ?\" , params[:id], params[:report_id]]).first\n\n if @rest\n respond_to do |format|\n if @rest.update_attributes({ :location => params[:location], :ended_at => DateTime.now })\n @json = Hash[:rest => {\n :id => @rest.id,\n :report_id => @rest.report_id,\n :location => @rest.location,\n :latitude => @rest.latitude,\n :longitude => @rest.longitude,\n :address => @rest.address,\n :started_at => @rest.started_at,\n :ended_at => @rest.ended_at\n }]\n format.json { render json: @json }\n else\n format.json { render json: {:error => \"Rest update failed.\"}, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.json { render json:{ :error => \"Not Acceptable:rests#update\", :status => 406 } }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reportabus.update(reportabus_params)\n format.html { redirect_to '/reportabuses/', notice: 'Reportabuse was successfully updated.' }\n format.json { render :show, status: :ok, location: @reportabus }\n else\n format.html { render :edit }\n format.json { render json: @reportabus.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @appointment_report.update(appointment_report_params)\r\n format.html { redirect_to @appointment_report, notice: 'Reporte actualizado con exito.' }\r\n format.json { render :show, status: :ok, location: @appointment_report }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @appointment_report.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @admin_report_tag.update(admin_report_tag_params)\n format.html { redirect_to @admin_report_tag, notice: 'Report tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin_report_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matricreport.update(matricreport_params)\n format.html { redirect_to @matricreport, notice: 'Matricreport was successfully updated.' }\n format.json { render :show, status: :ok, location: @matricreport }\n else\n format.html { render :edit }\n format.json { render json: @matricreport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report2 = Report2.find(params[:id])\n\n respond_to do |format|\n if @report2.update_attributes(params[:report2])\n format.html { redirect_to(@report2, :notice => 'Report2 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @report2.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @report.update(report_params)\n @report.create_activity action: 'update', owner: current_user\n redirect_to @report, flash: { success: 'Report updated.' }\n else\n render :edit\n end\n end",
"def update\n authorize :report, :update?\n respond_to do |format|\n if @report.update(report_params)\n format.html { redirect_to [@resquest_criminal,@report], notice: 'Report was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bus_report.update(bus_report_params)\n format.html { redirect_to @bus_report, notice: 'Bus report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bus_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @type_report.update(type_report_params)\n format.html { redirect_to @type_report, notice: 'Type report was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_report }\n else\n format.html { render :edit }\n format.json { render json: @type_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @report = Report.find(params[:report_id])\n @work_item = WorkItem.find(params[:id])\n\n respond_to do |format|\n if @work_item.update_attributes(params[:work_item])\n format.html { redirect_to @report, notice: 'Work item was successfully updated.' }\n format.json { render json: @work_item, status: :ok, location: [@report, @work_item] }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n @report_request = ReportRequest.find(params[:report_request][:id])\n @fields = params[:field_filter]\n\n @fields.each do |k, v|\n field_filter = @report_request.field_filter(k.to_i)\n field_filter.update_attributes(v)\n end\n \n respond_to do |format|\n format.html\n format.xml { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @monthly_report.update(monthly_report_params)\n format.html { redirect_to @monthly_report, notice: 'Monthly report was successfully updated.' }\n format.json { render :show, status: :ok, location: @monthly_report }\n else\n format.html { render :edit }\n format.json { render json: @monthly_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n appctrl_patch_params_from_js( :saved_report, :active_task_ids )\n appctrl_patch_params_from_js( :saved_report, :inactive_task_ids )\n\n if ( @record.update_attributes( params[ :saved_report ] ) )\n flash[ :notice ] = \"Report details updated.\"\n redirect_to( report_path( @record ) )\n else\n render( :action => :edit )\n end\n end",
"def update\n @client = Client.find(params[:id])\n @client.report_header = nil if params[:remove_report_header]\n \n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6936786",
"0.6860476",
"0.6860476",
"0.68570864",
"0.68476593",
"0.68476593",
"0.6841573",
"0.6832132",
"0.6824728",
"0.68218154",
"0.67968696",
"0.6796351",
"0.67753536",
"0.676711",
"0.6761314",
"0.67367345",
"0.67303354",
"0.67303354",
"0.67303354",
"0.67303354",
"0.67303354",
"0.67303354",
"0.67303354",
"0.67303354",
"0.67303354",
"0.6719032",
"0.6695657",
"0.66501635",
"0.66281784",
"0.66281784",
"0.6614505",
"0.66079384",
"0.65939045",
"0.6580136",
"0.6558354",
"0.6526414",
"0.6516407",
"0.65156555",
"0.65112627",
"0.6493691",
"0.6486946",
"0.6485701",
"0.64616317",
"0.64547855",
"0.64323854",
"0.6395034",
"0.6379868",
"0.63773286",
"0.6363579",
"0.6356627",
"0.6356443",
"0.635537",
"0.6343103",
"0.6338235",
"0.63241655",
"0.630754",
"0.6287538",
"0.626307",
"0.6245142",
"0.6238928",
"0.6235208",
"0.6228791",
"0.62162644",
"0.6199912",
"0.61956614",
"0.6191243",
"0.61877054",
"0.61818373",
"0.6157108",
"0.6133322",
"0.61325663",
"0.61063975",
"0.6104223",
"0.6100472",
"0.6099085",
"0.60809493",
"0.6064168",
"0.6062777",
"0.6051127",
"0.6046257",
"0.604093",
"0.6024303",
"0.60189885",
"0.60139257",
"0.60136586",
"0.60109556",
"0.6010257",
"0.6004452",
"0.6000215",
"0.5999577",
"0.5994029",
"0.5992541",
"0.5990706",
"0.5983687",
"0.59817785",
"0.5981603",
"0.5979419",
"0.5976113",
"0.59746087",
"0.5968631",
"0.59554356"
] |
0.0
|
-1
|
DELETE /reports/1 DELETE /reports/1.json
|
def destroy
@report.destroy
redirect_to reports_url, notice: t("activerecord.attributes.report.destroyed")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @report.destroy!\n render json: {status: :ok}\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to admin_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n #format.json { head :ok }\n end\n end",
"def destroy\n @report = current_user.reports.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to admin_reports_url, notice: t('shared.msgs.success_destroyed',\n obj: t('activerecord.models.report', count: 1)) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to user_reports_url, notice: I18n.t('controllers.reports.successfully_updated') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey_report = SurveyReport.find(params[:id])\n @survey_report.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_find_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: \"Report was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: \"Report was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Mg::Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(mg_reports_url) }\n format.xml { head :ok }\n end\n end",
"def report_delete(id)\r\n\t\tpost= { \"token\" => @token, \"report\" => id } \r\n\t\tdocxml=nessus_request('report/delete', post)\r\n\t\treturn docxml\r\n\tend",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'El Reporte fue Eliminado Exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reporte = Reporte.find(params[:id])\n @reporte.destroy\n\n respond_to do |format|\n format.html { redirect_to reportes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_report.destroy\n respond_to do |format|\n format.html { redirect_to admin_reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @custom_report = CustomReport.find(params[:id])\n @custom_report.destroy\n\n head :no_content\n end",
"def destroy\n @report_file = ReportFile.find(params[:id])\n @report_file.destroy\n\n respond_to do |format|\n format.html { redirect_to report_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inventory_report = InventoryReport.find(params[:id])\n @inventory_report.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = current_user.reports.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to user_path(current_user), notice: \"Report was deleted!\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stores_report = Stores::Report.find(params[:id])\n @stores_report.destroy\n\n respond_to do |format|\n format.html { redirect_to stores_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @statusreport = current_user.organization.statusreports.find(params[:id])\n @statusreport.destroy\n respond_to do |format|\n format.html { redirect_to statusreports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pod_report.destroy\n respond_to do |format|\n format.html { redirect_to pod_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_report.destroy\n respond_to do |format|\n format.html { redirect_to client_reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @all_report.destroy\n respond_to do |format|\n format.html { redirect_to all_reports_url, notice: 'All report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report_content.destroy\n respond_to do |format|\n format.html { redirect_to report_contents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@report = Report.find(params[:id])\n\t\t@report.destroy\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to reports_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n\t\t@report = Report.find(params[:id])\n\t\t@report.destroy\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to reports_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @daily_report.destroy\n respond_to do |format|\n format.html { redirect_to daily_reports_url, notice: 'Daily report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize :report, :destroy?\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dynamic_report.destroy\n respond_to do |format|\n format.html { redirect_to dynamic_reports_url, notice: 'Dynamic report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @journal_doc_report.destroy\n respond_to do |format|\n format.html { redirect_to journal_doc_reports_url, notice: 'Journal doc report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @et_report.destroy\n respond_to do |format|\n format.html { redirect_to et_reports_url, notice: '削除が完了しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crunch_report.destroy\n respond_to do |format|\n format.html { redirect_to crunch_reports_url, notice: 'Crunch report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dailyreport = Dailyreport.find(params[:id])\n @dailyreport.destroy\n\n respond_to do |format|\n format.html { redirect_to(dailyreports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hivdrugreport = Hivdrugreport.find(params[:id])\n @hivdrugreport.destroy\n\n respond_to do |format|\n format.html { redirect_to hivdrugreports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @failure_report.destroy\n respond_to do |format|\n format.html { redirect_to failure_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_reports = UserReport.find(params[:id])\n @user_reports.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_reports_url) }\n format.xml { head :ok }\n end\n end",
"def report_delete(id)\n\t\t\tpost= { \"token\" => @token, \"report\" => id }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('report/delete', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\treturn docxml\n\t\tend",
"def destroy\n @reportable = @report.reportable\n @report.destroy\n respond_to do |format|\n format.html {redirect_to @reportable, notice: 'Report was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @time_report = TimeReport.find(params[:id])\n @time_report.destroy\n\n respond_to do |format|\n format.html { redirect_to time_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fin_report = FinReport.find(params[:id])\n @fin_report.destroy\n\n respond_to do |format|\n format.html { redirect_to fin_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_report.destroy\n respond_to do |format|\n format.html { redirect_to post_reports_url, notice: 'Post report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_report.destroy\n respond_to do |format|\n format.html { redirect_to event_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n service_report = ServiceReport.find(params[:id])\n @service_request = service_report.service_request\n @service_request.service_reports.destroy(service_report)\n\n respond_to do |format|\n format.html { redirect_to(service_request_url(@service_request)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @theft_report.destroy\n respond_to do |format|\n format.html { redirect_to theft_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comparative_report = ComparativeReport.find(params[:id])\n @comparative_report.destroy\n\n respond_to do |format|\n format.html { redirect_to(comparative_reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @action_report.destroy\n respond_to do |format|\n format.html { redirect_to action_reports_url, notice: 'Action report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_report.destroy\n respond_to do |format|\n format.html { redirect_to project_reports_url, notice: 'Project report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n store_location\n @report.destroy\n respond_to do |format|\n format.html { redirect_to session.delete(:return_to)}\n format.json { head :no_content }\n end\n end",
"def destroy\n @report_date.destroy\n respond_to do |format|\n format.html { redirect_to report_dates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admins_direct_report.destroy\n respond_to do |format|\n format.html { redirect_to admins_direct_reports_url, notice: 'Direct report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @accounting_report.destroy\n respond_to do |format|\n format.html { redirect_to accounting_reports_url, notice: 'Accounting report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@report.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @report.destroy\n flash[:success] = \"report deleted\"\n redirect_to reports_url\n \n end",
"def destroy\n @event = Event.find(params[:event_id])\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(event_path(@event)) }\n format.html { redirect_to reports_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @expense_report.destroy\n respond_to do |format|\n format.html { redirect_to expense_reports_url, notice: 'Expense report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@team_report = TeamReport.find(params[:id])\n @team_report.destroy\n\n respond_to do |format|\n format.html { redirect_to action: :index }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reporte.destroy\n respond_to do |format|\n format.html { redirect_to reportes_url, notice: 'Reporte was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ee_report.destroy\n respond_to do |format|\n format.html { redirect_to ee_reports_url, notice: 'Ee report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ee_report.destroy\n respond_to do |format|\n format.html { redirect_to ee_reports_url, notice: 'Ee report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report_narrative = ReportNarrative.find(params[:id])\n @report_narrative.destroy\n\n respond_to do |format|\n format.html { redirect_to report_narratives_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @quarterly_report = QuarterlyReport.find(params[:id])\n @quarterly_report.destroy\n\n respond_to do |format|\n format.html { redirect_to(quarterly_reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_report = UserReport.find(params[:id])\n @user_report.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report_line = ReportLine.find(params[:id])\n @report_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(report_lines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @office_report.destroy\n respond_to do |format|\n format.html { redirect_to office_reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tbdotreport = Tbdotreport.find(params[:id])\n @tbdotreport.destroy\n\n respond_to do |format|\n format.html { redirect_to tbdotreports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @applicant_report.destroy\n respond_to do |format|\n format.html { redirect_to applicant_reports_url, notice: 'Reporte de becario eliminado correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @annual_summary_report.destroy\n respond_to do |format|\n format.html { redirect_to annual_summary_reports_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to posts_path(code: Code.first.code) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report2 = Report2.find(params[:id])\n @report2.destroy\n\n respond_to do |format|\n format.html { redirect_to(report2s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @batch_progress_report.destroy\n respond_to do |format|\n format.html { redirect_to batch_progress_reports_url, notice: 'Batch progress report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @weekly_report.destroy\n respond_to do |format|\n format.html { redirect_to weekly_reports_url, notice: 'Weekly report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.78883916",
"0.77925867",
"0.7791945",
"0.7791945",
"0.7791945",
"0.7768737",
"0.7727435",
"0.7727435",
"0.7727435",
"0.7727435",
"0.7672675",
"0.75966144",
"0.75292933",
"0.75292933",
"0.75199825",
"0.7518596",
"0.7518159",
"0.7505007",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.7485241",
"0.74796754",
"0.74796754",
"0.7473989",
"0.74728113",
"0.74648476",
"0.74638873",
"0.74638873",
"0.7434007",
"0.7429916",
"0.7408249",
"0.73837847",
"0.73818904",
"0.73699695",
"0.7366642",
"0.73643637",
"0.73641366",
"0.73634446",
"0.73605555",
"0.73573846",
"0.73381484",
"0.732708",
"0.732708",
"0.73191226",
"0.7315813",
"0.73125166",
"0.729199",
"0.728158",
"0.72787595",
"0.72474194",
"0.7232709",
"0.72261465",
"0.72183925",
"0.7192553",
"0.7188103",
"0.71800166",
"0.71736306",
"0.7171925",
"0.7170453",
"0.7168215",
"0.71623516",
"0.7157617",
"0.71509993",
"0.71453905",
"0.7144843",
"0.714436",
"0.71163625",
"0.7114552",
"0.7109758",
"0.70890725",
"0.70875955",
"0.708472",
"0.70844483",
"0.70714444",
"0.70566064",
"0.70566064",
"0.7055829",
"0.70399314",
"0.7030043",
"0.7015181",
"0.70076495",
"0.7004839",
"0.70019466",
"0.69952273",
"0.69943607",
"0.6990628",
"0.6988986",
"0.6984356"
] |
0.0
|
-1
|
Use callbacks to share common setup or constraints between actions.
|
def set_report
@report = Report.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup_handler\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def before_dispatch(env); end",
"def process_action(...)\n send_action(...)\n end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def action\n end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def config(action, *args); end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def setup\n # override this if needed\n end",
"def matt_custom_action_begin(label); end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def setup_signals; end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def lookup_action; end",
"def around_hooks; end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def action_target()\n \n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def call\n setup_context\n super\n end",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def duas1(action)\n action.call\n action.call\nend"
] |
[
"0.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.5328757",
"0.5310255",
"0.5300339",
"0.5298796",
"0.5295774",
"0.5256034",
"0.5243039",
"0.5236007",
"0.5235239",
"0.5235239",
"0.5235239",
"0.5235239",
"0.5235239",
"0.52321917",
"0.5227032",
"0.52216744",
"0.5216349",
"0.52161187",
"0.5210265",
"0.5207244",
"0.5177388",
"0.5177142",
"0.51747334",
"0.516293",
"0.51629275",
"0.5155534",
"0.51540613",
"0.515197",
"0.5151636",
"0.5145279",
"0.51380795",
"0.5135777",
"0.5117378",
"0.5115066",
"0.5115066",
"0.5110235",
"0.5106418",
"0.50917816",
"0.50909185",
"0.50855017",
"0.5082105",
"0.506359",
"0.5055345",
"0.50546116",
"0.50523037",
"0.50523037",
"0.50327307",
"0.5024364",
"0.5021113",
"0.50174654",
"0.50163317",
"0.5000553",
"0.50002855",
"0.49991882",
"0.49905527",
"0.49905527",
"0.49849054",
"0.4982546",
"0.4980941",
"0.4979153",
"0.49693102",
"0.4967172",
"0.49594432",
"0.49564302",
"0.49552485",
"0.49533385",
"0.49506924",
"0.49452737",
"0.49442786",
"0.49347955",
"0.49341312",
"0.49295264",
"0.49261844",
"0.4925649",
"0.49251428",
"0.4920729",
"0.49177617",
"0.4916373",
"0.49158472",
"0.4915794",
"0.49156648"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def report_params
params.require(:report).permit(:title, :body)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Use symbols to avoid loading all shortcutted filters.
|
def filter_for(shortcut)
{
attribute_filter: [:"MundaneSearch::Filters::AttributeMatch", {}],
filter_greater_than: operator_filter(:>),
filter_less_than: operator_filter(:<),
filter_greater_than_or_equal_to: operator_filter(:>=),
filter_less_than_or_equal_to: operator_filter(:<=),
}[shortcut]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resolve_symbols\n s = Symbols.new(@filtered)\n pro = s.process_labels\n @filtered = s.translate_symbols(pro)\n process\n end",
"def symbols() @symbols end",
"def symbols; end",
"def clear_symbols(*symbols)\n [BusScheme.current_scope, BusScheme::SYMBOL_TABLE].compact.map{ |scope| symbols.map{ |sym| scope.delete sym } }\n end",
"def symbols\n @symbol_set.symbols\n end",
"def gen_symbols\n @symbols = true\n end",
"def replace_symbols_with_refs\n symbol_defs = symbols_first_pass\n symbols_second_pass symbol_defs\n end",
"def symbols(new_symbols = (not_set = true))\n return @symbols if not_set\n\n @symbols.merge!(new_symbols)\n end",
"def symbols(new_symbols = (not_set = true))\n return @symbols if not_set\n\n @symbols.merge!(new_symbols)\n end",
"def methods_accepting_symbol; end",
"def get_symbols\n\t\treturn @symbols\n\tend",
"def hide(symbols)\n RegLang.new(fa.hide(symbols))\n end",
"def add_filter(filter_symbol)\n filters << filter_symbol\n end",
"def remove_symbols(*symbols)\n @interface.remove_symbols(*symbols)\n end",
"def symbols\n each_symbol.to_a\n end",
"def privatize_non_exported_methods(singleton, symbols)\n singleton.instance_methods(false).each do |sym|\n next if symbols.include?(sym)\n\n singleton.send(:private, sym)\n end\n end",
"def shortcuts\n these_shortcuts = {}\n ActiveSupport::Notifications.instrument 'add_console_shortcuts.cnfs', { shortcuts: these_shortcuts }\n these_shortcuts\n end",
"def delegate_methods(*symbols); end",
"def symbols\n keys.sort\n end",
"def use(sym); end",
"def query_symbols(query); end",
"def query_symbols(query); end",
"def convert_symbols_to(formula = nil, &block)\n XMLKey.symbol_converter = formula ? formula : block\n end",
"def initialize(symbols:)\n @symbols = symbols\n @learned = {}\n end",
"def symbols(file); end",
"def symbols(file); end",
"def set_exported_symbols(mod, symbols)\n mod.__module_info[:exported_symbols] = symbols\n singleton = mod.singleton_class\n\n privatize_non_exported_methods(singleton, symbols)\n expose_exported_constants(mod, singleton, symbols)\n end",
"def symbols_in_program_memory\n @symbol_set.symbols_in_memory(:program_memory)\n end",
"def clear_symbols\n @interface.clear_symbols\n end",
"def each() @symbols.each {|s| yield s if block_given? } end",
"def build_symbols(options)\n if options == :ascii\n ASCII_SYMBOLS\n elsif options.is_a? Hash\n base_symbols = options[:base] == :ascii ? ASCII_SYMBOLS : SYMBOLS\n if options[:override].is_a?(Hash)\n base_symbols.merge(options[:override])\n else\n base_symbols\n end\n else\n SYMBOLS\n end\n end",
"def import_symbols(symbol_source)\n if symbol_source.respond_to?(:symbols)\n @symbol_set.def_symbols symbol_source.symbols\n end\n\n if symbol_source.respond_to?(:symbols_in_ram)\n @symbol_set.def_symbols symbol_source.symbols_in_ram, :ram\n end\n\n if symbol_source.respond_to?(:symbols_in_program_memory)\n @symbol_set.def_symbols symbol_source.symbols_in_program_memory, :program_memory\n end\n\n if symbol_source.respond_to?(:symbols_in_eeprom)\n @symbol_set.def_symbols symbol_source.symbols_in_eeprom, :eeprom\n end\n end",
"def private_delegate_methods(*symbols); end",
"def add_symbols(*symbols)\n @interface.add_symbols(*symbols)\n end",
"def symbolize!\n return replace(symbolize)\n end",
"def convert_symbols(a)\n # find (labels) and add them to the symbol table and\n # reference the next line of code, then delete the\n # label\n a = replace_label_symbols(a)\n\n # Find all user Symbols, add them to Symbol Table if\n # not already there. Then replace the symbol in the\n # code with it's numerical equivalent.\n a = populate_user_symbols(a)\n \n # Replace pre-defined symbols with their numerical \n # equivalent from the system table\n a = replace_predefined_symbols(a)\n end",
"def perform_list\n puts 'Symbol table (special chars escaped):'\n @symbol_table.symbols.each do |sym|\n puts \"#{sym.name} -> #{sym.value.dump} #{sym.readonly ? '[readonly]' : ''}\"\n end\n end",
"def symbols_in_ram\n @symbol_set.symbols_in_memory(:ram)\n end",
"def get_regular_expression_of_symbols\n regular_expression = nil\n @symbols.each do |symbol|\n formated_symbol = Regexp.escape(symbol[:symbol])\n regular_expression = if regular_expression.nil?\n \"(#{formated_symbol})\"\n else\n \"#{regular_expression}|(#{formated_symbol})\"\n end\n end\n Regexp.new(regular_expression)\n end",
"def register_symbol symbol\n @@registeredkeys[symbol] = self\n end",
"def unregister(symbol); end",
"def allow_currency_symbols(*args)\n # Obviously US-centric, I need to make it international or customizable.\n # Some international symbols '¢£¥€ƒ$,'\n add_equal_method CURRENCY_CHARS, args \n end",
"def symbols_first_pass\n symbol_defs = {}\n @data.each do |address, byte|\n next unless byte.is_a? Hash\n symbol = byte.keys.first\n value = byte.values.first\n # Store the symbol and its address for the second pass\n symbol_defs[symbol] = address\n # Replace the definition with just the value\n @data[address] = value\n end\n symbol_defs\n end",
"def skip_symbol_cache?\n true\n end",
"def symbolicate!\n return if @isSymbolicated\n buildgdbcommandfile\n gdbout = rungdb\n @symbols = []\n gdbout.lines.each do |l|\n @symbols << Symbolized.new(l)\n end\n \n addresses.each do |a|\n @symbols.each do |s|\n if s.startaddress && a >= s.startaddress && a <= s.endaddress\n report.gsub!(/(0x.*#{a.to_s(16)}) (.*)/, \"#{$1} #{s.symbol} (#{s.filename}:#{s.line})\")\n end # address matches\n end # @symbols.each\n end# addresses.each\n @isSymbolicated = true\n end",
"def filtered_methods\n @filtered_methods ||= []\n end",
"def create_symbols\n # creates all named symbols, including vector references\n @expressions.map { |a| a.create_symbols }\n puts(self.class)\n end",
"def filter_methods; end",
"def global_filter; end",
"def key_words\n # because dollar signs don't work we can't display a $ sign in the keyword\n # list so its not explicitly clear what the keyword\n variables = scope.to_hash.keys\n # prepend a :: to topscope variables\n scoped_vars = variables.map { |k, _v| scope.compiler.topscope.exist?(k) ? \"$::#{k}\" : \"$#{k}\" }\n PuppetDebugger::InputResponders::Functions.instance.debugger = self\n funcs = PuppetDebugger::InputResponders::Functions.instance.func_list\n PuppetDebugger::InputResponders::Datatypes.instance.debugger = self\n (scoped_vars + funcs + static_responder_list + PuppetDebugger::InputResponders::Datatypes.instance.all_data_types).uniq.sort\n end",
"def temp_file_symbols\n []\n end",
"def enable_operator_shorthands\n return if @shorthands_enabled\n Symbol.instance_eval { include SymbolHack, PipeHack }\n String.instance_eval { include PipeHack }\n Fixnum.instance_eval { include FixnumOfHack }\n Range.instance_eval { include RangeOfHack }\n @shorthands_enabled = true\n end",
"def hide_symbols(text)\n html = text.is_a?(ActiveSupport::SafeBuffer)\n text = text.to_s unless text.is_a?(String)\n\n # noinspection RubyMismatchedReturnType\n return html ? text : ERB::Util.h(text) unless text.match?(SYMBOLS)\n\n if html && (parts = text.scan(FOR_ELEMENTS)).present?\n # noinspection RubyMismatchedArgumentType\n parts.flat_map {\n part = []\n part << _1.presence && hide_symbols(_1) # leading text\n part << [_2, _3, _4].join # HTML tag\n part << _5.presence && hide_symbols(_5.html_safe) # HTML node contents\n part << _6 # HTML tag close\n part << _7.presence && hide_symbols(_7) # trailing text\n }.compact.join.html_safe\n else\n text.scan(/(.*?)(#{SYMBOLS})/).flat_map { |txt, sym|\n part = []\n part << txt.presence && (html ? txt : html_span(txt, class: 'text'))\n part << symbol_icon(sym)\n }.compact.join.html_safe\n end\n end",
"def do_global_map\r\n $FOORTH_GLOBALS[@symbol]\r\n end",
"def action(sym, ops = {})\n\t \tops[:icon] ||= sym\n\t \tops[:title] ||= sym.to_s.humanize\n\t \tif ops[:icon].is_a?(String)\n\t \t\tadd_icon sym => ops[:icon]\n\t \t\tops[:icon] = sym\n\t \tend\n @actions[sym] = ops\n\t end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def sym(name)\n #This is a stub, used for indexing\n end",
"def add_known_symbol(s)\n @@known_symbols << s.to_sym\n @@known_symbols_by_glass[glass] ||= []\n @@known_symbols_by_glass[glass] << s.to_sym\n end",
"def objects_and_symbols; end",
"def non_terminal_symbols\n symbols.values.select {|symbol| symbol.non_terminal}\n end",
"def private(*syms) end",
"def private_delegate_methods(*symbols)\n symbols.each { |symbol| private delegate_method(symbol) }\n nil\n end",
"def register_filter(mod); end",
"def hash_proc_4symstr\n @hash_proc_4symstr ||= proc do |hash, key|\n case key\n when String\n tmp = key.to_sym\n hash.key?(tmp) ? hash[tmp] : nil\n when Symbol\n tmp = key.to_s\n hash.key?(tmp) ? hash[tmp] : nil\n end\n end\n end",
"def map_without_defaults(name)\r\n if (@symbol = SymbolMap.map(@name = name))\r\n do_map_name\r\n end\r\n end",
"def symbols\n @symbols ||= Array(@grpc.symbols).map do |b|\n Symbol.from_grpc b\n end\n end",
"def all=(symbol)\n [:symbol, :long_symbol, :name, :long_name].each do |field|\n send(field.to_s + '=', symbol.to_s)\n end\n end",
"def symbols(expr = @expr)\n expr[1..-1].map do |sym|\n case sym\n when Symbol\n sym\n when Array\n symbols(sym)\n end\n end.flatten.compact.uniq\n end",
"def sym\n @sym\n end",
"def endpoint(symbol)\n symbol.to_s\n .gsub(\"admin_\", \"admin/\")\n .gsub(\"hidden_\", \".\")\n end",
"def reserved_shortcuts\n [home_shortcut, items_shortcut, inventory_shortcut, blogs_shortcut, calendars_shortcut, categories_shortcut, items_shortcut].uniq.compact\n end",
"def symbols\n @flags.keys\n end",
"def clean(sym)\n sym.to_s.gsub(/\\W/, '_')\n end",
"def aliases!\n @validators.keys.find_all { |key| @validators[key].is_a? ::Symbol }\n end",
"def symbol\n @symbol\n end",
"def symbols(names_only=false, recurse=false)\n symtab = recurse ? @children.map { |c| c.symbols(names_only, true)\n }.flatten : []\n names_only ? @symtab.keys.concat(symtab) : @symtab.values.concat(symtab)\n end",
"def symbol(*args, &block)\n args = [{ :using => Option, :kind => Symbol }, *args]\n da = option(*args, &block)\n da.instance_eval do\n from String do |s|\n s.to_sym\n end\n end\n end",
"def symbolized_path_parameters\n @symbolized_path_params ||= path_parameters.symbolize_keys\n end",
"def sym(name)\n SymEngine::Symbol.new(name)\nend",
"def delegate_methods(*symbols)\n symbols.each { |symbol| delegate_method(symbol) }\n nil\n end",
"def symbols_places_unlocked\n @known_places ||= MapConfig.default_place\n @known_places\n end",
"def symbols?\n sort == ::SYMBOLS\n end",
"def do_object_class_map\r\n Object.map_foorth_shared(@symbol)\r\n end",
"def remove_symbols_from_name\n all_customers = Customer.all\n\n all_customers.each do |customer|\n customer.update(search_name: customer.name.gsub(/[^a-zA-Z\\s]/,'').downcase)\n end\n end",
"def symbols(include_number=true)\r\n cache.keys.find_all { |k| k.is_a?(Symbol) && (include_number || !self[k].is_a?(Types::Number)) }\r\n end",
"def symbol_icon(icon, **opt)\n icon = icon_definitions.dig(icon, :icon) if icon.is_a?(Symbol)\n super(icon, **opt)\n end",
"def terminal_symbols\n symbols.values.select {|symbol| symbol.terminal}\n end",
"def symbols_for( symbol )\n return @group_members.member?(symbol.name) ? @group_members[symbol.name] : [symbol]\n end",
"def filters\n @filters ||= {}\n end",
"def named_filter; end",
"def set_symbols(file_name)\n @symbols = []\n if file_name.nil?\n file_name = File.join(\n File.dirname(File.dirname(File.dirname(__FILE__))),\n 'symbols.xml'\n )\n end\n document = REXML::Document.new(File.read(file_name))\n document.elements.each('symbols/symbol') do |symbol_xml|\n symbol = {}\n symbol[:symbol] = symbol_xml.attribute('symbol').value\n symbol[:description] = @configure.get_parameter(\n symbol_xml.attribute('description').value\n )\n @symbols.push(symbol)\n end\n end",
"def command_lookup_table \n return @command_lookup_table if @command_lookup_table\n @command_lookup_table = command_abbreviations.merge(shortcut_table)\n end",
"def strip_symbols(name)\n return name.to_s.gsub(/[[:punct:]]/, '')\n end",
"def prepare(syms)\n @syms = syms\n end",
"def prepare(syms)\n @syms = syms\n end"
] |
[
"0.7036925",
"0.6237597",
"0.61471754",
"0.61041725",
"0.6094397",
"0.6040069",
"0.59871346",
"0.59117705",
"0.59117705",
"0.58749574",
"0.5871395",
"0.58564013",
"0.5844829",
"0.58248305",
"0.5777203",
"0.5653244",
"0.5630441",
"0.5563246",
"0.55531335",
"0.55163527",
"0.54900855",
"0.54900855",
"0.5465753",
"0.54518616",
"0.54327756",
"0.54327756",
"0.5417347",
"0.54000264",
"0.53885776",
"0.5360128",
"0.53554845",
"0.53415084",
"0.53242916",
"0.53192717",
"0.5314345",
"0.5307613",
"0.5290528",
"0.52881986",
"0.52807105",
"0.5271885",
"0.52526945",
"0.5203505",
"0.52004707",
"0.5194451",
"0.51910776",
"0.51812553",
"0.51781154",
"0.51398504",
"0.51304865",
"0.5115066",
"0.5109195",
"0.5089865",
"0.50866777",
"0.5068974",
"0.5056241",
"0.5055557",
"0.5055557",
"0.5055557",
"0.5055557",
"0.5055557",
"0.5055557",
"0.5037327",
"0.5023602",
"0.501949",
"0.5018015",
"0.50124913",
"0.49879736",
"0.49879304",
"0.49875918",
"0.49794078",
"0.49774808",
"0.4967447",
"0.4965023",
"0.4962927",
"0.49539164",
"0.49444497",
"0.49368447",
"0.49289447",
"0.49248022",
"0.49238992",
"0.49197683",
"0.4914975",
"0.49056464",
"0.49006736",
"0.48935518",
"0.48802897",
"0.487199",
"0.48699632",
"0.48656404",
"0.4859117",
"0.4858855",
"0.4849822",
"0.48459622",
"0.48456687",
"0.48435864",
"0.48403803",
"0.4836238",
"0.48354325",
"0.48320085",
"0.48320085"
] |
0.51245904
|
49
|
Declares which content models will be included with the model EXAMPLE: has_content :articles, :tips
|
def has_yaml_content(*args)
include HasYamlContent::InstanceMethods
#get the already loaded content modules
content_types = custom_content_types
args.each do |arg|
#load content model
if arg.is_a?(Symbol)
#singularize content model and append to array
model_name = arg.to_s.singularize.titleize.gsub(" ","")
content_types << {:name => model_name, :plural => true}
#try to load the content module if it exists
load_custom_content_module(arg.to_s)
#add method so that content can be called like base.tips or base.detail
define_method(arg.to_s) do
get_content(model_name)
end
#extra options for a content model such as :plural => false, or :class_name => 'PromotionDetail'
elsif arg.is_a?(Hash)
content_types[content_types.size - 1] = content_types.last.merge(arg) #append options to last item in array
#try to load the content module from :class_name
if arg[:class_name]
load_custom_content_module(arg[:class_name])
end
end
end
#insert the new content modules
custom_content_types = content_types
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def assert_content_model\n add_relationship(:has_model, \"info:fedora/hull-cModel:examPaper\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:compoundContent\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:commonMetadata\")\n end",
"def set_content\n @content = @slide.contents.friendly.find(params[:id])\n @content_types = ContentType.all\n end",
"def assert_content_model\n g = Genre.find(descMetadata.genre.first)\n add_relationship(:has_model, \"info:fedora/#{g.c_model}\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:compoundContent\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:commonMetadata\")\n end",
"def assert_content_model\n add_relationship(:has_model, \"info:fedora/hydra-cModel:genericParent\")\n super\n end",
"def set_content_model\n @content_model_class_name = self.class.name.gsub(/Controller/,'').singularize.constantize\n end",
"def assert_content_model\n add_relationship(:has_model, \"info:fedora/hull-cModel:bookChapter\") \n add_relationship(:has_model, \"info:fedora/hydra-cModel:compoundContent\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:commonMetadata\") \n end",
"def set_content\n\t @content = Content.find(params[:id])\n\tend",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def include_content=(value)\n @include_content = value\n end",
"def specific_content_params\n params.require(:specific_content).permit(:title, :subtitle, :content, :external_link)\n end",
"def set_content\n @content = Content.find(params[:id])\n end",
"def content_params\n params.require(:content).permit(:content_one)\n end",
"def inherited(subclass)\n unless class_variable_defined?(:@@content_model)\n class_variable_set(:@@content_model, subclass)\n subclass.send :include, Spontaneous::Model::Core\n end\n super\n end",
"def content\n @content ||= if valid_attrs?(:content_id, :content_type)\n Object.const_get(content_type).find_by_id(content_id)\n end\n end",
"def content_params\n params.require(:content).permit(:html, :ordering, :usage, :_destroy, :wrapper_klass, :image)\n end",
"def included(model_class); end",
"def init(context={})\n\n app = context[:app]\n \n # View models\n ::Model::ViewModel.new(:content, 'content', ContentManagerSystem::Content, :view_template_contents,\n [::Model::ViewModelField.new(:_id, 'id', :string),\n ::Model::ViewModelField.new(:title, 'title', :string),\n ::Model::ViewModelField.new(:path, 'path', :string),\n ::Model::ViewModelField.new(:alias, 'alias', :string),\n ::Model::ViewModelField.new(:summary, 'summary', :string),\n ::Model::ViewModelField.new(:type, 'type', :string),\n ::Model::ViewModelField.new(:creation_date, 'creation_date', :date),\n ::Model::ViewModelField.new(:creation_user, 'creation_user', :string)])\n \n ::Model::ViewModel.new(:term, 'term', ContentManagerSystem::Term, :view_template_terms,\n [::Model::ViewModelField.new(:id, 'id', :serial),\n ::Model::ViewModelField.new(:description, 'description', :string)])\n\n ::Model::ViewModel.new(:profile, 'profile', Users::Profile, :view_template_profiles,[]) \n\n # View renders \n teaser_preprocessor = Proc.new do |data, context, render_options|\n data.map { |element| CMSRenders::Factory.get_render(element, context, 'teaser').render({}, [:ignore_complements, :ignore_blocks]) }\n end\n\n slider_preprocessor = Proc.new do |data, context, render_options|\n data.map { |element| CMSRenders::Factory.get_render(element, context, 'justphoto').render({}, [:ignore_complements, :ignore_blocks]) }\n end\n\n term_hierarchy_preprocessor = Proc.new do |data, context, render_options|\n separator = render_options['separator'] || \" · \"\n data.map do |element| \n terms = []\n terms << \"<a href=\\\"#{render_options['prefix']}/#{element.id}\\\">\"\n terms << \"#{element.description}</a>\"\n while not element.parent.nil?\n element = element.parent\n terms << separator\n terms << \"<a href=\\\"#{render_options['prefix']}/#{element.id}\\\">#{element.description}</a>\"\n end\n render_result = \"<div class=\\\"term-hierarchy-container #{render_options['container_class']}\\\">\" << terms.reverse.join << \"</div>\"\n end\n \n end\n\n ::Model::ViewRender.new(:teaser, 'teaser', ::Model::ViewStyle::VIEW_STYLE_TEASER, teaser_preprocessor)\n ::Model::ViewRender.new(:thumbnail, 'thumbnail', Model::ViewStyle::VIEW_STYLE_THUMBNAIL)\n\n end",
"def set_content\n @content = Content.find(params.require(:content_id))\n end",
"def content_params\n params.require(:content).permit!\n end",
"def content_params\n params.require(:content).permit(:title, :body, :image_url, :place)\n end",
"def set_content\n @content = Content.find(params[:id])\n @parent = @content\n end",
"def set_specific_content\n @specific_content = SpecificContent.find(params[:id])\n end",
"def contents=(params)\n self.content_needs_saving = true\n contents.each do |content|\n update = params[content.association_name][content.id.to_s]\n content.attributes = update if update\n end\n end",
"def content_params\n params.require(:content).permit(:title, :body, :content_type, :app_id, :source_link)\n end",
"def attributes\n\t\tsuper.merge({'content'=>content, 'content_type'=>content_type})\n\tend",
"def set_content_defaults\r\n @content.user_id = @user.id\r\n @content.user = @user\r\n @content.is_in_startpage = !@content.albums.detect{|a| !a.featured_album?}\r\n @content.is_in_gallery = true\r\n @content_kind_displayname = \"New #{@content.entity_name_for_human.titleize}\".t\r\n @title = @user.login + ' :: ' + @content_kind_displayname\r\n #'New Music Album'.t\r\n #'New Music Contest'.t\r\n end",
"def index\n @specific_contents = SpecificContent.all\n end",
"def set_content\n @o_single = Content.find(params[:id])\n end",
"def create_contents\n return if definition.fetch(:ingredients, []).any?\n\n definition.fetch(\"contents\", []).each do |attributes|\n Content.create(attributes.merge(element: self))\n end\n end",
"def content_params\n params.require(:content).permit(:body, :content_type_id, :sort_order)\n end",
"def content_params\n params.require(:content).permit(:text, :otu_id, :topic_id, :type)\n end",
"def add(content)\n if ( (! content.kind_of?(BioInterchange::TextMining::Content)) && (! content.kind_of?(BioInterchange::TextMining::ContentConnection)) )\n raise BioInterchange::Exceptions::ImplementationModelError, 'Content has to be of kind BioInterchange::TextMining::Content or kind BioInterchange::TextMining::ContentConnection' \n end\n @content << content\n end",
"def get_content(model_name)\n @_content ||= {}\n\n # return content if it has already been memoized\n return @_content[model_name] unless @_content[model_name].nil?\n\n #get class of content model we are trying to get content for\n model = get_content_model(model_name)\n\n if is_plural?(model_name)\n content = model.find(:all, :path => custom_content_path, :parent => self)\n else\n content = model.find(:first, :path => custom_content_path, :parent => self)\n end\n\n\n # memoize content so we don't parse file again on the same request\n @_content[model_name] = content\n end",
"def content_params\n params.require(:content).permit(:description)\n end",
"def content\n @content ||= Alchemy::Content.find_by(essence_type: acts_as_essence_class.to_s, essence_id: self.id)\n end",
"def render_model_content(model)\n if model.respond_to?(:is_using_extra_options?) && model.is_using_extra_options?\n #if model.use_placeholders? && (placeholders = /\\[(\\w*):(.*)\\]/i.match(model.content)) # anything in brackets with a colon inside => [model:title_or_id]\n # model.content = set_content_in_placeholders(model, placeholders)\n #end\n \n ERB.new(model.content).result(binding)\n else\n model.content\n end\n end",
"def find_content content_title\n self.content_title_field = content_title\n apply\n end",
"def content_params\n params.require(:content).permit(Elements::Content::ATTRIBUTES)\n end",
"def set_about_content\n @about_content = AboutContent.find(params[:id])\n end",
"def content_params\n\t params.require(:content).permit(:value_of_content, :address, :comments)\n\tend",
"def contentmodel(value)\n _contentmodel(value) or fail ArgumentError, \"Unknown value for contentmodel: #{value}\"\n end",
"def index\n @join_specific_content_to_places = JoinSpecificContentToPlace.all\n end",
"def enable_relationships\n self.items.each do |_, content_type|\n content_type.fields.find_all(&:is_relationship?).each do |field|\n # look for the target content type from its slug\n field.class_name = field.class_slug\n field.klass = self.items[field.class_slug]\n end\n end\n end",
"def set_content\n @content = Content.find(params[:id])\n \tauthorize [:admin, @content]\n end",
"def render_model_content(model)\n if model.is_using_extra_options?\n if model.use_placeholders? && (placeholders = /\\[(\\w*):(.*)\\]/i.match(model.content)) # anything in brackets with a colon inside => [model:title_or_id]\n model.content = set_content_in_placeholders(model, placeholders)\n end\n \n ERB.new(model.content).result(binding)\n else\n model.content\n end\n end",
"def aspect_target_model\n ContentManagerSystem::Content\n end",
"def content_definitions\n return nil if definition.blank?\n\n definition[\"contents\"]\n end",
"def content\n @content = content_class.published.find(params[:id])\n end",
"def setup_layouts\n @content_layouts = []\n get_layouts(File.join(::Rails.root.to_s, 'app', 'views', 'layouts')).each do |layout|\n @content_layouts << OpenStruct.new(:name => layout.titleize, :value => layout)\n end\n end",
"def include_related_content(val)\n add_actions \"includerelatedcontent(#{val})\"\n end",
"def set_sub_content\n @sub_content = SubContent.find(params[:id])\n end",
"def models\n work_classes + collection_classes\n end",
"def resolve_content\n @content_model == :simple ? %(<p>#{content}</p>) : content\n end",
"def create_proper_content_model_with_selections\n results = true\n\n print \"[Start] Creating Full ContentProfile Data Model: \"\n Rails.logger.info \"#{self.class.name}##{__method__}(START) Creating Full ContentProfile Data Model.\"\n ## Begin Good Work\n\n ContentType.create!([\n {name: \"Experience\", description: \"Monthly Experience Reports and Files\", value_data_type: \"String\",\n content_type_opts_attributes: {\n \"1\" => {value: \"*.pdf\", type_name: \"Experience\", description: \"Document store Experience PDF Type\" }}\n },\n {name: \"Commission\", description: \"Monthly Commission Reports and Files\", value_data_type: \"String\",\n content_type_opts_attributes: {\n \"0\" => {value: \"*.pdf\", type_name: \"Commission\", description: \"Document store Commision Document Type ID\" },\n \"1\" => {value: \"*.csv\", type_name: \"Commission\", description: \"Document store Commision CSV Document Type ID\" } }\n },\n {name: \"Notification\", description: \"Email Notification of Related Events\", value_data_type: \"String\",\n content_type_opts_attributes: {\n \"0\" => {value: \"AdvCancel\", type_name: \"Notification\", description: \"Advance Cancel\" },\n \"1\" => {value: \"FutCancel\", type_name: \"Notification\", description: \"Future Cancel\" },\n \"2\" => {value: \"Cancel\", type_name: \"Notification\", description: \"Cancel\" } }\n },\n {name: \"LicensedStates\", description: \"Business Operational Metric\", value_data_type: \"Integer\",\n content_type_opts_attributes: {\n \"0\"=>{:value=>\"54\", :type_name=>\"LicensedStates\", :description=>\"Alaska\"},\n \"1\"=>{:value=>\"1\", :type_name=>\"LicensedStates\", :description=>\"Alabama\"},\n \"2\"=>{:value=>\"3\", :type_name=>\"LicensedStates\", :description=>\"Arkansas\"},\n \"3\"=>{:value=>\"2\", :type_name=>\"LicensedStates\", :description=>\"Arizona\"},\n \"4\"=>{:value=>\"4\", :type_name=>\"LicensedStates\", :description=>\"California\"},\n \"5\"=>{:value=>\"5\", :type_name=>\"LicensedStates\", :description=>\"Colorado\"},\n \"6\"=>{:value=>\"6\", :type_name=>\"LicensedStates\", :description=>\"Connecticut\"},\n \"7\"=>{:value=>\"8\", :type_name=>\"LicensedStates\", :description=>\"Washington Dc\"},\n \"8\"=>{:value=>\"7\", :type_name=>\"LicensedStates\", :description=>\"Delaware\"},\n \"9\"=>{:value=>\"9\", :type_name=>\"LicensedStates\", :description=>\"Florida\"},\n \"10\"=>{:value=>\"10\", :type_name=>\"LicensedStates\", :description=>\"Georgia\"},\n \"11\"=>{:value=>\"52\", :type_name=>\"LicensedStates\", :description=>\"Hawaii\"},\n \"12\"=>{:value=>\"14\", :type_name=>\"LicensedStates\", :description=>\"Iowa\"},\n \"13\"=>{:value=>\"11\", :type_name=>\"LicensedStates\", :description=>\"Idaho\"},\n \"14\"=>{:value=>\"12\", :type_name=>\"LicensedStates\", :description=>\"Illinois\"},\n \"15\"=>{:value=>\"13\", :type_name=>\"LicensedStates\", :description=>\"Indiana\"},\n \"16\"=>{:value=>\"15\", :type_name=>\"LicensedStates\", :description=>\"Kansas\"},\n \"17\"=>{:value=>\"16\", :type_name=>\"LicensedStates\", :description=>\"Kentucky\"},\n \"18\"=>{:value=>\"17\", :type_name=>\"LicensedStates\", :description=>\"Louisiana\"},\n \"19\"=>{:value=>\"20\", :type_name=>\"LicensedStates\", :description=>\"Massachusetts\"},\n \"20\"=>{:value=>\"19\", :type_name=>\"LicensedStates\", :description=>\"Maryland\"},\n \"21\"=>{:value=>\"18\", :type_name=>\"LicensedStates\", :description=>\"Maine\"},\n \"22\"=>{:value=>\"21\", :type_name=>\"LicensedStates\", :description=>\"Michigan\"},\n \"23\"=>{:value=>\"22\", :type_name=>\"LicensedStates\", :description=>\"Minnesota\"},\n \"24\"=>{:value=>\"24\", :type_name=>\"LicensedStates\", :description=>\"Missouri\"},\n \"25\"=>{:value=>\"23\", :type_name=>\"LicensedStates\", :description=>\"Mississippi\"},\n \"26\"=>{:value=>\"25\", :type_name=>\"LicensedStates\", :description=>\"Montana\"},\n \"27\"=>{:value=>\"32\", :type_name=>\"LicensedStates\", :description=>\"North Carolina\"},\n \"28\"=>{:value=>\"33\", :type_name=>\"LicensedStates\", :description=>\"North Dakota\"},\n \"29\"=>{:value=>\"26\", :type_name=>\"LicensedStates\", :description=>\"Nebraska\"},\n \"30\"=>{:value=>\"28\", :type_name=>\"LicensedStates\", :description=>\"New Hampshire\"},\n \"31\"=>{:value=>\"29\", :type_name=>\"LicensedStates\", :description=>\"New Jersey\"},\n \"32\"=>{:value=>\"30\", :type_name=>\"LicensedStates\", :description=>\"New Mexico\"},\n \"33\"=>{:value=>\"27\", :type_name=>\"LicensedStates\", :description=>\"Nevada\"},\n \"34\"=>{:value=>\"31\", :type_name=>\"LicensedStates\", :description=>\"New York\"},\n \"35\"=>{:value=>\"34\", :type_name=>\"LicensedStates\", :description=>\"Ohio\"},\n \"36\"=>{:value=>\"35\", :type_name=>\"LicensedStates\", :description=>\"Oklahoma\"},\n \"37\"=>{:value=>\"36\", :type_name=>\"LicensedStates\", :description=>\"Oregon\"},\n \"38\"=>{:value=>\"37\", :type_name=>\"LicensedStates\", :description=>\"Pennsylvania\"},\n \"39\"=>{:value=>\"38\", :type_name=>\"LicensedStates\", :description=>\"Rhode Island\"},\n \"40\"=>{:value=>\"39\", :type_name=>\"LicensedStates\", :description=>\"South Carolina\"},\n \"41\"=>{:value=>\"40\", :type_name=>\"LicensedStates\", :description=>\"South Dakota\"},\n \"42\"=>{:value=>\"41\", :type_name=>\"LicensedStates\", :description=>\"Tennessee\"},\n \"43\"=>{:value=>\"42\", :type_name=>\"LicensedStates\", :description=>\"Texas\"},\n \"44\"=>{:value=>\"43\", :type_name=>\"LicensedStates\", :description=>\"Utah\"},\n \"45\"=>{:value=>\"45\", :type_name=>\"LicensedStates\", :description=>\"Virginia\"},\n \"46\"=>{:value=>\"44\", :type_name=>\"LicensedStates\", :description=>\"Vermont\"},\n \"47\"=>{:value=>\"46\", :type_name=>\"LicensedStates\", :description=>\"Washington\"},\n \"48\"=>{:value=>\"48\", :type_name=>\"LicensedStates\", :description=>\"Wisconsin\"},\n \"49\"=>{:value=>\"47\", :type_name=>\"LicensedStates\", :description=>\"West Virginia\"},\n \"50\"=>{:value=>\"49\", :type_name=>\"LicensedStates\", :description=>\"Wyoming\"},\n \"51\"=>{:value=>\"58\", :type_name=>\"LicensedStates\", :description=>\"Puerto Rico\"},\n \"52\"=>{:value=>\"81\", :type_name=>\"LicensedStates\", :description=>\"A F Americas\"},\n \"53\"=>{:value=>\"82\", :type_name=>\"LicensedStates\", :description=>\"A F Europe\"},\n \"54\"=>{:value=>\"83\", :type_name=>\"LicensedStates\", :description=>\"A F Pacific\"},\n \"55\"=>{:value=>\"84\", :type_name=>\"LicensedStates\", :description=>\"American Samoa\"},\n \"56\"=>{:value=>\"85\", :type_name=>\"LicensedStates\", :description=>\"Micronesia\"},\n \"57\"=>{:value=>\"86\", :type_name=>\"LicensedStates\", :description=>\"Guam\"},\n \"58\"=>{:value=>\"87\", :type_name=>\"LicensedStates\", :description=>\"Marshall Isl\"},\n \"59\"=>{:value=>\"88\", :type_name=>\"LicensedStates\", :description=>\"N Mariana Isl\"},\n \"60\"=>{:value=>\"89\", :type_name=>\"LicensedStates\", :description=>\"Palau\"},\n \"61\"=>{:value=>\"99\", :type_name=>\"LicensedStates\", :description=>\"Not Found\"} }\n },\n {name: \"Activity\", description: \"Partner Relationship Reports\", value_data_type: \"String\",\n content_type_opts_attributes: {\n \"0\" => {value: \"*.pdf\", type_name: \"Activity\", description: \"Document store Project Status Report Document Type ID\"}\n }\n },\n {name: \"FileDownload\", description: \"Project Related Resources\", value_data_type: \"String\",\n content_type_opts_attributes: {\n \"0\" => {value: \"*.png\", type_name: \"FileDownload\", description: \"Project Related by Document Type PNG\"},\n \"1\" => {value: \"*.jpg\", type_name: \"FileDownload\", description: \"Project Related by Document Type JPEG\"},\n \"2\" => {value: \"*.pdf\", type_name: \"FileDownload\", description: \"Project Related by Document Type PDF\"},\n \"3\" => {value: \"*.log\", type_name: \"FileDownload\", description: \"Project Related by Document Type LOG\"}\n }\n }\n ])\n\n TopicType.create!([\n {name: \"Branch\", description: \"Branch Actions for a specific branch\", value_based_y_n: \"N\",\n topic_type_opts_attributes: {\n \"0\" => {value: \"0034\", type_name: \"Branch\", description: \"South Branch Number\"},\n \"1\" => {value: \"0037\", type_name: \"Branch\", description: \"North Branch Number\"},\n \"2\" => {value: \"0040\", type_name: \"Branch\", description: \"West Branch Number\"} }\n },\n {name: \"Partner\", description: \"This Corporate Account\", value_based_y_n: \"N\",\n topic_type_opts_attributes: {\n \"0\" => {value: \"0099\", type_name: \"Partner\", description: \"Skoona Consulting\"}}\n },\n {name: \"UserGroups\", description: \"Shared access to project working files\", value_based_y_n: \"N\",\n topic_type_opts_attributes: {\n \"0\" => {value: \"Manager\", type_name: \"UserGroups\", description: \"Project Workfiles\"},\n \"1\" => {value: \"EmployeePrimary\", type_name: \"UserGroups\", description: \"Project Workfiles\"},\n \"2\" => {value: \"EmployeeSecondary\", type_name: \"UserGroups\", description: \"Project Workfiles\"},\n \"3\" => {value: \"VendorPrimary\", type_name: \"UserGroups\", description: \"Project Workfiles\"},\n \"4\" => {value: \"VendorSecondary\", type_name: \"UserGroups\", description: \"Project Workfiles\"},\n \"5\" => {value: \"BranchPrimary\", type_name: \"UserGroups\", description: \"Project Workfiles\"},\n \"6\" => {value: \"BranchSecondary\", type_name: \"UserGroups\", description: \"Project Workfiles\"},\n \"7\" => {value: \"Developer\", type_name: \"UserGroups\", description: \"Project Workfiles\"}\n }\n }\n ])\n\n cpe_developer = []\n [\n ['Experience', ['*.pdf'], 'Branch', ['0034'], 'Branch Experience Statements'],\n ['Commission', ['*.pdf'], 'Branch', ['0034'], 'Access Branch Commission PDF Files'],\n ['Notification', ['AdvCancel'], 'Branch', ['0034'], 'Notify Branch of Policy Events'],\n ['LicensedStates', ['21'], 'Branch', ['0034'], 'Licensed to operate in state'],\n ['LicensedStates', ['12'], 'Branch', ['0034'], 'Licensed to operate in state'],\n ['LicensedStates', ['13'], 'Branch', ['0034'], 'Licensed to operate in state'],\n ['Activity', ['*.pdf'], 'Partner', ['0099'], 'Partner Relationship Reports'],\n\n ['Experience', ['*.pdf'], 'Branch', ['0037'], 'Branch Experience Statements'],\n ['Commission', ['*.pdf'], 'Branch', ['0037'], 'Access Branch Commission CSV Files'],\n ['Notification', ['Cancel'], 'Branch', ['0037'], 'Notify Branch of Policy Events'],\n ['LicensedStates', ['34'], 'Branch', ['0037'], 'Licensed to operate in state'],\n ['LicensedStates', ['37'], 'Branch', ['0037'], 'Licensed to operate in state'],\n ['LicensedStates', ['31'], 'Branch', ['0037'], 'Licensed to operate in state'],\n\n ['Experience', ['*.pdf'], 'Branch', ['0040'], 'Branch Experience Statements'],\n ['Commission', ['*.pdf'], 'Branch', ['0040'], 'Access Branch Commission PDF Files'],\n ['Notification', ['FutCancel'], 'Branch', ['0040'], 'Notify Branch of Policy Events'],\n ['LicensedStates', ['24'], 'Branch', ['0040'], 'Licensed to operate in state'],\n ['LicensedStates', ['14'], 'Branch', ['0040'], 'Licensed to operate in state'],\n ['LicensedStates', ['3'], 'Branch', ['0040'], 'Licensed to operate in state'],\n\n ['FileDownload', ['*.pdf'], 'UserGroups', ['Developer'], 'Shared access to project working files'],\n ['FileDownload', ['*.png'], 'UserGroups', ['Developer'], 'Shared access to project working files'],\n ['FileDownload', ['*.jpg'], 'UserGroups', ['Developer'], 'Shared access to project working files'],\n ['FileDownload', ['*.log'], 'UserGroups', ['Developer'], 'Shared access to project working files']\n\n ].each do |req|\n cchoice = selections_choose_for(req[1], selections_for_content_type(req[0], true))\n tchoice = selections_choose_for(req[3], selections_for_topic_type(req[2], true))\n cpe_developer << create_content_profile_entry_for(req.last, tchoice, cchoice)\n end\n\n cpe_primary = []\n [\n ['Experience', ['*.pdf'], 'Branch', ['0034'], 'Branch Experience Statements'],\n ['Commission', ['*.pdf'], 'Branch', ['0034'], 'Access Branch Commission PDF Files'],\n ['Notification', ['AdvCancel'], 'Branch', ['0034'], 'Notify Branch of Policy Events'],\n ['LicensedStates', ['21'], 'Branch', ['0034'], 'Licensed to operate in state'],\n ['LicensedStates', ['12'], 'Branch', ['0034'], 'Licensed to operate in state'],\n ['LicensedStates', ['13'], 'Branch', ['0034'], 'Licensed to operate in state'],\n ['Activity', ['*.pdf'], 'Partner', ['0099'], 'Partner Relationship Reports'],\n\n ['Experience', ['*.pdf'], 'Branch', ['0037'], 'Branch Experience Statements'],\n ['Commission', ['*.csv'], 'Branch', ['0037'], 'Access Branch Commission CSV Files'],\n ['Notification', ['Cancel'], 'Branch', ['0037'], 'Notify Branch of Policy Events'],\n ['LicensedStates', ['34'], 'Branch', ['0037'], 'Licensed to operate in state'],\n ['LicensedStates', ['37'], 'Branch', ['0037'], 'Licensed to operate in state'],\n ['LicensedStates', ['31'], 'Branch', ['0037'], 'Licensed to operate in state'],\n\n ['Experience', ['*.pdf'], 'Branch', ['0040'], 'Branch Experience Statements'],\n ['Commission', ['*.pdf'], 'Branch', ['0040'], 'Access Branch Commission PDF Files'],\n ['Notification', ['FutCancel'], 'Branch', ['0040'], 'Notify Branch of Policy Events'],\n ['LicensedStates', ['24'], 'Branch', ['0040'], 'Licensed to operate in state'],\n ['LicensedStates', ['14'], 'Branch', ['0040'], 'Licensed to operate in state'],\n ['LicensedStates', ['3'], 'Branch', ['0040'], 'Licensed to operate in state'],\n\n ['FileDownload', ['*.pdf'], 'UserGroups', ['EmployeePrimary'], 'Shared access to project working files'],\n ['FileDownload', ['*.png'], 'UserGroups', ['EmployeePrimary'], 'Shared access to project working files'],\n ['FileDownload', ['*.jpg'], 'UserGroups', ['EmployeePrimary'], 'Shared access to project working files'],\n ['FileDownload', ['*.log'], 'UserGroups', ['EmployeePrimary'], 'Shared access to project working files']\n\n ].each do |req|\n cchoice = selections_choose_for(req[1], selections_for_content_type(req[0], true))\n tchoice = selections_choose_for(req[3], selections_for_topic_type(req[2], true))\n cpe_primary << create_content_profile_entry_for(req.last, tchoice, cchoice)\n end\n\n cpe_sec = []\n [\n ['Experience', ['*.pdf'], 'Branch', ['0034'], 'Branch Experience Statements'],\n ['Commission', ['*.pdf'], 'Branch', ['0034'], 'Access Branch Commission PDF Files'],\n ['Notification', ['AdvCancel'], 'Branch', ['0034'], 'Notify Branch of Policy Events'],\n ['Activity', ['*.pdf'], 'Partner', ['0099'], 'Partner Relationship Reports'],\n\n ['Experience', ['*.pdf'], 'Branch', ['0040'], 'Branch Experience Statements'],\n ['Commission', ['*.pdf'], 'Branch', ['0040'], 'Access Branch Commission PDF Files'],\n ['Notification', ['FutCancel'], 'Branch', ['0040'], 'Notify Branch of Policy Events'],\n\n ['FileDownload', ['*.pdf'], 'UserGroups', ['EmployeeSecondary'], 'Shared access to project working files'],\n ['FileDownload', ['*.pdf'], 'UserGroups', ['BranchPrimary'], 'Shared access to project working files']\n\n ].each do |req|\n cchoice = selections_choose_for(req[1], selections_for_content_type(req[0], true))\n tchoice = selections_choose_for(req[3], selections_for_topic_type(req[2], true))\n cpe_sec << create_content_profile_entry_for(req.last, tchoice, cchoice)\n end\n\n cpe_vendor = []\n [\n ['Activity', ['*.pdf'], 'Partner', ['0099'], 'Partner Relationship Reports'],\n ['FileDownload', ['*.log'], 'UserGroups', ['VendorPrimary'], 'Shared access to project working files']\n\n ].each do |req|\n cchoice = selections_choose_for(req[1], selections_for_content_type(req[0], true))\n tchoice = selections_choose_for(req[3], selections_for_topic_type(req[2], true))\n cpe_vendor << create_content_profile_entry_for(req.last, tchoice, cchoice)\n end\n\n # loop thru users\n res = Secure::UserProfile.page_users.each do |u|\n next if u.user_options.empty? or u.user_options.include?(\"VendorSecondary\")\n\n cp = create_content_profile_for(u, u.assigned_groups.first)\n\n entries = case u.assigned_groups.first\n when 'Developer'\n cpe_developer\n when 'Manager', 'EmployeePrimary'\n cpe_primary\n when 'EmployeeSecondary', 'BranchPrimary'\n cpe_sec\n else\n cpe_vendor\n end\n\n assign_content_profile_entry_to(cp, entries)\n\n end\n\n\n ## End Good Work\n puts \"[Success!]\"\n Rails.logger.info \"#{self.class.name}##{__method__}(SUCCESS) Creating Full ContentProfile Data Model.\"\n results\n rescue Exception => e\n Rails.logger.error \"#{self.class.name}.#{__method__}(FAILED) Creating Full ContentProfile Data Model; Klass: #{e.class.name}, Cause: #{e.message} #{e.backtrace[0..4]}\"\n puts \"[Failed!]\"\n false\n end",
"def content_methods; end",
"def set_tableofcontent\n @tableofcontent = Tableofcontent.friendly.find(params[:id])\n end",
"def content_params\n params.require(:content).permit(:cla_id, :title,:content,:auther,:image, :price,:summary, :icon, :name, :mail, )\n end",
"def set_content_admin\n @content_admin = ContentAdmin.find(params[:id])\n end",
"def any_content(includes = true)\n @any_content ||= !(\n @comment.empty? &&\n @method_list.empty? &&\n @attributes.empty? &&\n @aliases.empty? &&\n @external_aliases.empty? &&\n @requires.empty? &&\n @constants.empty?\n )\n @any_content || (includes && !(@includes + @extends).empty? )\n end",
"def set_media_content\n @media_content = MediaContent.find(params[:id])\n end",
"def build_content_metadata record, tags\n # TODO: Further enrich the structured data by marking up FAQ accordions, Video Carousels, Image Galleries, etc.\n # Also ItemList metadata for the meditations archive\n # See here: https://developers.google.com/search/docs/data-types/article\n []\n end",
"def entity content\n end",
"def front_end_content_params\n params.require(:front_end_content).permit!\n end",
"def models\r\n\r\n end",
"def content_params\n params.require(:content).permit(:heading, :subheading, :description, :index, :archived, :_destroy,\n images_attributes: [:id, :image, :content_id, :_destroy])\n end",
"def merge(content_data)\n content_data.contents.values.each { |content|\n add_content(content)\n }\n content_data.instances.values.each { |instance|\n add_instance(instance)\n }\n end",
"def content_types\n ContentTypes.new(self)\n end",
"def index\n # @contents = Content.all\n end",
"def content_manipulation\n self.summary = markup_manipulation self.summary if self.summary.present?\n self.content = markup_manipulation self.content if self.content.present?\n end",
"def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name,content|\n view.content_for name, content\n end\n end\n end",
"def content_params\n params.require(:content).permit(:name, :resource_id, :resource_type, :parent_id, :navlabel, :active, :admin, :redirect, :controller_redirect, :action_redirect, :position, :controller_name, :category)\n end",
"def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name,content|\n view.content_for name, content\n end\n end\n end",
"def set_content_template\n @content_template = ContentTemplate.find(params[:id])\n end",
"def user_content_params\n params.require(:user_content).permit(:user_id, :content_id)\n end",
"def set_join_specific_content_to_place\n @join_specific_content_to_place = JoinSpecificContentToPlace.find(params[:id])\n end",
"def main_content\n do_include(@template)\n end",
"def content_descriptions\n return nil if definition.blank?\n definition['contents']\n end",
"def content_should_be_allowed_as_content_representation\n errors.add(:content, :not_allowed_as) unless\n content &&\n parent &&\n parent.own_or_inherited_layout_variant[target].present? &&\n content.content_type_configuration[:available_content_representations].include?(parent.own_or_inherited_layout_variant[target]['representation'])\n end",
"def about_content_params\n params.require(:about).permit(:title, :content, :image_url)\n end",
"def get_content_objects(as = :models) \n query = \"is_part_of_ssim:#{full_pid}\"\n row_count = ActiveFedora::SolrService.count(query)\n results = ActiveFedora::SolrService.query(query, rows: row_count)\n parse_return_statement(as, results)\n end",
"def add_content_items_to_collections context\n\n context[:all_metadata].select do |item|\n item[:file_type] == :content && (\n context[:status] == :preview || item['published'] )\n end.each do | item |\n context[( item['content_type'] + 's').to_sym ] ||= []\n context[( item['content_type'] + 's').to_sym ].push item\n end\n end",
"def with_content(content)\n @content = content\n self\n end",
"def content\n end",
"def content\n end",
"def content\n end",
"def information_content_params\n params.require(:information_content).permit(:information_area, :content)\n end",
"def set_extra_stuff\n @templates = Template.all\n @tags = tags_for('Common')\n end",
"def interactive_content_params\n params.require(:interactive_content).permit(:content_type, :name, :content, :production_date, :producer_name, :admin_note)\n end",
"def content_columns #:nodoc:\n self.model_name.constantize.content_columns.collect { |c| c.name.to_sym }.compact rescue []\n end",
"def use_tinymce\n @content_for_tinymce = \"\" \n content_for :tinymce do\n javascript_include_tag \"tiny_mce/tiny_mce\"\n end\n @content_for_tinymce_init = \"\" \n content_for :tinymce_init do\n javascript_include_tag \"mce_editor\"\n end\n end"
] |
[
"0.6334754",
"0.6129015",
"0.6087126",
"0.60795563",
"0.5967125",
"0.58907115",
"0.5809402",
"0.5793399",
"0.5793399",
"0.5793399",
"0.5793399",
"0.5782194",
"0.5782194",
"0.5782194",
"0.5782194",
"0.5782194",
"0.5782194",
"0.5782194",
"0.57793635",
"0.57523406",
"0.5708118",
"0.5705633",
"0.56854683",
"0.56854415",
"0.5666218",
"0.56536525",
"0.56451744",
"0.5614481",
"0.559944",
"0.55879176",
"0.558281",
"0.55348",
"0.55263704",
"0.55098766",
"0.54952854",
"0.5491653",
"0.54713726",
"0.5468805",
"0.54647434",
"0.5445064",
"0.54386735",
"0.5426964",
"0.5411431",
"0.54083914",
"0.54078746",
"0.53840333",
"0.5365449",
"0.535543",
"0.5355065",
"0.5337781",
"0.53375363",
"0.5328552",
"0.53012556",
"0.5298113",
"0.52964085",
"0.52693063",
"0.52483284",
"0.52269864",
"0.52246624",
"0.5213851",
"0.5193994",
"0.5188716",
"0.5174181",
"0.5166088",
"0.5159289",
"0.5158966",
"0.5148935",
"0.51453567",
"0.5133995",
"0.51263994",
"0.5124127",
"0.5105559",
"0.50973916",
"0.5088833",
"0.50868064",
"0.5080195",
"0.50730705",
"0.507001",
"0.5062211",
"0.502495",
"0.502324",
"0.5023049",
"0.50191414",
"0.50176907",
"0.50140905",
"0.50093365",
"0.50075483",
"0.5007444",
"0.4999279",
"0.49947423",
"0.49934614",
"0.49823815",
"0.49772778",
"0.49772778",
"0.49772778",
"0.49764922",
"0.49737048",
"0.496721",
"0.4967061",
"0.49616727"
] |
0.6385777
|
0
|
short cut to get all content_types
|
def content_types
self.class.custom_content_types
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def content_types\n type.children.select { |child| child.class == ContentType }\n end",
"def content_types\n return @content_types\n end",
"def content_types\n self.values.collect do |hash|\n (hash || {})['type']\n end.compact\n end",
"def content_types\n result = call(\"Webs\", \"get_content_types\", \"listName\" => @id)\n result.xpath(\"//sp:ContentType\", NS).map do |content_type|\n supersite && supersite.content_type(content_type[\"ID\"]) || ContentType.new(self, nil, content_type[\"ID\"], content_type[\"Name\"], content_type[\"Description\"], content_type[\"Version\"], content_type[\"Group\"])\n end\n end",
"def content_types\n ContentTypes.new(self)\n end",
"def content_types(meta=false)\n content_type_classes(meta).map { |cls| cls.key }\n end",
"def accepted_content_types\n return @content_types if @content_types\n @content_types = []\n if val = @ext_params[\"content_return_types\"]\n @content_types = val.split(',').map {|i| i.to_sym}\n end\n\n @content_types\n end",
"def content_types(query = {})\n resp =\n _instrument 'content_types', query: query do\n get('content_types', query)\n end\n resp.assert_ok!\n end",
"def content_types\n self.mounting_point.content_types\n end",
"def available_related_content_types\n available_related_content.map{|hash| hash['Type'] }\n end",
"def available_content_types\n if self.api_file.download_url\n return [self.api_file.mime_type]\n else\n return []\n end\n end",
"def content_types=(value)\n @content_types = value\n end",
"def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| kind.term }\n end",
"def mime_types\n [].tap do |result|\n @parts.each do |part|\n result << part.content_type\n end\n end\n end",
"def types\n get_metadata unless @types\n return @types\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def filter_content_types(recommendations_types)\n Content.filter_content_types(recommendations_types)\n end",
"def content_types\n EnvironmentContentTypeMethodsFactory.new(self)\n end",
"def contentByType( type )\n\t\tcontent = nil\n\t\t@content.each_index { |i|\n\t\t\tif @content[i].type == type\n\t\t\t\tcontent = @content[i]\n\t\t\tend\n\t\t}\n\t\tcontent\n\tend",
"def proper_types\n Page.distinct(:_type).reject { |type| type.constantize.new.entry? }\n end",
"def index\n @content_types = ContentType.order(:position)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def readable_entry_types\n BIDURI['entry_types'].select{|s| s['has_own_page'].nil? || s['has_own_page'] == true}.map{|m| m['entry_type']}\n end",
"def get_post_types(args = {}, output = 'names', operator = 'and')\n field = ( 'names' == output ) ? 'name' : false\n\n wp_filter_object_list(Railspress.GLOBAL.wp_post_types, args, operator, field)\n end",
"def category_types\n @category_types.each\n end",
"def content_type_classes(meta=false)\n (meta ? @metadata_tree.node_types : @content_tree.node_types).dup\n end",
"def types\n respond_to?(:articleType) ? articleType : []\n end",
"def mime_types\n safe_const_get(:MIME_TYPES) || []\n end",
"def available_types\n gather do |c|\n c.respond_to?(:model_types) ? c.model_types : []\n end\n end",
"def content_type_whitelist\n MIME_TYPE_WHITELIST\n end",
"def content_return_types\n get_ext_param('content_return_types')\n end",
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def entity_types\n @entity_types ||= metadata.xpath('//EntityType').collect {|entity| entity.attributes['Name'].value}\n end",
"def allowed_types\n [ Entities::Domain, \n Entities::Host, \n Entities::Organization, \n Entities::SearchString, \n Entities::Person]\nend",
"def content_type\n content_type_class.constantize if content_type_class\n end",
"def all\n all_by_type.values.flatten\n end",
"def get_link_types\n Occi::Log.debug(\"Getting link types ...\")\n collection = @model.get Occi::Core::Link.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def dor_resource_content_type\n public_xml_doc.xpath('//contentMetadata/resource/@type').map(&:text)\n end",
"def get_all_post_types\n post_types = {'Interview' => '<i class=\"fa fa-fw fa-newspaper-o\"></i>',\n 'Case Study' => '<i class=\"fa fa-fw fa-list\"></i>',\n 'Facebook' => '<i class=\"fa fa-fw fa-facebook-official\"></i>',\n 'Twitter' => '<i class=\"fa fa-fw fa-twitter\"></i>',\n 'LinkedIn' => '<i class=\"fa fa-fw fa-linkedin-square\"></i>',\n 'Instagram' => '<i class=\"fa fa-fw fa-instagram\"></i>',\n 'Blog Post' => '<i class=\"fa fa-fw fa-wordpress\"></i>',\n 'White Paper' => '<i class=\"fa fa-fw fa-file-o\"></i>',\n 'Ebook' => '<i class=\"fa fa-fw fa-book\"></i>',\n 'Slidedeck' => '<i class=\"fa fa-fw fa-map-o\"></i>',\n 'Video' => '<i class=\"fa fa-fw fa-video-camera\"></i>',\n 'Podcast' => '<i class=\"fa fa-fw fa-microphone\"></i>'\n }\n end",
"def view_types(for_select = true) # get the defined view type partials. e.g. views/views/list.html.erb\n fetch_array_for get_view_types, for_select\n end",
"def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::Domain, \n Entities::Host,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend",
"def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end",
"def content_type\n ContentType.new(@site, @list, attributes[\"ContentTypeId\"])\n end",
"def getTypeUrlFromTypesObject(types)\n return types.map {|x| x['type']['url']}.compact\nend",
"def types\n @types ||= []\n end",
"def media_types\n return @media_types\n end",
"def entity_types\n @entity_types ||= schemas.map do |namespace, schema|\n schema.entity_types.map do |entity_type|\n \"#{namespace}.#{entity_type}\"\n end\n end.flatten\n end",
"def entity_types\n @entity_types ||= schemas.map do |namespace, schema|\n schema.entity_types.map do |entity_type|\n \"#{namespace}.#{entity_type}\"\n end\n end.flatten\n end",
"def media_types\n Restfulie::MediaType.default_types + MediaType.medias_for(self)\n end",
"def get_content_type_headers\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/getContentType'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request)\n validate_response(_response)\n end",
"def content_types(*content_types)\n Sinatra::RPC::Serializer.register self, content_types\n @response_content_type = content_types.compact.first\n end",
"def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::DnsRecord, \n Entities::Host,\n Entities::EmailAddress,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend",
"def mime_types(type)\n mime_types = {\n yaml: \"application/x-yaml\",\n json: \"application/json\"\n }\n mime_types[type.to_sym]\n end",
"def service_types_generated \n types = [ ServiceTypeValue[:fulltext], ServiceTypeValue[:holding], ServiceTypeValue[:table_of_contents], ServiceTypeValue[:relevant_link] ]\n \n return types\n end",
"def index\n @contents = Content.all(:order => \"resource_type, resource_id\")\n @types = Content.all(:select => \"distinct resource_type\") \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contents }\n end\n end",
"def recognized_item_types\n\t\t# , 'DocFile', 'DocImage', 'DocPrivate', 'Path'\n\t\t['Article', 'Document', 'Event', 'Group', 'Page', 'Petition', 'Signature', 'User', 'Weblink']\n\tend",
"def types(types); end",
"def all_items(type = nil)\n if type\n @api_items.select {|k, v| v.kind_of?(TYPE_MAP[type])}.keys\n else\n @api_items.keys\n end\n end",
"def content_type_denylist\n end",
"def allowed_types\n [ Entities::Account,\n Entities::DnsRecord, \n Entities::DnsServer, \n Entities::DocFile,\n Entities::EmailAddress,\n Entities::FacebookAccount,\n Entities::Finding,\n Entities::Host, \n Entities::LocalImage,\n Entities::RemoteImage,\n Entities::KloutAccount,\n Entities::NetBlock,\n Entities::NetSvc,\n Entities::Organization,\n Entities::ParsableFile,\n Entities::ParsableText,\n Entities::PdfFile,\n Entities::Person,\n Entities::PhysicalLocation, \n Entities::SearchString, \n Entities::TwitterAccount,\n Entities::Username,\n Entities::WebApplication,\n Entities::WebForm,\n Entities::WebPage,\n Entities::XlsFile ]\n end",
"def getMetadatatypes\n \n @queryparams = params\n \n # Get all metadatatypes\n @results = MetadataType.find(:all, :order => \"updated_at ASC\" )\n \n if params[:format] && params[:format]== \"json\" || params[:format] == \"yaml\"\n @yaml_results = {}\n @results.each do |result|\n @yaml_results.merge!({result.name => result.value_type})\n end\n \n end\n \n # host parameter, needed when creating atom-feed\n if request.ssl?\n @host = \"https://#{request.host}\"\n else\n @host = \"http://#{request.host}\"\n end\n\n if request.port != nil and request.port != 80\n @host += \":#{request.port}\"\n end \n \n # Create atom feed\n @host = @@http_host\n respond_to do |format|\n if @queryparams[:format] == nil\n format.html {render :getmetadatatypes, :layout=>true }\n else\n format.html {render :getmetadatatypes, :layout=>true }\n format.atom {render :getmetadatatypes, :layout=>false }\n format.yaml {render :text => YAML.dump(@yaml_results), :layout=>false }\n format.json {render :text => JSON.dump(@yaml_results), :layout=>false }\n end\n end\n end",
"def content_type(name)\n name_li(name).span(:class=>/(mylibrary_item_|searchcontent_result_)mimetype/).text\n end",
"def index\n @entity_types = EntityType.all\n end",
"def index\n @admin_media_types = Admin::MediaType.all\n end",
"def the_content_type(content=nil)\n if node = content || @content || Content.get(params[:id])\n node.content_type\n else\n \"<strong>Error:</strong> No content type information could be found\" unless ENV['RACK_ENV'] == 'production'\n end\n end",
"def types\n if @@types.nil? || (@@last_type_check + (4 * 60 * 60)) < Time.now\n @@last_type_check = Time.now\n @@types = _make_request(:types)['results']\n end\n @@types\n end",
"def types(pattern = nil)\n @types ||= @doc.xpath(\"//*\").map { |e| e.name }.uniq\n\n pattern ?\n @types.select { |t| t =~ Regexp.new(pattern) } :\n @types\n end",
"def types(pattern = nil)\n @types ||= @doc.xpath(\"//*\").map { |e| e.name }.uniq\n\n pattern ?\n @types.select { |t| t =~ Regexp.new(pattern) } :\n @types\n end",
"def freebase_types\n _response_entity.fetch(\"freebaseTypes\", [])\n end",
"def get_all_types\n types = Hash.new()\n @packages.each do |key, value|\n types[key] = value.stringpool_typestrings.values\n end\n\n return types\n end",
"def contact_types\n values = categories.map(&:contact_type_id)\n values.empty? ? @contact_types : values\n end",
"def contents_from_html\n types_ids = []\n html = introduction + links\n page = Hpricot(html)\n as = page.search('//a')\n as.each do |a|\n href = a.attributes['href']\n ActiveRecord::Acts::Content.model_types.each do |t|\n underscore = t.underscore\n if href =~ /\\/#{underscore.pluralize}\\/(.+)/ # The URL must be in the form /plural/id\n id = $1.to_i\n types_ids << [t, id]\n end\n end\n end\n\n ret = []\n types_ids.uniq!\n types_ids.each do |t, id|\n klass = t.constantize\n content = klass.find_by_id(id)\n ret << content unless content.nil?\n end\n ret\n end",
"def merchant_types\n MerchantType.find merchant_type_ids\n end",
"def content_type_allowlist\n Rails.configuration.x.file_upload_content_type_allowlist.split(/\\s*,\\s*/)\n end",
"def registered_types\n end",
"def item_types(refresh: false)\n cname = \"#{name}.item_types\"\n Rails.cache.delete(cname) if refresh\n\n Rails.cache.fetch(cname) do\n list = []\n implementation_classes.each do |imp_class|\n list += imp_class.attribute_names\n .select { |a| Classification::GeneralSelection.use_with_attribute?(a) }\n .map do |a|\n mn = imp_class.model_name.to_s.ns_underscore\n mn = mn.pluralize unless imp_class.respond_to?(:is_activity_log)\n \"#{mn}_#{a}\".to_sym\n end\n end\n\n list\n end\n end",
"def types(types)\n select { |node| types.include?(node.type) }\n end",
"def types(types)\n select { |node| types.include?(node.type) }\n end",
"def index\n authorize @thing, :get_types?\n @thing_types = @thing.thing_types\n end",
"def all_of_type\n Resource::AllOfType.new(type)\n end",
"def proper_pages\n Page.where(:_type.in => proper_types)\n end",
"def extract_types(doc)\n types = []\n @raw_types.each do |raw_type|\n doc.each_element_with_attribute('name', raw_type, 0,\n '//schema/complexType') do |type_node|\n type = {:name => raw_type, :fields => []}\n ext_node = REXML::XPath.first(type_node, 'complexContent/extension')\n if ext_node\n base_type = ext_node.attribute('base').to_s.gsub(/^.+:/, '')\n type[:base] = base_type\n @raw_types << base_type unless @raw_types.include?(base_type)\n seq_node = REXML::XPath.first(ext_node, 'sequence')\n fields = get_element_fields(seq_node)\n process_method_field_types(fields)\n type[:fields] += fields\n end\n seq_node = REXML::XPath.first(type_node, 'sequence')\n if seq_node\n fields = get_element_fields(seq_node)\n process_method_field_types(fields)\n type[:fields] += fields\n end\n types << type\n end\n end\n return types\n end",
"def all(*types); end",
"def get_content_type\n self.content_type\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def content_type\n @resource.content_type\n end",
"def content_type\n self.name[/::(.*)$/, 1].underscore.gsub(/_/, '/')\n end",
"def get_types(type)\n result = []\n types = TYPE_CONVERSION_TREE[type]\n if types\n result += types\n types.each do |t|\n result |= get_types(t)\n end\n end\n result\n end",
"def dor_content_type\n public_xml_doc.xpath('//contentMetadata/@type').text\n end",
"def get_exchange_types\n exchange_types = []\n ExchangeType.where(:selectable => true).each do |et|\n exchange_types.push(et.msgid)\n end\n\n if self.exchange_types.empty? or self.exchange_types.include?('exchangetype.open_for_all_offers')\n return exchange_types\n end\n\n return exchange_types & self.exchange_types\n end",
"def get_activites_supportedtypes()\n @restv9.get_activites_supportedobjecttypes()\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def get_list_service_types\n ServiceType.get_list_service_types\n end",
"def content_type\n guidance_urls.for_scraping.first.try(:content_type)\n end",
"def meta_content_type(body); end",
"def extensions\n TYPE_EXTS[type] || []\n end",
"def content_type\n if id = self.content_type_id\n @content_type ||= self.site.content_types.find(id) rescue nil\n else\n nil\n end\n end",
"def return_sub_types\n main_type = type_status\n if main_type\n return self.beer_subtypes.map{|type| {id: type.id, name: type.name}}\n else\n return types_for_subtype\n end\n end",
"def defined_classes\n # TODO: check content type before scanning\n content.scan(/\\s*class\\s+([A-Za-z0-9_\\.]*)/).flatten\n end",
"def mime_types(*types)\n types.flatten.each do |t|\n @mime_types << t\n end\n @mime_types\n end",
"def org_types\n organizations.map(&:organization_type)\n end"
] |
[
"0.82932085",
"0.80205816",
"0.79431593",
"0.79315645",
"0.75378376",
"0.7463109",
"0.72879255",
"0.7283435",
"0.7252349",
"0.7223778",
"0.6832146",
"0.6768432",
"0.65115404",
"0.65114963",
"0.650651",
"0.6479295",
"0.63892066",
"0.6328243",
"0.6278252",
"0.625154",
"0.62469375",
"0.6243119",
"0.62089926",
"0.62005955",
"0.61732316",
"0.61315554",
"0.6129767",
"0.6101181",
"0.6098352",
"0.60811186",
"0.60576415",
"0.60439867",
"0.6027342",
"0.60104793",
"0.6009292",
"0.60088956",
"0.60023385",
"0.59947425",
"0.5972638",
"0.5966938",
"0.5965615",
"0.5963625",
"0.5962684",
"0.59623533",
"0.59570044",
"0.5950258",
"0.5950258",
"0.5925309",
"0.5924461",
"0.58960634",
"0.586802",
"0.58674884",
"0.5859861",
"0.5852679",
"0.58487993",
"0.58469665",
"0.58465123",
"0.58446705",
"0.5836535",
"0.5816448",
"0.58157855",
"0.58141994",
"0.5812166",
"0.5810612",
"0.5810474",
"0.57977134",
"0.57977134",
"0.57965165",
"0.5781698",
"0.5781545",
"0.57799304",
"0.57312137",
"0.5730862",
"0.5729957",
"0.5729623",
"0.57282794",
"0.57282794",
"0.5705189",
"0.57033515",
"0.5702238",
"0.56988204",
"0.5697216",
"0.56899774",
"0.56801677",
"0.5678382",
"0.5665838",
"0.56653774",
"0.56617934",
"0.56573075",
"0.56568414",
"0.5651103",
"0.5642669",
"0.5629433",
"0.56276107",
"0.5622932",
"0.5615671",
"0.56145686",
"0.5612078",
"0.5599372",
"0.5594322"
] |
0.7325148
|
6
|
returns an array (YamlContentBaseArray) of all the content objects (one YamlContentBase instance if it isn't plural).
|
def get_content(model_name)
@_content ||= {}
# return content if it has already been memoized
return @_content[model_name] unless @_content[model_name].nil?
#get class of content model we are trying to get content for
model = get_content_model(model_name)
if is_plural?(model_name)
content = model.find(:all, :path => custom_content_path, :parent => self)
else
content = model.find(:first, :path => custom_content_path, :parent => self)
end
# memoize content so we don't parse file again on the same request
@_content[model_name] = content
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all_contents()\n contents = self.content.flatten.map do |c|\n case c\n when Eddy::Models::Loop::Repeat then c.all_contents()\n when Eddy::Models::Loop::Base then c.all_contents()\n when Eddy::Models::Segment then c\n else raise Eddy::Errors::RenderError\n end\n end\n return contents.flatten\n end",
"def get_contents \n @contents = []\n\n sub_directory_names = Dir[CONTENT_ROOT_DIRECTORY + \"/*\"]\n\n sub_directory_names.each do |sub_directory_name|\n sub_directory_basename = File.basename(sub_directory_name)\n @contents.push(Content.new(sub_directory_basename))\n end\n end",
"def sub_content \n sub_contents = []\n\n if @is_post == false\n root_regexp = Regexp.new(@root, Regexp::IGNORECASE)\n sub_directories = Dir.glob(@absolute_path + '*');\n\n sub_directories.each do |sub_directory|\n begin\n # Remove the root from the path we pass to the new Content instance.\n # REVIEW: Should we be flexible and allow for the root dir to be present?\n content = Content.new(sub_directory.sub(root_regexp, ''))\n sub_contents.push(content)\n rescue ArgumentError\n next\n end\n end\n end\n\n sub_contents.reverse\n end",
"def all_contents\n yml_filenames = Dir.glob(settings.root + '/contents/*.yml')\n yml_filenames.map { |filename|\n id = filename.match(/\\/contents\\/(.*)\\.yml/)[1]\n content_info(id)\n }\n end",
"def create_contents\n contents = []\n if definition[\"contents\"].blank?\n log_warning \"Could not find any content descriptions for element: #{self.name}\"\n else\n definition[\"contents\"].each do |content_hash|\n contents << Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def create_contents\n contents = []\n if description[\"contents\"].blank?\n log_warning \"Could not find any content descriptions for element: #{self.name}\"\n else\n description[\"contents\"].each do |content_hash|\n contents << Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def localized_contents\n @contents ||= begin\n Content.content_associations.inject([]) do |memo, assoc|\n memo += send(assoc).all_with_localization(:page_localization_id => current_localization.id)\n end\n end\n end",
"def to_a\n @content.collect { |item| assemble(item) }\n end",
"def as_content_array\n as_array[1]\n end",
"def contents\n children.select { |child| child.is_a? DocumentContent }\n end",
"def content_types\n ContentTypes.new(self)\n end",
"def objects\n @objects ||= []\n end",
"def create_contents\n contents = []\n if description[\"contents\"].blank?\n logger.warn \"\\n++++++\\nWARNING! Could not find any content descriptions for element: #{self.name}\\n++++++++\\n\"\n else\n description[\"contents\"].each do |content_hash|\n contents << Alchemy::Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def array\n self.allObjects\n end",
"def contents_from_html\n types_ids = []\n html = introduction + links\n page = Hpricot(html)\n as = page.search('//a')\n as.each do |a|\n href = a.attributes['href']\n ActiveRecord::Acts::Content.model_types.each do |t|\n underscore = t.underscore\n if href =~ /\\/#{underscore.pluralize}\\/(.+)/ # The URL must be in the form /plural/id\n id = $1.to_i\n types_ids << [t, id]\n end\n end\n end\n\n ret = []\n types_ids.uniq!\n types_ids.each do |t, id|\n klass = t.constantize\n content = klass.find_by_id(id)\n ret << content unless content.nil?\n end\n ret\n end",
"def objects\n @objects ||= []\n end",
"def index\n @content_images = ContentImage.all\n end",
"def load_content(post_type)\n content = []\n q = @db.query(\"select distinct *\n from wp_posts as p\n where p.post_type = '#{post_type}' and p.post_status = 'publish'\n order by id desc\")\n\n q.each_hash do |p|\n post = OpenStruct.new(p)\n post.categories = self.post_categories(post.ID).map { |c| @categories[c] }\n post.comments = self.post_comments(post.ID)\n content.push post\n end\n\n return content\n end",
"def content_types\n return @content_types\n end",
"def content\n raise \"content is nil \" unless @list\n return @list\n end",
"def ansible_content\n @ansible_content ||= begin\n require_relative 'plugins/ansible_content'\n flat_map do |engine|\n content_directories(engine, \"ansible\").map { |dir| AnsibleContent.new(dir) }\n end\n end\n end",
"def get_contents_as_blocks(context)\n \n ContentManagerSystem::Content.all(:block => true).map do |content|\n {:name => \"content_#{content.id}\",\n :description => content.title, \n :module_name => :cms, \n :theme => Themes::ThemeManager.instance.selected_theme.name}\n end\n\n end",
"def all\n containers = service.list_containers\n data = []\n containers.each do |container|\n c = parse_storage_object(container)\n c[:acl] = 'unknown'\n data << c\n end\n load(data)\n end",
"def content_types\n type.children.select { |child| child.class == ContentType }\n end",
"def objects\n return @objects unless @objects.nil?\n objs = []\n dict = @instance.getDictionary\n (0 ... dict.getChildCount).each do |i|\n obj = dict.getChildAt(i)\n objs << {\n :name => obj.getName,\n :qual => obj.getQualification.toString.downcase.to_sym,\n :type => obj.getType.toString.downcase.to_sym,\n :object => obj,\n }\n end\n @objects = objs\n end",
"def getObjects\n readObjects\n\n return @Objects\n end",
"def entity_objects\n ProjectMedia.where(id: self.entities).to_a\n end",
"def objects\n @objects ||= begin\n raw_objects = @data['objects'] || []\n raw_objects.map do |object|\n if object.is_a?(Hash)\n # TODO: assumes it has the right keys.\n object\n else\n {\n item: object,\n description: nil\n }\n end\n end\n end\n end",
"def all_contents\n @all_contents ||= Spontaneous::Collections::EntrySet.new(self, entry_store)\n end",
"def content_definitions\n return nil if definition.blank?\n\n definition[\"contents\"]\n end",
"def content\n @content ||= if valid_attrs?(:content_id, :content_type)\n Object.const_get(content_type).find_by_id(content_id)\n end\n end",
"def content_descriptions\n return nil if description.blank?\n description['contents']\n end",
"def localized_contents\n @localized_contents ||= begin\n # First collect the localized content\n contents_data = Gluttonberg::Content.localization_associations.inject([]) do |memo, assoc|\n memo += send(assoc).all\n end\n contents_data = contents_data.sort{|a,b| a.section_position <=> b.section_position}\n end\n @localized_contents\n end",
"def index\n @contents = Content.all\n end",
"def index\n @contents = Content.all\n end",
"def objects\n @objects ||= []\n end",
"def index\n @content_blocks = ContentBlock.all\n end",
"def contentByType( type )\n\t\tcontent = nil\n\t\t@content.each_index { |i|\n\t\t\tif @content[i].type == type\n\t\t\t\tcontent = @content[i]\n\t\t\tend\n\t\t}\n\t\tcontent\n\tend",
"def get_content_objects(as = :models) \n query = \"is_part_of_ssim:#{full_pid}\"\n row_count = ActiveFedora::SolrService.count(query)\n results = ActiveFedora::SolrService.query(query, rows: row_count)\n parse_return_statement(as, results)\n end",
"def items\n @items ||= fetch_items(contents)\n end",
"def content_descriptions\n return nil if definition.blank?\n definition['contents']\n end",
"def getAllContents() # BUG: camel_case.rb\r\n assert_exists\r\n #element.log \"There are #{@o.length} items\"\r\n returnArray = []\r\n @o.each { |thisItem| returnArray << thisItem.text }\r\n return returnArray \r\n end",
"def content_paths\n if @content_paths.nil?\n paths = if filesystem_path.end_with?(\".content.xml\")\n Pathname(filesystem_path).parent.to_s\n elsif sling_initial_content? and filesystem_path.end_with?(\".json\")\n [filesystem_path, filesystem_path.gsub(/.json$/, \"\")].delete_if { |path| !File.exist?(path) }\n else\n filesystem_path\n end\n\n @content_paths = Array(paths)\n end\n\n @content_paths\n end",
"def all_objects; end",
"def get_content\n @list \n end",
"def data_array\n completed_array = []\n slugs.each_with_index do |slug, index|\n completed_array << {slug: slug, content: contents[index]}\n end\n completed_array\n end",
"def content_blocks\n @content_blocks ||= Hash.new {|h,k| h[k] = [] }\n end",
"def getMembersAsArray() \n ret = []\n it = self.getIterator() \n while(it.hasMoreResources())\n ret << it.nextResource().getContentAsREXML()\n end\n \n return ret\n end",
"def contents\n @contents ||= begin\n # First collect the localized content\n contents_data = localized_contents\n contents_data = [] if contents_data.blank?\n # Then grab the content that belongs directly to the page\n contents_data << non_localized_contents\n unless contents_data.blank?\n contents_data = contents_data.flatten.sort{|a,b| a.section_position <=> b.section_position}\n end\n end\n @contents\n end",
"def index\n @specific_contents = SpecificContent.all\n end",
"def get_all(klass = nil, search_params = {})\n replies = get_all_bundles(klass, search_params)\n return nil unless replies\n resources = []\n\t\treplies.each do |reply|\n resources.push(reply.entry.collect{ |singleEntry| singleEntry.resource })\n end\n resources.compact!\n resources.flatten(1)\n\tend",
"def index\n # @contents = Content.all\n end",
"def content(into: nil)\n return parsed_content if into.nil?\n\n if parsed_content.is_a?(Array)\n parsed_content.map { |entry| convert_into(entry, into: into) }\n else\n convert_into(parsed_content, into: into)\n end\n end",
"def index\n @content_urls = ContentUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @content_urls }\n end\n end",
"def has_yaml_content(*args)\n include HasYamlContent::InstanceMethods\n\n #get the already loaded content modules\n content_types = custom_content_types\n args.each do |arg|\n #load content model\n if arg.is_a?(Symbol)\n\n #singularize content model and append to array\n model_name = arg.to_s.singularize.titleize.gsub(\" \",\"\")\n content_types << {:name => model_name, :plural => true}\n\n #try to load the content module if it exists\n load_custom_content_module(arg.to_s)\n\n #add method so that content can be called like base.tips or base.detail\n define_method(arg.to_s) do\n get_content(model_name)\n end\n\n #extra options for a content model such as :plural => false, or :class_name => 'PromotionDetail'\n elsif arg.is_a?(Hash)\n content_types[content_types.size - 1] = content_types.last.merge(arg) #append options to last item in array\n\n #try to load the content module from :class_name\n if arg[:class_name]\n load_custom_content_module(arg[:class_name])\n end\n end\n end\n\n #insert the new content modules\n custom_content_types = content_types\n end",
"def children\n Array.new\n end",
"def all\n Dir.chdir(content_dir) do\n files = Dir.glob(File.join(\"**\", \"*#{SOURCE_FILE_EXT}\")).delete_if {|p| p =~ Regexp.new(\"\\\\.[0-9]+\\\\#{SOURCE_FILE_EXT}$\")}\n files.collect {|f| Page.new(uri_from_path(f), File.open(f, 'r') {|b| b.read})}\n end\n end",
"def index\n @cms_attachments = Cms::Attachment.all\n end",
"def content_blocks\n @content_blocks ||= Hash.new { |h, k| h[k] = [] }\n end",
"def content\n\t\treturn GridCreator.fromArray(self.contents, :horizontal => true)\n\tend",
"def load_objects(dir_name, kind, klass)\n all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext, locales)|\n I18n.locale = I18n.default_locale # Set current locale to default\n\n # Get filenames\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # is binary content?\n is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))\n\n # Read content and metadata\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # Is locale content?\n # - excluded content with locale meta IS a locale content\n # - excluded content without locale meta IS NOT locale content\n # - included content with or without locale meta IS locale content\n # - included content with locale meta set to `false` IS NOT locale\n # content\n is_locale = !!(meta['locale'] || (meta['locale'] != false && locale_content?(content_filename || meta_filename, kind)))\n\n # Create one item by locale, if content don't need a localized version,\n # use default locale\n (is_locale ? I18n.available_locales : [I18n.default_locale]).map do |locale|\n I18n.locale = locale # Set current locale\n\n # Process for localized files\n if is_locale\n # Get filenames for localized content\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # Read content and metadata for localized content\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # merge meta for current locale, default locale meta used by\n # default is meta don't have key\n meta_locale = meta.delete('locale') {|el| Hash.new }\n meta = (meta_locale[I18n.default_locale] || Hash.new).merge(meta)\n meta.merge!(meta_locale[locale.to_s] || Hash.new)\n end\n\n # Get attributes\n attributes = {\n :filename => content_filename,\n :content_filename => content_filename,\n :meta_filename => meta_filename,\n :extension => content_filename ? ext_of(content_filename)[1..-1] : nil,\n :locale => locale,\n # WARNING :file is deprecated; please create a File object manually\n # using the :content_filename or :meta_filename attributes.\n # TODO [in nanoc 4.0] remove me\n :file => content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil\n }.merge(meta)\n\n # Get identifier\n if meta_filename\n identifier = identifier_for_filename(meta_filename[(dir_name.length+1)..-1])\n elsif content_filename\n identifier = identifier_for_filename(content_filename[(dir_name.length+1)..-1])\n else\n raise RuntimeError, \"meta_filename and content_filename are both nil\"\n end\n # Prepend locale code to identifier if content is localized\n identifier = \"/#{locale}#{identifier}\" if is_locale\n\n # Get modification times\n meta_mtime = meta_filename ? File.stat(meta_filename).mtime : nil\n content_mtime = content_filename ? File.stat(content_filename).mtime : nil\n if meta_mtime && content_mtime\n mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime\n elsif meta_mtime\n mtime = meta_mtime\n elsif content_mtime\n mtime = content_mtime\n else\n raise RuntimeError, \"meta_mtime and content_mtime are both nil\"\n end\n\n # Create layout object\n klass.new(\n content_or_filename, attributes, identifier,\n :binary => is_binary, :mtime => mtime\n )\n end\n end.flatten # elements is an array with all locale item, flatten in to one items list\n end",
"def index\n @contents = Content.all\n\n respond_with @contents\n end",
"def get_content(*files)\n content = {}\n files.each do |file|\n content = content.merge YAML.load_file('app/content/' + file)\n end\n content\n end",
"def load_objects\n objects = []\n [@opts[:organization_data], @opts[:ticket_data], @opts[:user_data]]\n .zip(['organization', 'ticket', 'user'])\n .map do |file_paths, object_type|\n file_paths.each do |file_path|\n read_objects = JSON.parse File.read(file_path)\n read_objects.each { |o| o['_type'] = object_type }\n objects.concat read_objects\n end\n end\n return objects\n end",
"def content_blocks\n @content_blocks ||= Hash.new {|h,k| h[k] = [] }\n end",
"def index\n\t\t# All Content tags\n\t\tcontents = ContentTag.all\n\t\trender json: contents\n\tend",
"def content_to_render\n\t\t\tcontent_to_render = []\n\n\t\t\t@wiki_query.pages.each do |key, page|\n\t\t\t\tcontent_to_render << get_content_needed(key, page)\n\t\t\tend\n\n\t\t\tcontent_to_render\n\t\tend",
"def content\n return @content if @content\n matches = class_const(:CONTENT_RE).match(page)\n if matches\n @content = class_const(:KILL_CHARS_RE).gsub(matches[1].to_s, '')\n content_processor\n @content.collect! { |p| decode_entities(p.strip) }\n @content.delete_if { |p| p == '' or p.nil? }\n end\n @content = [] if @content.nil?\n @content\n end",
"def index\n @content_templates = ContentTemplate.all.order(\"title asc\")\n end",
"def content_collection_for(storable)\n contents if CaTissue::Specimen === storable\n end",
"def get_objects\n return self.pageobjects\n end",
"def find_all\n Dir[\"#{pages_dir}**/*.yml\"].map {|f| new f }\n end",
"def instances #:nodoc:\n r = []\n ObjectSpace.each_object(self) { |mod| r << mod }\n r\n end",
"def all_descriptions\n result = []\n @pages.each do |page|\n result << [page.page_url, page.meta_desc_content] if page.page_a_tags\n end\n result\n end",
"def content\n @content ||= content!\n end",
"def objects\n @@objects ||= []\n end",
"def generate_yaml_file_path__content_array(top_file_path)\n self.generate!\n [{ :path => top_file_path, :content => YamlHelper.generate(@yaml_object) }] + generate_nested_dsl_file_path__content_array\n end",
"def content_versions\n return @content_versions\n end",
"def assets\n content_mappings.collect{|mapping| mapping.asset }\n end",
"def content\n raise NotLoadedError.new(:content) unless content_loaded?\n @content\n end",
"def index\n @content_pages = ContentPage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @content_pages }\n end\n end",
"def each_content\n @content.each do |content|\n yield content if content\n end\n end",
"def content_types\n self.class.custom_content_types\n end",
"def all\n load_all! unless @objs_list\n @objs_list.values\n end",
"def serialized_content\n resources = ActiveModel::ArraySerializer.new(Post.published.sorted).as_json | ActiveModel::ArraySerializer.new(Tweet.published.sorted).as_json\n\n resources.sort_by { |i| i[:published_date] }.reverse\n end",
"def content\n @content ||= @deleted ? nil : content_from(@resource)\n end",
"def content_items\n edition.content_items.where(group_id: id)\n end",
"def content_types\n result = call(\"Webs\", \"get_content_types\", \"listName\" => @id)\n result.xpath(\"//sp:ContentType\", NS).map do |content_type|\n supersite && supersite.content_type(content_type[\"ID\"]) || ContentType.new(self, nil, content_type[\"ID\"], content_type[\"Name\"], content_type[\"Description\"], content_type[\"Version\"], content_type[\"Group\"])\n end\n end",
"def all_objects\n Registry.all(:root, :module, :class)\n end",
"def index\n @box_contents = BoxContent.all\n end",
"def get_all_posts(oauth_token)\n result = []\n client = Octokit::Client.new(access_token: oauth_token)\n posts = client.contents(full_repo_name, path: '_posts')\n posts.each do |post|\n oldest_commit = get_oldest_commit_for_file(client, post.path)\n username = client.user[:login]\n if username == oldest_commit[:author][:login]\n post_api_response = client.contents(full_repo_name, path: post.path)\n\n post_model = create_post_from_api_response(post_api_response, nil)\n image_paths = KramdownService.get_all_image_paths(post_model.contents)\n\n images = []\n image_paths.each do | image_path |\n image_content = client.contents(full_repo_name, path: image_path)\n images << create_post_image(image_path, image_content.content)\n end\n\n post_model.images = images\n \n result << post_model\n end\n end\n result\n end",
"def to_a\n [ @content_type, @extensions, @encoding, @system, @obsolete, @docs,\n @url, registered? ]\n end",
"def index\n @content_managers = BigCms::ContentManager.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @content_managers }\n end\n end",
"def non_localized_contents\n @non_localized_contents ||= begin\n # grab the content that belongs directly to the page\n contents_data = Gluttonberg::Content.non_localized_associations.inject([]) do |memo, assoc|\n memo += page.send(assoc).all\n end\n contents_data = contents_data.sort{|a,b| a.section_position <=> b.section_position}\n end\n @non_localized_contents\n end",
"def index\n @contents = Content.find(:all, :limit => 10, :order => \"created_at desc\")\n end",
"def all_objects\n objects = []\n each_namespace{|n| objects << n}\n each_namespace{|n| \n n.each_relvar{|r| objects << r}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_candidate_key{|k| objects << k}}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_foreign_key{|k| objects << k}}\n }\n objects\n end",
"def to_array\n children.each_with_object( [ self ] ) { |child, memo|\n memo.concat( child.to_array )\n }.flatten\n end",
"def content\n @content ||= parts.map(&:body).join(\"\\n\")\n end",
"def index\n @word_content_categories = WordContentCategory.all\n end",
"def containers\n obj = parse_object(1)\n return nil unless obj && obj.m_Container && obj.m_Container.array?\n obj.m_Container.value.map do |e|\n {:name => e.first.value, :preload_index => e.second.preloadIndex.value, :path_id => e.second.asset.m_PathID.value}\n end\n end"
] |
[
"0.7165808",
"0.6887904",
"0.6463056",
"0.640376",
"0.6349051",
"0.6312852",
"0.6306193",
"0.6258356",
"0.625145",
"0.6201269",
"0.62003624",
"0.61289096",
"0.611967",
"0.60478806",
"0.60248977",
"0.6024005",
"0.6021868",
"0.60194016",
"0.6017341",
"0.60012347",
"0.5997141",
"0.59683937",
"0.5965806",
"0.593545",
"0.59330785",
"0.592765",
"0.5860299",
"0.58490115",
"0.5844252",
"0.5840198",
"0.58279175",
"0.5822091",
"0.5816522",
"0.5816286",
"0.5816286",
"0.5803415",
"0.5798356",
"0.57913643",
"0.5777379",
"0.577605",
"0.57696486",
"0.5764414",
"0.5755089",
"0.57497716",
"0.5740579",
"0.5698471",
"0.56885105",
"0.5684551",
"0.5681591",
"0.5675382",
"0.56664824",
"0.56459695",
"0.56442827",
"0.5641141",
"0.56374294",
"0.56373155",
"0.5627018",
"0.5622842",
"0.56199336",
"0.5606036",
"0.56032103",
"0.55918306",
"0.5560569",
"0.5553685",
"0.55506486",
"0.555047",
"0.55457735",
"0.5545144",
"0.5539436",
"0.5536995",
"0.5528707",
"0.55179447",
"0.55169135",
"0.5502167",
"0.55014473",
"0.5494089",
"0.5489687",
"0.54872185",
"0.54795766",
"0.5477813",
"0.5477135",
"0.54741424",
"0.54720163",
"0.54603326",
"0.545946",
"0.5455636",
"0.5451399",
"0.5446214",
"0.5439765",
"0.5436932",
"0.5431081",
"0.5412096",
"0.54068434",
"0.54064935",
"0.5403684",
"0.54032534",
"0.5399853",
"0.53920054",
"0.53904533",
"0.53881973"
] |
0.56774175
|
49
|
Gets the content model class
|
def get_content_model(model_name)
model_hash = content_types.select{|x| x[:name] == model_name}.first
return model_hash[:class_name].nil? ? model_name.constantize : model_hash[:class_name].constantize
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def model_class\n return @model_class || self.class.model_class\n end",
"def class\n @model.class\n end",
"def set_content_model\n @content_model_class_name = self.class.name.gsub(/Controller/,'').singularize.constantize\n end",
"def model_class\n self.class.const_get('MODEL')\n end",
"def model_class\n @model_class ||= controller_path.classify.constantize\n end",
"def model_class\n @model_class ||= mapping.to\n end",
"def model_class\n @model_class ||= derived_model_class_name.constantize\n end",
"def model_type\n self.class.model_type\n end",
"def model\n self.class.model\n end",
"def model\n self.class.model\n end",
"def model_class\n @model_class ||= model_name.camelize.constantize\n end",
"def node_content_class\n raise ArgumentError, \"invalid content_type\" unless ActsAsNode.classes.include? params[:content_type]\n params[:content_type].constantize\n end",
"def model_class\n self.class.models[implementation_model_name]\n end",
"def get_model_class(file); end",
"def content_type\n content_type_class.constantize if content_type_class\n end",
"def node_content_class\n raise ArgumentError, \"invalid content_type\" unless ActsAsNode.classes.include? params[:content_type]\n params[:content_type].constantize\n end",
"def model_class\n @class_name.constantize\n end",
"def model\n return @model\n end",
"def model\n return @model\n end",
"def get_model(model_slug)\n site = get_site\n site.content_types.where(:slug => model_slug).first\n end",
"def model\n return @model\n end",
"def get_model\n return model_classes[item_type].new()\n end",
"def model_class(model_or_controller_name)\n # site settings isn't a model so it isn't defined\n @model_class = model_or_controller_name.singular.camelcase.constantize rescue nil\n end",
"def model_class(model_or_controller_name)\n # site settings isn't a model so it isn't defined\n @model_class = model_or_controller_name.singular.camelcase.constantize rescue nil\n end",
"def concrete_model\n self.class\n end",
"def model\n self.class.const_get(:MODEL)\n end",
"def object_class\n self.class.object_class\n end",
"def class\n @object.class\n end",
"def klass\n (@klass ||= self.mounting_point.content_types[self.class_name]).tap do |klass|\n if klass.nil?\n raise UnknownContentTypeException.new(\"unknow content type #{self.class_name}\")\n end\n end\n end",
"def model_type\n @model_type\n end",
"def model_class\n @controller.model_class\n end",
"def content_type\n if id = self.content_type_id\n @content_type ||= self.site.content_types.find(id) rescue nil\n else\n nil\n end\n end",
"def model_class; end",
"def get_mobj(mname=nil) @model_class.instance; end",
"def class\n object.class\n end",
"def model()\n @props[:model]\n end",
"def view_model_class_for model\n specific_view_model_class_for(model) || default_view_model_class_for(model)\n end",
"def model_class\n class_name.constantize\n end",
"def extract_model_klass(value)\n model_klass = @model_wrapper.call(value)\n\n raise_extract_wrapper_error(model_klass) unless implements_model?(model_klass)\n\n model_klass\n end",
"def get_content_type\n self.content_type\n end",
"def content_type\n ContentType.new(@site, @list, attributes[\"ContentTypeId\"])\n end",
"def model_class\n self.class_name.constantize\n end",
"def klass\n info.klass\n end",
"def current_model\n Object.const_get(params[:model].classify)\n end",
"def get_class()\n l = get_type()\n #puts \"Type #{l.class} in #{self.class} , #{self}\"\n l.object_class()\n end",
"def get_class()\n l = get_type()\n #puts \"Type #{l.class} in #{self.class} , #{self}\"\n l.object_class()\n end",
"def model\n @type.constantize\n end",
"def model\n @type.constantize\n end",
"def getContenttype\r\n\t\t\t\t\treturn @contenttype\r\n\t\t\t\tend",
"def model\n __getobj__\n end",
"def dynamic_model_class_name\n dynamic_model.implementation_class.name\n end",
"def model\n self::Model\n end",
"def model_name\n self.class\n end",
"def klass\n reflection.klass\n end",
"def klass\n reflection.klass\n end",
"def model\n @model\n end",
"def model\n @model\n end",
"def model\n @model\n end",
"def model\n @model\n end",
"def to_model_class\n to_model_name.classify.constantize\n end",
"def obj\n @model\n end",
"def content_type\n @content_type || object.content_type\n end",
"def meta_model\n @work.class.name\n end",
"def klass\n self.class\n end",
"def model\n controller_name.classify.constantize\n end",
"def aspect_target_model\n ContentManagerSystem::Content\n end",
"def klass\n class_name = self[\"_type\"]\n class_name ? class_name.constantize : nil\n end",
"def default_model_name\n @object.class.to_s\n end",
"def model_name\n self.class.model_name\n end",
"def model\n self\n end",
"def klass\n @klass ||= association ? association.klass : model\n end",
"def content\n @content ||= if valid_attrs?(:content_id, :content_type)\n Object.const_get(content_type).find_by_id(content_id)\n end\n end",
"def true_class\n return ModelProxy\n end",
"def model\n if object[inheritance_column]\n object[inheritance_column].constantize\n else\n original_class\n end\n end",
"def model\n\t\tObject.const_get(controller_name.classify)\n\tend",
"def model_name\n self.class\n end",
"def cv_klass\n object.model.class.properties[attribute_name.to_s].class_name\n end",
"def model\n @model ||= Model.new(self)\n end",
"def model\n @_model ||=\n if self.class == Edgarj::EdgarjController\n # dummy model for 'top' action:\n Edgarj::Sssn\n else\n self.class.name.gsub(/Controller$/, '').singularize.constantize\n end\n end",
"def model\n @model ||= resource.model\n end",
"def model\r\n\t\t\t@model ||= json['model']\r\n\t\tend",
"def model\n @model ||= if self.class.path_to_model\n m = eval(self.class.path_to_model)\n if m\n if m.respond_to?(:_controller=)\n m.send(:_controller=, self)\n end\n else\n fail \"No model object found at path: #{self.class.path_to_model}\"\n end\n m\n end\n end",
"def model\n provider.model\n end",
"def entity_class\n self.class.entity_class\n end",
"def klass\n @object.name if (defined? @object.class.name)\n end",
"def model_class\n resource_class = @options[:resource]\n if resource_class.nil?\n @name.to_s.camelize.constantize\n elsif resource_class.kind_of? String\n resource_class.constantize\n else\n resource_class # could be a symbol\n end\n end",
"def parent_model_class\n self.class.parent_model_class\n end",
"def base_class\n S::Model\n end",
"def class_obj\n self.class\n end",
"def class\n @cx.class\n end",
"def model_class_name\n implementation_model_name.ns_camelize\n end",
"def contentmodel(value)\n _contentmodel(value) or fail ArgumentError, \"Unknown value for contentmodel: #{value}\"\n end",
"def class_at_path(path)\n if path\n begin\n # remove the _ and then singularize\n if path.last == :[]\n index = -2\n else\n index = -1\n end\n\n klass_name = path[index].singularize.camelize\n\n klass = $page.model_classes[klass_name] || Model\n rescue NameError => e\n # Ignore exception, just means the model isn't defined\n klass = Model\n end\n else\n klass = Model\n end\n\n return klass\n end",
"def get_content(model_name)\n @_content ||= {}\n\n # return content if it has already been memoized\n return @_content[model_name] unless @_content[model_name].nil?\n\n #get class of content model we are trying to get content for\n model = get_content_model(model_name)\n\n if is_plural?(model_name)\n content = model.find(:all, :path => custom_content_path, :parent => self)\n else\n content = model.find(:first, :path => custom_content_path, :parent => self)\n end\n\n\n # memoize content so we don't parse file again on the same request\n @_content[model_name] = content\n end",
"def model\n parts.first\n end",
"def data_class\n @data_class ||= begin\n klass = \"Netzke::ModelExtensions::#{config[:model]}For#{short_widget_class_name}\".constantize rescue nil\n klass || original_data_class\n end\n end",
"def hook_model_klass\n fail 'child class to return a model klass here'\n end",
"def get_class type\n case type\n when Class\n type\n when BaseModel\n type.my_class\n when String, Symbol\n return get_class send(\"#{type}_model\") if [:subject, :object, :join].include?(type.to_sym)\n type.to_s.constantize\n else\n raise \"Can't determine a class from: #{type}\"\n end \n end",
"def class\n __getobj__.class\n end",
"def content_type_id\n if self.target_klass_name =~ /^Locomotive::ContentEntry([a-z0-9]+)$/\n $1\n else\n nil\n end\n end"
] |
[
"0.7543149",
"0.7474377",
"0.72985125",
"0.72675735",
"0.70565087",
"0.70486283",
"0.69520867",
"0.69487506",
"0.69052047",
"0.69052047",
"0.6850171",
"0.68262625",
"0.68163633",
"0.68129766",
"0.6802389",
"0.6782626",
"0.6760645",
"0.67597884",
"0.67597884",
"0.6722085",
"0.66923237",
"0.6690856",
"0.66633964",
"0.6662698",
"0.6644934",
"0.66169536",
"0.6573566",
"0.65635693",
"0.6562788",
"0.6558671",
"0.6542794",
"0.6535323",
"0.6501918",
"0.64910877",
"0.6488935",
"0.64858574",
"0.6479853",
"0.64693743",
"0.6464394",
"0.64621353",
"0.64483285",
"0.64316976",
"0.6423578",
"0.64152116",
"0.63889843",
"0.63889843",
"0.63871133",
"0.63871133",
"0.637657",
"0.63712764",
"0.6335639",
"0.63163215",
"0.6307932",
"0.62936866",
"0.62936866",
"0.6288319",
"0.6288319",
"0.6288319",
"0.6288319",
"0.62878734",
"0.6272143",
"0.6271142",
"0.6268511",
"0.62585306",
"0.6250255",
"0.6234036",
"0.6204561",
"0.62025917",
"0.6197847",
"0.61950827",
"0.61792743",
"0.61741906",
"0.6165977",
"0.6161846",
"0.61553955",
"0.615355",
"0.615353",
"0.61518705",
"0.6135835",
"0.6130271",
"0.6122939",
"0.61225265",
"0.6114143",
"0.609451",
"0.608615",
"0.6073004",
"0.6068914",
"0.6068245",
"0.60588646",
"0.60428095",
"0.60386103",
"0.6034793",
"0.6029097",
"0.6016209",
"0.6014678",
"0.60099506",
"0.6008924",
"0.60066867",
"0.59997046",
"0.5987609"
] |
0.7724374
|
0
|
Checks to see if the association is plural or singular
|
def is_plural?(model_name)
model_hash = content_types.select{|x| x[:name] == model_name}.first
return model_hash[:plural]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def plural?\n self.class.pluralized || false\n end",
"def plural?\n self.plural_head\n end",
"def plural?\n self == self.pluralize\n end",
"def plural?\n !@msgid_plural.nil?\n end",
"def plural?\n @msgid_plural != nil\n end",
"def uncountable?\n singular_table_name == plural_table_name\n end",
"def singular?\n self == self.singularize\n end",
"def is_plural?(astring)\n astring.singularize != astring\nend",
"def plural?(is_plural,term)\n singular_plural = term.split('/')\n if singular_plural.size == 1\n singular_plural << \"#{singular_plural[0]}s\"\n end\n singular_plural[is_plural ? 1 : 0]\n end",
"def singular?(plural)\n if plural =~ /s$/\n if plural =~ /ies$/\n plural.gsub(/ies$/, 'y')\n else\n plural.gsub(/s$/, '')\n end\n else\n plural #input not plural\n end\n end",
"def plural?(word)\n word[-1] == 'S' && word[-2] != 'S'\n end",
"def is_plural?(value)\n\t(value > 1) || (value < 1)\nend",
"def is_plural(word)\n\treturn word[-1] === 's' ? true : false\nend",
"def singulars\n @singulars\n end",
"def singular_resource?\n @resource_arity.to_s == 'singular'\n end",
"def plural?(word)\n word = require_string!(word)\n\n word == pluralize(word)\n end",
"def pluralize\n p = self[ :plural ]\n p = ! scalar? if p.nil?\n p = 's' if p == false\n p = 'p' if p == true\n p.to_s\n end",
"def name_plural() name_singular + 's' end",
"def plural\n return word if word.to_s.empty?\n\n find_match(Inflection.configuration.plurals[:noun]) ||\n (uncountable? && word) || find_match(Nouns.plurals) || word\n end",
"def can_create_pluralized_model_for?(klass)\n !klass.to_s.match(/^\\#/)\n end",
"def pluralize_collection collection, noun \n if collection.size == 1 \n \"1 #{noun}\"\n else \n \"#{collection.size} #{noun.pluralize}\"\n end\n end",
"def test_plural_ruby\n\t\tp = Print.new\n\t\tassert_equal('rubies',p.singular_or_plural(0,'rubies'))\n\tend",
"def singular?\n not regular?\n end",
"def plural_association_name(foreign_key)\n pluralize singular_association_name(foreign_key)\n end",
"def pluralize_word(singular)\n singular.respond_to?(:pluralize) ? singular.pluralize : singular + 's'\n end",
"def simple?\n\t\tself.class.name.demodulize.tableize.singularize == \"simple\"\n\tend",
"def resource_plural_name\n @association_name ||= self.class.resource_class.name.tableize\n end",
"def default_pluralizer(count)\n count == 1 ? :one : :other\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count} \" + if count == 1\n singular\n elsif plural\n plural\n elsif Object.const_defined?(\"Inflector\")\n Inflector.pluralize(singular)\n else\n singular + \"s\"\n end\n end",
"def plural_object_name\n singular_object_name.pluralize\n end",
"def plural_target\n @plural_target ||= target.presence && target.to_s.underscore.pluralize\n end",
"def valid_association_for_combining?(name)\n\t\t\treflections[name].macro.in? [:has_and_belongs_to_many, :has_many]\n\t\tend",
"def regular_o_declension?\n @inflection_class == 1 && @nom.to_s =~ /us$/ # to_s because it might be nil\n end",
"def pluralize(count = nil)\n if count == 1\n self\n else\n MotionSupport::Inflector.pluralize(self)\n end\n end",
"def singularize\n ActiveSupport::Inflector.singularize(self)\n end",
"def pluralize\n @name.pluralize\n end",
"def singularize\n @name.pluralize.singularize\n end",
"def is_disambiguation_page?(p)\n\t\tlogger.debug \"is disambiguation page?\"\n\t\tbelongs_to_categories? p, [\n\t\t\t\"Category:All article disambiguation pages\",\n\t\t\t\"Category:All disambiguation pages\",\n\t\t\t\"Category:Disambiguation pages\",\n\t\t\t\"Kategori:Förgreningssidor\"\n\t\t]\n\tend",
"def is_many?\n case @reflection.macro\n when :has_many, :has_and_belongs_to_many\n true\n else\n @parent ? @parent.is_many? : false\n end\n end",
"def has_many?\n @macro == :belongs_to\n end",
"def test_plural_fake_ruby\n\t\tp = Print.new\n\t\tassert_equal('fake rubies',p.singular_or_plural(0,'fake'))\n\tend",
"def declension(singular, plural, count)\n count == 1 ? singular : plural\n end",
"def singularize\n MotionSupport::Inflector.singularize(self)\n end",
"def assertPlural( singular, plural, altplural, comment )\n\t\trval, pl_noun, pl_verb, pl, pl_val, altpl_val = [nil] * 6\n\n\t\tisNv = false\n\t\tcase comment\n\t\twhen /verb/i\n\t\t\tisNv = 'verb'\n\t\twhen /noun/i\n\t\t\tisNv = 'noun'\n\t\tend\n\n\t\top = \"Pluralizing '#{singular}': \"\n\t\tassert_nothing_raised( op + \"plural verb\" ) {\n\t\t\tpl_verb = singular.en.plural_verb\n\t\t}\n\t\tassert_nothing_raised( op + \"plural noun\" ) {\n\t\t\tpl_noun = singular.en.plural_noun\n\t\t}\n\t\tassert_nothing_raised( op + \"plural\" ) {\n\t\t\tpl = singular.en.plural\n\t\t}\n\n\t\tif !altplural.nil? && !altplural.empty?\n\t\t\tbegin\n\t\t\t\tassert_nothing_raised( op + \"classical\" ) {\n\t\t\t\t\tLinguistics::classical = true\n\t\t\t\t\taltpl_val = singular.en.plural\n\t\t\t\t}\n\t\t\tensure\n\t\t\t\tLinguistics::classical = false\n\t\t\tend\n\t\tend\n\n\t\tpl_val = isNv ? (isNv == \"noun\" ? pl_noun : pl_verb) : pl\n\n\t\tassert_equal plural, pl_val, \"Plural of '#{singular}'\"\n\t\tassert_equal altplural, altpl_val,\n\t\t\t\"Classical plural of '#{singular}'\" unless\n\t\t\taltplural.nil? or altplural.empty?\n\tend",
"def singular\n return word if word.to_s.empty?\n\n find_match(Inflection.configuration.singulars[:noun]) ||\n (uncountable? && word) || find_match(Nouns.singulars) || word\n end",
"def verify_model?(klass)\n collection_name = URI.parse(id).host.chomp(\".collection\")\n\n return klass.collection_name.to_s == collection_name if klass.respond_to?(:collection_name)\n\n klass.name == ActiveSupport::Inflector.classify(collection_name)\n end",
"def singularize(locale = :en)\n ActiveSupport::Inflector.singularize(self, locale)\n end",
"def is_association?(model_name, association_name)\n associations = @associations[model_name]\n !!(associations && associations[association_name])\n end",
"def multiple? #nodoc\n @options[:association] == :has_many || @options[:association] == :has_and_belongs\n end",
"def singularity\n @singularity ||= (strategy =~ /_many$/) ? :many : :one\n end",
"def preconditions\n %i[\n has_one\n has_many\n ].include?(association.macro) && association.through_reflection.nil? && association.klass\n rescue NameError\n false\n end",
"def has_many_through_translatable?\n options[:through] && through_reflection.klass.is_translatable?\n end",
"def pluralize\n self[-1] == 's' ? \"#{self}es\" : \"#{self}s\"\n end",
"def friendly_name_pluralized\n @friendly_name_pluralized ||= self.name.humanize.pluralize\n end",
"def simple_pluralize count, singular, plural=nil\n ((count == 1 || count =~ /^1(\\.0+)?$/) ? singular : (plural || singular.pluralize))\n end",
"def plural?(word, term: :noun)\n case term.to_sym\n when :noun, :n\n Noun[word].plural?\n when :verb, :v\n Verb[word].plural?\n else\n raise Error, \"Unknown option '#{term}' as a term\"\n end\n end",
"def is_relationship?\n %w(belongs_to has_many many_to_many).include?(self.type.to_s)\n end",
"def pluralize\n self.class.new Inflector.pluralize(self)\n end",
"def pluralize\n self.class.new Inflector.pluralize(self)\n end",
"def pluralize_word(count, singular, plural = nil)\n ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def preconditions\n %i[\n has_one\n has_many\n ].include?(association.macro) && association.through_reflection.nil? && association.klass\n rescue StandardError\n false\n end",
"def is_association?(model_name, association_name)\n associations = @associations[model_name]\n associations && associations[association_name]\n end",
"def flexi_label(singular = false)\n if singular\n self._flexi_collection.singular_label\n else\n self._flexi_collection.plural_label\n end\n end",
"def singular_rule(singular, plural)\n @singular_rules << [singular, plural]\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def test_plural_int2\n assert_equal @p.plural?(2), 'rubies'\n end",
"def simple?\n empty? or singular?\n end",
"def resource_plural() self.class.read_inheritable_attribute(:resource_plural) end",
"def plural(n)\n n != 1\nend",
"def pluralize(word)\n return word + \"s\" if pluralize?\n word\nend",
"def localized?\n self.locales.size > 1\n end",
"def collection_name\n singular == plural ? \"#{plural}_index\" : plural\n end",
"def collection_name\n singular == plural ? \"#{plural}_index\" : plural\n end",
"def is_many?\n associations.values.flatten.any? { |assoc| assoc.is_many? }\n end",
"def multiple_associations?\n associations.any? { |col,assocs| assocs.length > 1 }\n end",
"def version_association?(association)\n association.to_s.end_with? 'versions'\n end",
"def plural_instance_name\n info.plural_name\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + (count == 1 ? singular : (plural || singular.pluralize))\n end",
"def singular?(word, term: :noun)\n case term.to_sym\n when :noun, :n\n Noun[word].singular?\n when :verb, :v\n Verb[word].singular?\n else\n raise Error, \"Unknown option '#{term}' as a term\"\n end\n end",
"def pluralize( name )\n warn_nyi( \"support for pluralization guides in pluralize()\" )\n return name.pluralize\n end",
"def _plural_name\n @plural_name || begin\n @plural_name = Origen::Componentable.componentable_names(self)[:plural]\n @singleton_name = Origen::Componentable.componentable_names(self)[:singleton]\n end\n end",
"def plural?(num)\n return 'ruby' if num == 1\n return 'rubies' if num > 1\n end",
"def test_pluralize_one\n assert_equal \"book\", @d.pluralize(\"book\", 1)\n end",
"def versioned_association?(association)\n versioned_associations.include?(association.to_sym)\n end",
"def pluralize_with_count( count=2 )\n count > 1 ? pluralize_without_count : singularize\n end",
"def plural?(method)\n str = method.to_s\n plr = str.to_sym\n sgl = str.sub(/e?s$/, '').to_sym\n\n /s$/ === str && Watirsome.watir_methods.include?(plr) && Watirsome.watir_methods.include?(sgl)\n end",
"def assign_singular?\n !returns_array?\n end",
"def pluralize amount, singular\n \"#{amount} #{singular}#{amount == 1 ? '' : 's'}\"\n end",
"def declension(singular, plural, count)\n if count == 1\n singular\n else\n plural\n end\n end",
"def has_associations?\n (!self.pulves.empty? ||\n !self.labours.empty? || \n !self.factures.empty? || \n !self.ventes.empty?)\n end",
"def associated?\n @associated\n end",
"def scaffold_associated_human_name(association)\n association.to_s.humanize\n end",
"def rest_parent_label_plural\n defined?(@rest_parent_label_plural) ? @rest_parent_label_plural : default_rest_parent_label_plural\n end",
"def title_plural\n self.title.pluralize\n end",
"def actuale? opt = \"\"\n relation = opt.to_s.tableize\n\n actuale = false\n model.dependent_relations.each do |dependent_relation|\n tmp = self.send dependent_relation\n if relation == dependent_relation\n actuale ||= tmp.all.size > 1\n else\n actuale ||= tmp.exists?\n end\n end\n actuale\n end",
"def singular?\n size == 1 && first[1] == 1\n end",
"def hash_is_for_pluralization?(hash, locale)\n plural_keys = I18n.t('i18n.plural.keys', locale: locale)\n raise missing_pluralisations_message(locale) unless plural_keys.is_a?(Array)\n ((hash.keys.map(&:to_s) - plural_keys.map(&:to_s)) - ['zero']).empty?\n end",
"def singularize(str)\n Gorillib::Inflector.pluralizations.invert.fetch(str){ str.gsub(/s$/, '') }\n end",
"def present_participle\n plural = self.obj.to_s.en.plural_verb\n\n\t\tplural.sub!( /ie$/, 'y' ) or\n\t\t\tplural.sub!( /ue$/, 'u' ) or\n\t\t\tplural.sub!( /([auy])e$/, '$1' ) or\n\t\t\tplural.sub!( /i$/, '' ) or\n\t\t\tplural.sub!( /([^e])e$/, \"\\\\1\" ) or\n\t\t\t/er$/.match( plural ) or\n\t\t\tplural.sub!( /([^aeiou][aeiouy]([bdgmnprst]))$/, \"\\\\1\\\\2\" )\n\n return \"#{plural}ing\"\n\tend"
] |
[
"0.77525496",
"0.74685425",
"0.7435193",
"0.7232097",
"0.72101504",
"0.7073882",
"0.70722836",
"0.6970622",
"0.6837027",
"0.657962",
"0.65337664",
"0.64684737",
"0.6419915",
"0.63317204",
"0.629669",
"0.62274164",
"0.6205158",
"0.61565197",
"0.6146051",
"0.61436284",
"0.6113504",
"0.60972434",
"0.60874456",
"0.6079375",
"0.6074605",
"0.60628617",
"0.6062785",
"0.6059452",
"0.6034853",
"0.6007862",
"0.5943308",
"0.59341735",
"0.5907719",
"0.58355004",
"0.5823754",
"0.5810871",
"0.58101064",
"0.58094025",
"0.578624",
"0.57832646",
"0.5778369",
"0.57776195",
"0.5767848",
"0.57636636",
"0.57577175",
"0.57454926",
"0.57424396",
"0.5734779",
"0.57322955",
"0.57282495",
"0.57126534",
"0.5692637",
"0.56870323",
"0.56754684",
"0.5674478",
"0.567048",
"0.56594455",
"0.56513256",
"0.56513256",
"0.564726",
"0.5646161",
"0.56292206",
"0.5608274",
"0.5603239",
"0.5582964",
"0.5582964",
"0.5565119",
"0.55471224",
"0.55417943",
"0.55275714",
"0.55231494",
"0.55226636",
"0.5519227",
"0.5519227",
"0.5514124",
"0.5512449",
"0.5498468",
"0.54924226",
"0.5491421",
"0.54861146",
"0.54858845",
"0.54575473",
"0.5445065",
"0.5444833",
"0.54301643",
"0.5422895",
"0.5422178",
"0.54213196",
"0.54112434",
"0.5410747",
"0.5409461",
"0.54016525",
"0.5397715",
"0.5396152",
"0.5390335",
"0.53796387",
"0.5376683",
"0.5372145",
"0.53706175",
"0.53690326"
] |
0.66041344
|
9
|
Converts an object of this instance into a database friendly value.
|
def mongoize
return if values.blank?
values.map { |value| value.mongoize }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def convert_to_dynamo_value(object_value); object_value; end",
"def cast_value\n value.mongoize\n end",
"def convert_to_object_value(dynamo_value); dynamo_value; end",
"def to_mongo_value\n h = {}\n self.class.column_names.each {|iv|\n val = read_attribute(iv)\n h[iv] = val == nil ? nil : val.to_mongo_value\n }\n h\n end",
"def from_database_type(obj)\n case obj\n when String, Float, Integer, NilClass, TrueClass, FalseClass\n obj\n when java.sql.Date, java.sql.Time, java.sql.Timestamp\n Time.at(obj.time/1000)\n when java.sql.Blob\n String.from_java_bytes(obj.get_bytes(1,obj.length))\n when java.sql.Clob\n obj.get_sub_string(1, obj.length)\n when java.math.BigDecimal\n BigDecimal.new(obj.to_s)\n else\n raise \"Can't find correct type to convert #{obj.inspect} into\"\n end\n end",
"def single_object_db=(v); end",
"def mongoize(object)\n case object\n when Money then object.mongoize\n when Hash then Money.new(object[:cents].to_i, object[:currency]).mongoize\n else object\n end\n end",
"def mongoize(object)\n case object\n when nil then nil\n when QDM::Code then object.mongoize\n when Hash\n object = object.symbolize_keys\n QDM::Code.new(object[:code], object[:system], object[:display], object[:version]).mongoize\n else object\n end\n end",
"def mongoize(object)\n case object\n when Quantity\n object.mongoize\n when Numeric\n self.new(object).mongoize\n else\n object\n end\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n else\n object\n end\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n else\n object\n end\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n else\n object\n end\n end",
"def mongoize\n @@value_map[value]\n end",
"def convert\n self.class.convert(object)\n end",
"def mongoize(object)\n object.mongoize\n end",
"def mongoize\n ::Hash.mongoize(self)\n end",
"def demongoize(object)\n object\n end",
"def value\n self.send :\"#{_mapped_value_column}\"\n end",
"def convert_to_attribute( oid, object )\n\t\treturn object.to_s unless conversion = @object_conversions[ oid ]\n\n\t\tif conversion.respond_to?( :call )\n\t\t\treturn conversion.call( object, self )\n\t\telse\n\t\t\treturn conversion[ object ]\n\t\tend\n\tend",
"def to_model\n __getobj__\n end",
"def mongoize(object)\n return if object.blank?\n if Mongoid.map_big_decimal_to_decimal128\n if object.is_a?(BSON::Decimal128)\n object\n elsif object.is_a?(BigDecimal)\n BSON::Decimal128.new(object)\n elsif object.numeric?\n BSON::Decimal128.new(object.to_s)\n elsif !object.is_a?(String)\n object.try(:to_d)\n end\n else\n if object.is_a?(BSON::Decimal128) || object.numeric?\n object.to_s\n elsif !object.is_a?(String)\n object.try(:to_d)&.to_s\n end\n end\n end",
"def mongoize(object)\n case object\n when Point then object.mongoize\n when Hash then Point.new(object[:x], object[:y]).mongoize\n else object\n end\n end",
"def mongoize(object)\n if type.resizable? || object_id_field?\n type.__mongoize_fk__(association, object)\n else\n related_id_field.mongoize(object)\n end\n end",
"def mu_pp(obj)\n if obj.is_a?(ActiveRecord::Base)\n obj.to_s\n else\n super\n end\n end",
"def object_value_from_dynamo_data(dynamo_record)\n dynamo_record[dynamo_attribute_key]\n end",
"def mongoize(object)\n case object\n when Point\n object.mongoize\n when Array, Hash\n new(object).mongoize\n else\n object\n end\n end",
"def mongo_value\n value\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n when Hash\n demongoize(object).mongoize\n else\n object\n end\n end",
"def serialize_value\n # Returning nil will prevent the row from being saved, to save some time since the EavHash that manages this\n # entry will have marked it for deletion.\n raise \"Tried to save with a nil value!\" if @value.nil? or @value.is_a? NilPlaceholder\n\n update_value_type\n if value_type == SUPPORTED_TYPES[:Object]\n write_attribute :value, YAML::dump(@value)\n else\n write_attribute :value, @value.to_s\n end\n\n read_attribute :value\n end",
"def mongoize\n ::BigDecimal.mongoize(self)\n end",
"def object_value(dynamo_data)\n dynamo_data[dynamo_attribute_key].send dynamo_attribute_value_type_key\n end",
"def mongoize(object)\n case object\n when Expert then object.mongoize\n when Hash then Expert.new(object[:name], object[:quote], object[:image_url]).mongoize\n else object\n end\n end",
"def mongoize(object)\n #EncryptedFields.logger.debug \"#{name}##{__method__.to_s}: #{object.inspect}\"\n case\n when object.is_a?(self.class)\n object.mongoize\n when object.blank? || is_encrypted?(object)\n object\n else\n convert(object).mongoize\n end\n end",
"def mongoize(object)\n case object\n when self then object.mongoize\n when Symbol then new(object).mongoize\n else object\n end\n end",
"def raw_value(obj)\n GraphQL::Execution::Interpreter::RawValue.new(obj)\n end",
"def to_bson\n to_h.to_bson\n end",
"def to_object_id(value)\n Plucky.to_object_id(value)\n end",
"def sql_literal(object)\n object.literal(to_s)\n end",
"def record_to_object(record)\n record\n end",
"def convert(object); end",
"def convert(value) \n return value.to_formatted_s(:db) if value.respond_to?(:to_formatted_s)\n value.to_s\n end",
"def mongoize(object_id)\n object_id\n end",
"def mongoize(object_id)\n object_id\n end",
"def mongoize(object)\n case\n when object.is_a?(Money) then object.mongoize(object)\n when object.is_a?(Hash) then\n object.symbolize_keys! if object.respond_to?(:symbolize_keys!)\n value = ::Money.new(object[:cents], object[:currency_iso] || Money.default_currency.iso_code)\n value.mongoize(object)\n when object.respond_to?(:to_money) then\n return if object.is_a?(String) && object.blank?\n object.to_money.mongoize(object)\n else object\n end\n end",
"def cast_value(value)\n case value\n when String then decode_and_initialize(value)\n when Hash then extract_model_klass(value).new(value)\n when nil then value\n else\n raise_cast_error(value) unless value.class.ancestors.include?(StoreModel::Model)\n\n value\n end\n rescue ActiveModel::UnknownAttributeError => e\n handle_unknown_attribute(value, e)\n end",
"def primary_key_value(obj)\n obj.pk\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n when Array\n demongoize(object).mongoize\n else\n object\n end\n end",
"def value\n @base_object\n end",
"def value\n @base_object\n end",
"def get_value(object)\n case value_type\n when 'integer' then object.value_integer\n when 'float' then object.value_float\n when 'string' then object.value_string\n else raise_invalid_type\n end\n end",
"def demongoize(object)\n new(value_of(object))\n end",
"def to_database\n {\n type: self.class.name,\n params: params,\n # account: Current.account,\n }\n\n end",
"def value\n to_s\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def mongoize(object)\n case object\n when RussianPhone::Number then object.mongoize\n when String then RussianPhone::Number.new(object, @options).mongoize\n else object\n end\n end",
"def execute(obj)\n return convert(obj) if check(obj)\n return obj\n end",
"def save\n table_name = self.class.to_s.tableize\n variables = self.instance_variables\n attr_hash = {}\n \n variables.each do |var|\n attr_hash[\"#{var.slice(1..-1)}\"] = self.send(\"#{var.slice(1..-1)}\")\n end\n \n single_variables = []\n \n attr_hash.each do |k, v|\n if v.is_a?(String)\n single_variables << \"#{k} = '#{v}'\"\n else\n single_variables << \"#{k} = #{v}\"\n end\n end\n \n vars_to_sql = single_variables.join(\", \")\n \n CONNECTION.execute(\"UPDATE #{table_name} SET #{vars_to_sql} WHERE id = #{self.id}\")\n \n return self\n end",
"def to_s\n object.to_s\n end",
"def to_bson\n NO_VALUE\n end",
"def value\n _, _, type = @table.lookup_schema(cq)\n Util.from_bytes(type, raw)\n end",
"def value_for(value)\n return value.to_s(:db) if value.kind_of?(Time) \n return value.to_s(:db) if value.kind_of?(Date)\n return value.to_s\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def value(record)\n if self.association\n if self.association.macro == :one && dbi.klass.respond_to?(:human_attribute_name)\n dbi.klass.human_attribute_name(association.name)\n # dbi.record(record.send(association.name)).title\n elsif dbi.klass.respond_to?(:human_attribute_name)\n \"#{dbi.klass.human_attribute_name(association.name)} (#{record.send(association.name).count})\"\n else\n \"#{association.name} (#{record.send(association.name).count})\"\n end\n else\n record.send(self.name)\n end\n end",
"def to_s\n @object.to_s\n end",
"def value\n @casted_value ||= type_cast_value(@value)\n end",
"def mongoize(object)\n case object\n when TimeOfDay then object.mongoize\n else object\n end\n end",
"def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def mongoize\n self\n end",
"def single_object_db; end",
"def mongoize(object)\n case object\n when Interval then object.mongoize\n when Hash then Interval.new(object).mongoize\n else object\n end\n end",
"def value\n record.send(name).value\n end",
"def retrieve_value(obj, i)\r\n case obj.get_meta_data.get_column_type_name(i)\r\n when 'NUMBER'\r\n retrieve_number(obj, i)\r\n when 'INTEGER'\r\n retrieve_int(obj, i)\r\n when 'DATE'\r\n retrieve_time(obj, i)\r\n when 'TIMESTAMP'\r\n retrieve_time(obj, i)\r\n when 'CHAR', 'VARCHAR2', 'CLOB'\r\n retrieve_string(obj, i)\r\n when 'RAW'\r\n retrieve_raw(obj, i)\r\n else\r\n # If it is not one of the built-in tyes, it could be a user defined type\r\n # returning either an array or record type.\r\n type_code = obj.get_meta_data.get_column_type(i)\r\n if Java::JavaSql::Types::ARRAY == type_code\r\n @array ||= Array.new\r\n @array[i] ||= OraArray.new(obj.get_meta_data.get_column_type_name(i), nil)\r\n @array[i].retrieve_out_value(@connection, obj, i)\r\n elsif Java::JavaSql::Types::STRUCT == type_code\r\n @array ||= Array.new\r\n @array[i] ||= OraRecord.new(obj.get_meta_data.get_column_type_name(i), nil)\r\n @array[i].retrieve_out_value(@connection, obj, i)\r\n else\r\n raise UnknownSQLType, obj.get_meta_data.get_column_type_name(i)\r\n end\r\n end\r\n end",
"def to_sql\n self.to_datetime.to_sql\n \tend",
"def serialized\n @value\n end",
"def value\n\t\t# This bizarre construct is done in order to not be reliant\n\t\t# on the inherent assignment-order when using Property.new({...})\n\t\t# since that hash can be ordered anywhich way .daniel\n\t\tif value_id\n\t\t\tvalue_object.value\n\t\telse\t\t\t\n\t\t\t@value\n\t\tend\n\tend",
"def value\n to_type(@value)\n end",
"def field_value(field)\n @object.respond_to?(field) ? @object.send(field) : ''\n end",
"def to_d\n @object.respond_to?(:to_d) ? @object.to_d : BigDecimal(@object.to_s)\n end",
"def to_d\n @object.respond_to?(:to_d) ? @object.to_d : BigDecimal(@object.to_s)\n end",
"def convert_attribute_value obj\n case obj\n when OpenCensus::Trace::TruncatableString\n TraceProtos::AttributeValue.new \\\n string_value: convert_truncatable_string(obj)\n when Integer\n TraceProtos::AttributeValue.new int_value: obj\n when true, false\n TraceProtos::AttributeValue.new bool_value: obj\n end\n end",
"def save\n table = self.class.to_s.pluralize.underscore\n\n instance_variables = self.instance_variables\n\n attribute_hash = {}\n\n instance_variables.each do |variable|\n attribute_hash[\"#{variable.slice(1..-1)}\"] = self.send(\"#{variable.slice(1..-1)}\")\n end\n\n individual_instance_variables = []\n\n attribute_hash.each do |key, value|\n if value.is_a?(String)\n individual_instance_variables << \"#{key} = '#{value}'\"\n else\n individual_instance_variables << \"#{key} = #{value}\"\n end\n end\n\n for_sql = individual_instance_variables.join(', ')\n DATABASE.execute(\"UPDATE #{table} SET #{for_sql} WHERE id = #{self.id}\")\n\n return self\n end",
"def serialize(object)\n object.to_s\n end",
"def id\n object.id.to_s\n end",
"def coerce(object)\n self.class.coerce(object)\n end",
"def __object\n __value\n end",
"def mongoize(object)\n { ::I18n.locale.to_s => type.mongoize(object) }\n end",
"def __mongoize_object_id__\n map!(&:__mongoize_object_id__).compact!\n self\n end",
"def save\n table_name = self.class.to_s.pluralize.underscore\n \n instance_variables = self.instance_variables\n \n attribute_hash = {}\n \n instance_variables.each do |variable|\n attribute_hash[\"#{variable.slice(1..-1)}\"] = self.send(\"#{variable.slice(1..-1)}\")\n end\n \n individual_instance_variables = []\n \n attribute_hash.each do |key, value|\n if value.is_a?(String)\n individual_instance_variables << \"#{key} = '#{value}'\"\n else\n individual_instance_variables << \"#{key} = #{value}\"\n end\n end\n \n for_sql = individual_instance_variables.join(', ')\n DATABASE.execute(\"UPDATE #{table_name} SET #{for_sql} WHERE id = #{id}\")\n \n return self\n end",
"def save(object)\n db_id = derive_db_id(object.class.name, object.id)\n db.transaction do\n db[db_id] = object\n end\n end",
"def serialize_default(object)\n mongoize(object)\n end",
"def queryAndConvert() \n\t\tres = self.query()\n\t\treturn res.convert()\n end",
"def raw_value\n to_s\n end",
"def to_bson_key\n value\n end",
"def serialize(object)\n if object.is_a?(::String)\n BSON::ObjectId.from_string(object) unless object.blank?\n else\n object\n end\n end",
"def to_bson\n end"
] |
[
"0.6693649",
"0.66611433",
"0.6586885",
"0.6584254",
"0.6357532",
"0.62361926",
"0.6231476",
"0.6201285",
"0.61927533",
"0.61496985",
"0.61056703",
"0.61056703",
"0.6097344",
"0.609666",
"0.608981",
"0.6082601",
"0.6079731",
"0.6045964",
"0.6021976",
"0.6007313",
"0.598294",
"0.59645253",
"0.5952961",
"0.5946529",
"0.59239274",
"0.5916294",
"0.5885547",
"0.58848625",
"0.58774245",
"0.58755267",
"0.58740526",
"0.58739173",
"0.5859244",
"0.58574617",
"0.58470386",
"0.58396614",
"0.5837642",
"0.5836862",
"0.5831732",
"0.58267486",
"0.58209443",
"0.580312",
"0.580312",
"0.57854563",
"0.5785288",
"0.57390994",
"0.569994",
"0.56952715",
"0.56952715",
"0.569436",
"0.56873083",
"0.5677675",
"0.56716645",
"0.5664638",
"0.5664638",
"0.56529087",
"0.5650867",
"0.563783",
"0.5631533",
"0.562753",
"0.56160885",
"0.56016785",
"0.5583372",
"0.5583372",
"0.5583372",
"0.5583372",
"0.5577108",
"0.5572878",
"0.5565826",
"0.5563649",
"0.5562645",
"0.554121",
"0.554121",
"0.5536579",
"0.5536416",
"0.5535947",
"0.55344886",
"0.5504335",
"0.5501072",
"0.54827935",
"0.5482638",
"0.5470947",
"0.54640317",
"0.5462905",
"0.5462905",
"0.54518944",
"0.5426575",
"0.542537",
"0.54174566",
"0.5416861",
"0.5414225",
"0.5410709",
"0.54061234",
"0.53995514",
"0.5398294",
"0.5390113",
"0.5365954",
"0.5359344",
"0.5357093",
"0.53564423",
"0.53535116"
] |
0.0
|
-1
|
Takes any possible object and converts it to how it would be stored in the database.
|
def mongoize(object)
return nil if object.nil?
case object
when self
object.mongoize
when Array
demongoize(object).mongoize
else
object
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def convert(object); end",
"def convert\n self.class.convert(object)\n end",
"def convert\n return unless should_convert?\n\n object_magic = MagicObjects.get_magic(object)\n {\n _magic: object_magic\n }\n end",
"def demongoize(object)\n object\n end",
"def convert(obj)\n if c = @converter\n c.call(obj)\n else\n obj\n end\n end",
"def mongoize(object)\n case object\n when Point then object.mongoize\n when Hash then Point.new(object[:x], object[:y]).mongoize\n else object\n end\n end",
"def convert(obj)\n ret = convert_proc.call(obj)\n filters.execute(ret)\n end",
"def mongoize(object)\n case object\n when Point\n object.mongoize\n when Array, Hash\n new(object).mongoize\n else\n object\n end\n end",
"def mongoize(object)\n case object\n when Money then object.mongoize\n when Hash then Money.new(object[:cents].to_i, object[:currency]).mongoize\n else object\n end\n end",
"def from_database_type(obj)\n case obj\n when String, Float, Integer, NilClass, TrueClass, FalseClass\n obj\n when java.sql.Date, java.sql.Time, java.sql.Timestamp\n Time.at(obj.time/1000)\n when java.sql.Blob\n String.from_java_bytes(obj.get_bytes(1,obj.length))\n when java.sql.Clob\n obj.get_sub_string(1, obj.length)\n when java.math.BigDecimal\n BigDecimal.new(obj.to_s)\n else\n raise \"Can't find correct type to convert #{obj.inspect} into\"\n end\n end",
"def execute(obj)\n return convert(obj) if check(obj)\n return obj\n end",
"def coerce(object)\n self.class.coerce(object)\n end",
"def mongoize(object)\n case object\n when Expert then object.mongoize\n when Hash then Expert.new(object[:name], object[:quote], object[:image_url]).mongoize\n else object\n end\n end",
"def demongoize(object)\n new(value_of(object))\n end",
"def mongoize(object)\n return if object.blank?\n if Mongoid.map_big_decimal_to_decimal128\n if object.is_a?(BSON::Decimal128)\n object\n elsif object.is_a?(BigDecimal)\n BSON::Decimal128.new(object)\n elsif object.numeric?\n BSON::Decimal128.new(object.to_s)\n elsif !object.is_a?(String)\n object.try(:to_d)\n end\n else\n if object.is_a?(BSON::Decimal128) || object.numeric?\n object.to_s\n elsif !object.is_a?(String)\n object.try(:to_d)&.to_s\n end\n end\n end",
"def convert(serialized_object, target_type)\n converter = converter serialized_object.content_type, target_type\n converter.convert serialized_object\n end",
"def mongoize(object)\n #EncryptedFields.logger.debug \"#{name}##{__method__.to_s}: #{object.inspect}\"\n case\n when object.is_a?(self.class)\n object.mongoize\n when object.blank? || is_encrypted?(object)\n object\n else\n convert(object).mongoize\n end\n end",
"def convert\n end",
"def convert\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n when Hash\n demongoize(object).mongoize\n else\n object\n end\n end",
"def mongoize(object)\n case\n when object.is_a?(Mongoid::Snappy) then object.mongoize\n when object.is_a?(String) then Mongoid::Snappy.new(object).mongoize\n else object\n end\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n else\n object\n end\n end",
"def mongoize(object)\n case\n when object.is_a?(Money) then object.mongoize(object)\n when object.is_a?(Hash) then\n object.symbolize_keys! if object.respond_to?(:symbolize_keys!)\n value = ::Money.new(object[:cents], object[:currency_iso] || Money.default_currency.iso_code)\n value.mongoize(object)\n when object.respond_to?(:to_money) then\n return if object.is_a?(String) && object.blank?\n object.to_money.mongoize(object)\n else object\n end\n end",
"def mongoize(object)\n case object\n when nil then nil\n when QDM::Code then object.mongoize\n when Hash\n object = object.symbolize_keys\n QDM::Code.new(object[:code], object[:system], object[:display], object[:version]).mongoize\n else object\n end\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n else\n object\n end\n end",
"def mongoize(object)\n return nil if object.nil?\n case object\n when self\n object.mongoize\n else\n object\n end\n end",
"def convert_from_object(object)\n if object.class.name =~\n /AdwordsApi::V201008::\\w+::\\w+/\n # Handle soap4r object\n object_class = REGISTRY.schema_definition_from_class(object.class)\n if object_class.elements and !object_class.elements.entries.empty?\n # Process complex object.\n hash = {}\n hash[:xsi_type] = object.class.name.split('::').last\n object_class.elements.entries.each do |entry|\n property = entry.varname.to_s\n if object.respond_to? property and !property.include?('_Type')\n value = object.send(property)\n property_name = nil\n if @api.config.read('service.use_ruby_names')\n property_name = underscore(property).to_sym\n else\n property_name = property.to_sym\n end\n # Recurse.\n hash[property_name] = convert_from_object(value) if value\n end\n end\n return hash\n else\n # Process simple object.\n parent = object.class.superclass\n return parent.new(object)\n end\n elsif object.is_a? Array\n # Handle arrays\n return object.map do |entry|\n # Recurse.\n convert_from_object(entry)\n end\n else\n # Handle native objects\n return object\n end\n end",
"def mongoize(object)\n object.mongoize\n end",
"def cast_value\n value.mongoize\n end",
"def mongoize(object)\n case object\n when RussianPhone::Number then object.mongoize\n when String then RussianPhone::Number.new(object, @options).mongoize\n else object\n end\n end",
"def convert\n raise NotImplementedError\n end",
"def coerce(object)\n self.class.coerce(object)\n end",
"def convert_object(value)\n case value\n when RDFSource\n value\n when RDF::Literal\n if value.simple?\n value.object\n elsif value.has_datatype?\n RDF::Literal.datatyped_class(value.datatype.to_s) ? value.object : value\n else\n value\n end\n when RDF::Resource\n cast? ? make_node(value) : value\n else\n value\n end\n end",
"def typecast(obj)\n case obj \n when Array\n _typecast(convert_format(obj))\n when Hash\n unless @columns\n raise Error, 'PGRow::Parser without columns cannot typecast from a hash'\n end\n _typecast(obj)\n else\n raise Error, 'PGRow::Parser can only typecast arrays and hashes'\n end\n end",
"def evolve(object)\n case object\n when RussianPhone::Number then object.mongoize\n else object\n end\n end",
"def object_to_param(object)\n if object.respond_to? :to_param\n object.to_param\n elsif object.respond_to? :to_s\n object.to_s\n else\n raise Unconvertable.new(object) \n end\n rescue NoMethodError\n raise Unconvertable.new(object)\n end",
"def mongoize(object)\n case object\n when self then object.mongoize\n when Symbol then new(object).mongoize\n else object\n end\n end",
"def mongoize(object)\n case object\n when TimeOfDay then object.mongoize\n else object\n end\n end",
"def convert(obj, options={})\n return obj if is_basic_type?(obj)\n return convert_hash(obj, options) if obj.kind_of?(Hash)\n return convert_enumerable(obj, options) if obj.respond_to?(:map)\n return convert_custom_type(obj, options)\n end",
"def convert_if_possible(object_hash)\n if klass = object_hash.is_a?(Hash) && object_hash['data']\n if model_string = object_hash['data']['architect4r_type']\n data = begin\n eval(\"#{model_string}.send(:build_from_database, object_hash)\")\n rescue => ex\n data\n end\n elsif object_hash['self'].match(/node\\/\\d+$/i)\n data = GenericNode.send(:build_from_database, object_hash)\n end\n else\n data = object_hash\n end\n data\n end",
"def convert!; end",
"def mongoize(object)\n case object\n when Quantity\n object.mongoize\n when Numeric\n self.new(object).mongoize\n else\n object\n end\n end",
"def convert_to_dynamo_value(object_value); object_value; end",
"def convert_to_attribute( oid, object )\n\t\treturn object.to_s unless conversion = @object_conversions[ oid ]\n\n\t\tif conversion.respond_to?( :call )\n\t\t\treturn conversion.call( object, self )\n\t\telse\n\t\t\treturn conversion[ object ]\n\t\tend\n\tend",
"def coerce(attributes_or_object)\n value = if attributes_or_object.kind_of?(::Hash)\n @primitive.new(attributes_or_object)\n else\n attributes_or_object\n end\n\n super(value)\n end",
"def convert_to_object_value(dynamo_value); dynamo_value; end",
"def converters; end",
"def converters; end",
"def converters; end",
"def evolve(object)\n case object\n when Mongoid::Snappy then object.mongoize\n when String then Mongoid::Snappy.new(object).mongoize\n else object\n end\n end",
"def evolve(object)\n case object\n when Money then object.mongoize\n else object\n end\n end",
"def convert_to_r_object(obj)\n # first try converters defined for just this instance\n success, value = apply_local_r_converters(obj)\n return [success, value] if success\n\n # then try converters defined in general\n success, value = apply_r_converters(obj)\n return [success, value] if success\n\n # and finally apply the default converters \n success, value = apply_default_r_converters(obj)\n return [success, value] if success\n\n # give up\n [false, obj]\n end",
"def evolve(object)\n case object\n when Money then object.mongoize\n else object\n end\n end",
"def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end",
"def encode(obj); end",
"def serialize_default(object)\n mongoize(object)\n end",
"def mongoize(object)\n { ::I18n.locale.to_s => type.mongoize(object) }\n end",
"def update_from_object(obj)\n\t\tfor to_type,fields in [[\"to_block_length\",%w{x y z stance}],[\"to_rotation_in_degrees\",%w{yaw pitch}],[\"to_i\",[\"is_on_ground\"]]]\n\t\t\tfor field in fields do\n\t\t\t\t#puts \"checking field #{field}\"\n\t\t\t\tif obj.respond_to?(field)\n\t\t\t\t\tinstance_variable_set(\"@\"+field,obj.send(field).send(to_type))\n\t\t\t\t#\tputs \"\\tset field #{field} to value #{obj.send(field)} enforcing type #{to_type}\"\n\t\t\t\tend\n\t\t\t\t\n\t\t\tend\n\t\tend\n\tend",
"def serialize(object) end",
"def mongoize(object)\n case object\n when Array then MongoizedLine.new(object).mongoize\n else object\n end\n end",
"def converter; end",
"def convert_object(value)\n value = value.object if value.kind_of? RDF::Literal\n value = make_node(value) if value.kind_of? RDF::Resource\n value\n end",
"def apply_r_converters(obj)\n apply_converters(Engine.r_converters, obj)\n end",
"def trycast(obj)\n\t\tif obj\n\t\t\treturn is_integer?(obj) ? obj.to_i : is_float?(obj) ? obj.to_f : nil\n\t\tend\n\t\treturn obj\n\tend",
"def instantiate_and_cast(obj, change = true)\n couchrest_parent_will_change! if change && use_dirty?\n obj.casted_by = casted_by if obj.respond_to?(:casted_by)\n obj.casted_by_property = casted_by_property if obj.respond_to?(:casted_by_property)\n obj\n end",
"def mongoize(object)\n case object\n when self\n object.mongoize\n when Hash\n h = object.deep_stringify_keys\n return self.new.mongoize if h[\"loc\"].blank?\n\n h[\"loc\"] = Map::Extensions::Loc.mongoize(h[\"loc\"])\n if h[\"zoom_level\"].present?\n h[\"zoom_level\"] = Integer(h[\"zoom_level\"]) rescue nil\n end\n ret = self.new\n ret.merge!(h)\n ret.mongoize\n else object\n end\n end",
"def convert\n raise \"The convert method must be implemented by subclass!\"\n end",
"def cast_value(value)\n case value\n when String then decode_and_initialize(value)\n when Hash then extract_model_klass(value).new(value)\n when nil then value\n else\n raise_cast_error(value) unless value.class.ancestors.include?(StoreModel::Model)\n\n value\n end\n rescue ActiveModel::UnknownAttributeError => e\n handle_unknown_attribute(value, e)\n end",
"def convert_to_object(object, parent_class = nil, property = nil)\n property = camel_case(property.to_s) if property\n if object.is_a? Hash\n # Process a hash.\n specified_class = object[:xsi_type] or object['xsi_type']\n default_class = nil\n # Determine default class for this object, given the property\n # being set.\n if parent_class and property\n parent = REGISTRY.schema_definition_from_class(parent_class)\n element = parent.elements.entries.find do |entry|\n entry.varname.to_s == property.to_s\n end\n default_class = element.mapped_class if element\n end\n validate_object(object, default_class)\n real_class = nil\n if specified_class\n real_class = @module.class_eval(specified_class)\n else\n real_class = default_class\n end\n # Instance real object.\n real_object = real_class.new\n # Set each of its properties.\n object.each do |entry, value|\n entry = entry.to_s\n unless entry == 'xsi_type'\n if @api.config.read('service.use_ruby_names')\n entry = camel_case(entry)\n end\n if value.is_a? Hash\n # Recurse.\n set_object_property(real_object, entry,\n convert_to_object(value, real_class, entry))\n elsif value.is_a? Array\n set_object_property(real_object, entry,\n value.map do |item|\n # Recurse.\n convert_to_object(item, real_class, entry)\n end\n )\n else\n set_object_property(real_object, entry, value)\n end\n end\n end\n return real_object\n elsif object.is_a? Array\n # Process an array\n return object.map do |entry|\n # Recurse.\n convert_to_object(entry, parent_class, property)\n end\n else\n return object\n end\n end",
"def evolve(object)\n case object\n when self then object.mongoize\n when Symbol then mongoize(object)\n else object\n end\n end",
"def record_to_object(record)\n record\n end",
"def from_type(obj)\n if !obj.nil? && type && !mapping\n send(\"dump_#{type}\", obj)\n elsif !obj.nil? && mapping && mapping.key?(obj)\n mapping[obj]\n else\n obj\n end\n end",
"def encode_object(object)\n scramble_encode(\"#{object.class}-#{object.id}\")\n end",
"def mongoize(object)\n case object\n when Interval then object.mongoize\n when Hash then Interval.new(object).mongoize\n else object\n end\n end",
"def coerce(object)\n Attribute.coerce(object)\n end",
"def to_obj; end",
"def coerce(object)\n project_relation(Relation.new(header, object))\n end",
"def normalize object\n tools = ::SleepingKingStudios::Tools::ObjectTools\n\n tools.deep_dup(object)\n end",
"def serialize(object)\n case object\n when String\n {\n type: \"string\",\n value: object,\n description: object\n }\n when Numeric\n {\n type: \"number\",\n value: object,\n description: object.to_s\n }\n when TrueClass, FalseClass\n {\n type: \"boolean\",\n value: object,\n description: object.to_s\n }\n when Symbol\n {\n type: \"symbol\",\n value: object,\n description: object.to_s\n }\n when Array\n result = {\n type: \"object\",\n className: object.class.to_s,\n description: \"Array(#{object.length})\",\n objectId: register(object),\n subtype: \"array\"\n }\n\n result.merge!(\n preview: result.merge(\n overflow: false,\n properties: get_properties(object)\n )\n )\n\n result\n when nil\n {\n type: \"object\",\n subtype: \"null\",\n value: nil\n }\n else\n {\n type: \"object\",\n className: object.class.to_s,\n description: object.to_s,\n objectId: register(object)\n }\n end\n end",
"def convert_to_native obj\n mapping = mappings[obj.name] || raise(Error, \"couldn't handle tag #{obj.name.inspect}\")\n mapping.call(obj)\n end",
"def mongoize(object)\n if type.resizable? || object_id_field?\n type.__mongoize_fk__(association, object)\n else\n related_id_field.mongoize(object)\n end\n end",
"def to_simple(object, container, options = {})\n val = value(object)\n mapper = self.mapper\n strings = options[:string_keys] || false\n changed_members = change_tracking_for(val)\n if options[:changed]\n if mapper\n change_proc = Proc.new do |key, val|\n changed_members[key] or (! val.nil? and val.changed?)\n end\n else\n change_proc = Proc.new {|k, v| changed_members[k]}\n end\n else\n change_proc = nil\n end\n changes = options[:changed] || false\n container = val.inject(container) do |hash, keyvalue|\n key = to_simple_key(keyvalue[0])\n hash[strings ? key.to_s : key] = mapper ? keyvalue[1].to_simple(options) : encode(keyvalue[1]) if ! change_proc or change_proc.call(*keyvalue)\n hash\n end\n if (change_proc or options[:all]) and ! options[:defined]\n changed_members.keys.find_all {|x| ! val.is_member?(x)}.each do |key|\n container[to_simple_key(key)] = nil\n end\n end\n container\n end",
"def convert!\n resource\n end",
"def encode(object, options={})\n object = object.to_a if defined?(ActiveRecord::Relation) && object.is_a?(ActiveRecord::Relation)\n fields_to_hash(options)\n if object.is_a?(Array)\n if options[:fields]\n encode_partial_array(object, options)\n else\n encode_array(object, options)\n end\n elsif options[:fields]\n encode_partial_single(object, options)\n else\n encode_single(object, options)\n end\n end",
"def serialize(object)\n if object.is_a?(::String)\n BSON::ObjectId.from_string(object) unless object.blank?\n else\n object\n end\n end",
"def convert(value) value end",
"def evolve(object)\n case object\n when QDM::Code then object.mongoize\n else object\n end\n end",
"def try_convert( object )\n \n converted_object = nil\n \n case object\n when ::Array::Hooked\n converted_object = object\n else\n if object.respond_to?( :to_ary )\n case attempted_conversion = object.to_ary\n when nil\n # we failed - done\n when ::Array::Hooked\n converted_object = attempted_conversion\n when ::Array\n converted_object = self.new_without_internal_array( @configuration_instance )\n converted_object.internal_array = attempted_conversion\n end\n end\n end\n \n return converted_object\n \n end",
"def convert_properties_to(obj, medium, properties)\n direction = medium == :ruby ? :to_ruby : :to_db\n properties.to_h.each_pair do |key, value|\n next if skip_conversion?(obj, key, value)\n\n converted_value = convert_property(key, value, direction)\n if properties.is_a?(ActiveGraph::AttributeSet)\n properties.write_cast_value(key, converted_value)\n else\n properties[key] = converted_value\n end\n end\n end",
"def fix_url_object(obj, data = nil)\n if data\n obj.content_type = PLAIN\n obj.data = data\n obj.store\n return obj\n end\n case obj.content_type\n when /json/ then fix_url_object(obj, JSON.parse(%({\"data\":#{obj.raw_data}}))['data'])\n when PLAIN then obj\n else fix_url_object(obj, obj.data) # old values had the right data but the content type was application/x-www-form-urlencoded\n end\n end",
"def evolve(object)\n case object\n when TimeOfDay then object.mongoize\n else object\n end\n end",
"def mongoize(object)\n return if object.nil?\n case object\n when ::Array, ::Set\n object.map(&:mongoize)\n end\n end",
"def evolve(object)\n case object\n when QDM::Date then object.mongoize\n else object\n end\n end",
"def _typecast(obj)\n if t = @typecaster\n t.call(obj)\n else\n obj\n end\n end",
"def convert(obj)\n case obj\n when ConfigNode\n obj\n when Hash\n ConfigNode.new convert_hash obj\n when Array\n obj.map { |o| convert o }\n else\n obj\n end\n end",
"def serialize(object)\n object ? constraint.convert(object) : []\n end",
"def converter\n end",
"def convert_object(*object_or_attributes)\n if object_or_attributes.length == 0\n return @contained_class.new\n elsif object_or_attributes.length > 1\n return @contained_class.new(*object_or_attributes)\n else\n object_or_attributes = object_or_attributes.first\n end\n\n if object_or_attributes.is_a?(Hash)\n @contained_class.new(**object_or_attributes)\n\n else\n raise ArgumentError.new(\"Argument provided to Collection.add could not be converted to a #{@contained_class}\") unless object_or_attributes.is_a?(@contained_class)\n object_or_attributes\n end\n end",
"def convert_to(value, type, path = nil)\n path = Path.new(path) unless path.kind_of?(Path)\n case type.object_id\n when Integer.object_id\n raise Error.new(Error::WrongType, path) unless value.respond_to?(:to_i)\n value.to_i\n when Float.object_id\n raise Error.new(Error::WrongType, path) unless value.respond_to?(:to_f)\n value.to_f\n when Array.object_id\n # FIXME: Should allow more flexible kinds of lists (with spaces).\n value.to_s.split\n when String.object_id\n value.to_s\n else\n raise Error.new(Error::WrongType, path) unless type.respond_to?(:from_str)\n type.from_str(value)\n end\n end",
"def normalize_firebase_hash(object, id = nil)\n # firebase returns objects like this:\n # [\"-K6BRIuIfaHFb9aZDP7I\", {\"name\"=>\"Jordan\", \"age\"=>\"27\"}]\n if object.is_a?(Array)\n id = object[0]\n data = object[1]\n data.merge('id' => id)\n elsif object.is_a?(Hash) && id\n object.merge('id' => id)\n end\n end"
] |
[
"0.81272006",
"0.7871279",
"0.70423317",
"0.6989946",
"0.68704975",
"0.68297803",
"0.6824049",
"0.6801315",
"0.6746827",
"0.6736552",
"0.6703407",
"0.669389",
"0.66761917",
"0.66558206",
"0.66486794",
"0.66148937",
"0.66136605",
"0.6544325",
"0.6544325",
"0.6541866",
"0.6531095",
"0.6529111",
"0.65143394",
"0.6513039",
"0.64901906",
"0.64901906",
"0.6473514",
"0.646069",
"0.6451015",
"0.6442256",
"0.6423813",
"0.6415121",
"0.63989955",
"0.63982093",
"0.6377441",
"0.6360841",
"0.63463247",
"0.63186264",
"0.6306245",
"0.6302209",
"0.62817526",
"0.6250117",
"0.62409556",
"0.6235351",
"0.6129105",
"0.61244655",
"0.6109757",
"0.6109757",
"0.6109757",
"0.61075765",
"0.6103958",
"0.60909766",
"0.6090913",
"0.60770947",
"0.6055622",
"0.6037993",
"0.60351676",
"0.60242903",
"0.6010017",
"0.60044485",
"0.60011166",
"0.5991375",
"0.5975063",
"0.59706765",
"0.5948006",
"0.59434086",
"0.5935162",
"0.5904379",
"0.5893443",
"0.58884776",
"0.5885723",
"0.58728874",
"0.5870966",
"0.5863298",
"0.5853657",
"0.58467644",
"0.5838032",
"0.5834288",
"0.581789",
"0.58112156",
"0.5788118",
"0.57750076",
"0.5739027",
"0.5736125",
"0.573508",
"0.57331043",
"0.57163006",
"0.57133555",
"0.5712761",
"0.5698377",
"0.56982285",
"0.5696114",
"0.5687302",
"0.5686801",
"0.5660497",
"0.56553024",
"0.5652681",
"0.56224316",
"0.56170607",
"0.56146675"
] |
0.63054633
|
39
|
Show the full list of categories
|
def index; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list_categories\n Category.all.each.with_index(1) {|x, i| puts \"#{i}. #{x.name}\"} #Scraper.categories.each.with_index(1) {|category, i| puts \"#{i}. #{category[0]}\"}\n puts \"select the number of the category you would like to browse or type 'exit'\"\n end",
"def category_lister\n Category.all.each_with_index do |cat, idx|\n puts \"#{idx + 1}: #{cat.name}\"\n end\n end",
"def index\n @cp_categories = Category.all\n @title = \"Categories\"\n end",
"def all_categories\n end",
"def index\n @categories = Category.all\n end",
"def categories_list\n self.categories.collect{|c| c.name}\n end",
"def index\n\t\t@categories = Category.all\n\tend",
"def index\n\t@categories = Category.all\n\tend",
"def list_categories \n @categories = [\"Muesums\", \"Music, Comedy, and Nightlife\", \"Shopping\", \"Sports & Recreation\", \"Theater & Performing Arts\", \"Tours & Attractions\"]\n @categories.each.with_index(1) {|index,category| \n puts \"#{category} - #{index}\"\n }\n end",
"def index\n @all_categories = CateItem.all\n end",
"def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend",
"def categories\n category\n end",
"def categories_list\n @categories = Category.all.collect { |p| [p.name, p.id] }\n end",
"def show\n @categories = Category.order(\"name ASC\")\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n @title = 'Categories'\n end",
"def index\n @mk_categories = MkCategoria.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def index\n @categories = Category.all\n end",
"def categories\n []\n end",
"def category_list_builder\n categories = API.get_categories\n categories.each do |cat|\n Category.new(cat)\n end\n end",
"def index\n @categories = collections_config.values\n end",
"def index\n @categs = Categ.all\n end",
"def categories\n return [] if @categories.blank?\n @categories.records.map {|c| c.display_name}\n end",
"def index\n @categories = Category.roots\n end",
"def index\n respond_with Category.all\n end",
"def getCategoryAll()\n params = Hash.new\n return doCurl(\"get\",\"/category/all\",params)\n end",
"def index\n @cathegories = Cathegory.all\n end",
"def list_categories(variable)\n if !variable.categories.empty?\n cat_list = \"\"\n variable.categories.split(',').each{|cat| cat_list << content_tag(:li, cat.capitalize, :class => cat.downcase)}\n content_tag(:ul, cat_list, :class => \"categories\")\n else\n content_tag(:span, \"None\")\n end\n end",
"def index\n @categors = Categor.all\n end",
"def categories()\n db = connect()\n db.execute('SELECT * FROM categories')\n end",
"def category_names\n @category_names || categories.map(&:name).join(' ')\n end",
"def categories\n notify Category.all(:order => \"name ASC\").collect {|c| c.name_with_id }.join(\"\\n\")\n end",
"def categories\n get('venues/categories').categories\n end",
"def index\n @categories=Category.all\n end",
"def index\n @caste_categories = CasteCategory.all\n end",
"def index\n @category = Category.all\n end",
"def index\n @admin_categories = Admin::Category.all\n end",
"def index\n @categories = @current_website.categories.all\n end",
"def index\n @casein_page_title = 'Categorias'\n \t\t@categories = Category.order(sort_order(:nombre)).paginate :page => params[:page]\n end",
"def index\n @admin_categories = Category.all\n end",
"def index\n\t\tcreator_categories\n\tend",
"def index\n @small_categories = SmallCategory.category_tree\n end",
"def categories\n add_to_query restrict_kind: 'category'\n end",
"def index\n @accolade_categories = AccoladeCategory.all\n end",
"def categories\n category_keys.collect(&:to_s)\n end",
"def show\n @p_cats = PCat.all\n end",
"def show\n @title = 'Categories'\n @recipes = @category.recipes.each{|c| [c.name, c.id] }\n end",
"def index\n @categories = @project.categories.all\n end",
"def category_names\n self.categories.map do |category|\n category.name\n end\n end",
"def get_sidebar_filter_categories(categories)\n html_code = ''\n if !categories.children.empty?\n\n html_code += '<div class=\"sidebar-module-container\">\n <div class=\"sidebar-filter\">\n <div class=\"sidebar-widget outer-bottom-small wow fadeInUp animated\">\n <h3 class=\"section-title\">shop by</h3>\n <div class=\"widget-header\">\n <h4 class=\"widget-title\">Category</h4>\n </div>\n <div class=\"sidebar-widget-body\">\n <div class=\"accordion\">'\n categories.children.each do |category|\n html_code += '<div class=\"accordion-group\">\n <div class=\"accordion-heading\">'\n html_code += link_to category.category_name, category_path(category: category.id), {class: 'accordion-toggle collapsed'}\n html_code += '</div></div>'\n end\n html_code += '</div></div></div></div></div>'\n end\n html_code.html_safe\n end",
"def fresh_categories\n # these are the categories that will be displayed by default\n # in the html view\n return {\n \"speakerData\" => {\"label\" => \"Character Direct Speech\", \"data\" => []},\n \"indirectData\" => {\"label\" => \"Character Indirect Diction\", \"data\" => []},\n \"traitData\" => {\"label\" => \"Trait: Character Type\", \"data\" => []}, \n \"genderData\" => {\"label\" => \"Trait: Character Sex\", \"data\" => []},\n \"maritalStateData\" => {\"label\" => \"Trait: Character Marriage Status\", \"data\" => []},\n \"socecStatusData\" => {\"label\" => \"Trait: Character Class Status\", \"data\" => []},\n \"ageData\" => {\"label\" => \"Trait: Character Age\", \"data\" => []},\n \"occupationData\" => {\"label\" => \"Trait: Character Occupation\", \"data\" => []},\n }\nend",
"def index\n @categories = Category.order(name: :asc).all\n end",
"def index\n @categories = current_user.categories\n end",
"def show\n\t\t@category = Category.find(params[:id])\n\t\t@sub_categories = @category.sub_categories\n\tend",
"def index\n @product_categories = Product::Category.all\n end",
"def categories\n return @categories\n end",
"def categories\n return @categories\n end",
"def categories\n return @categories\n end",
"def get_categories\n @categories = Category.all\n end",
"def index\n @hive_categories = HiveInformation.all\n end",
"def display_categories(db)\r\n\tcurrent_categories(db).each_with_index {|category, index| puts \"#{(index +1)}: #{category[0]}\"}\r\nend",
"def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @catalog_categories = CatalogCategory.all\n end",
"def index\n # @categories = current_user.categories\n @categories = Category.accessible_by(current_ability).all\n end",
"def index\n @sys_categories = Sys::Category.all\n end",
"def getCategories()\n\t\tcat = Array.new\n\t\tcat.push(\"heroku\")\n\t\tcat.push(\"go\")\n\t\tcat.push(\"github\")\n\t\tcat.push(\"docker\")\n\t\tcat.push(\"css\")\n\t\tcat.push(\"apache\")\n\t\tcat.push(\"html\")\n\t\tcat.push(\"bootstrap\")\n\t\tcat.push(\"java ee\")\n\t\tcat.push(\"javafx\")\n\t\tcat.push(\"java\")\n\t\tcat.push(\"jquery\")\n\t\tcat.push(\"mips\")\n\t\tcat.push(\"c++\")\n\t\tcat.push(\"laravel\")\n\t\tcat.push(\"linux\")\n\t\tcat.push(\"opengl\")\n\t\tcat.push(\"sml\")\n\t\tcat.push(\"javascript\")\n\t\tcat.push(\"mongo db\")\n\t\tcat.push(\"c\")\n\t\tcat.push(\"yacc\")\n\t\tcat.push(\"circuit\")\n\t\tcat.push(\"php\")\n\t\tcat.push(\"mysql\")\n\t\tcat.push(\"node js\")\n\t\tcat.push(\"photoshop\")\n\t\tcat.push(\"rails\")\n\t\tcat.push(\"postgres\")\n\t\tcat.push(\"ruby\")\n\t\tcat.push(\"redis\")\n\t\tcat.push(\"mac osx\")\n\t\tcat.push(\"sass\")\n\t\tcat.push(\"ubuntu\")\n\t\tcat.push(\"bower\")\n\t\tcat.push(\"wordpress\")\n\t\tcat.push(\"css\")\n\t\tcat.push(\"hosted\")\n\t\tcat.push(\"python\")\n\t\tcat.push(\"maven\")\n\t\tcat.push(\"maven mojo\")\n\t\tcat.push(\"composer\")\n\t\tcat.push(\"mips\")\n\t\tcat.push(\"gulp\")\n\t\tcat.push(\"grunt\")\n\t\tcat.push(\"phpstorm\")\n\t\tcat.push(\"react\")\n\t\tcat.push(\"swift\")\n\t\tcat.push(\"wordpress\")\n\t\tcat.push(\"tomcat\")\n\t\tcat.push(\"redis\")\n\t\tcat.push(\"travis\")\n\t\treturn cat\n\tend",
"def index\n @category = Category.all\n # @ means that this variable is seen inside corresponding view (index.html.erb)\n # Category.all shows all records (as with the console)\n end",
"def category\n categories.collect(&:title).join(',')\n end",
"def index\n @mcategories = Mcategory.all\n end",
"def all_categories\n\t\t@categories = Category.all\n\tend",
"def index\n @companies = Company.where(user_id: current_user.id).order(\"name\")\n @path = 'products_categories'\n @pagetitle = \"Product categories\"\n end",
"def index\n @ilance_categories = IlanceCategory.all\n end",
"def index\n @cats = Cat.all\n end",
"def index\n @gt_categories = GtCategory.all\n end",
"def get_categories_list\n args = receive_should_validate?\n get('redtube.Categories.getCategoriesList', {}, [], args[:should_validate])\n end",
"def index\n @categories = Category.all\n \n respond_with do |format|\n format.html { render :index, :layout => false}\n end\n end",
"def list_products_categories\n @company = Company.find(params[:company_id])\n @pagetitle = \"#{@company.name} - Product categories\"\n \n if(@company.can_view(current_user))\n @products_categories = ProductsCategory.where(company_id: @company.id).paginate(:page => params[:page])\n else\n errPerms()\n end\n end",
"def index\n @agendacategories = Agendacategory.all\n end"
] |
[
"0.7697334",
"0.7669039",
"0.76590073",
"0.76012456",
"0.7576922",
"0.75511366",
"0.7516861",
"0.7489365",
"0.7463017",
"0.74333066",
"0.74317175",
"0.74208283",
"0.73960096",
"0.73619294",
"0.732566",
"0.7315982",
"0.7304643",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.730288",
"0.7259362",
"0.72047323",
"0.71837544",
"0.7183402",
"0.7176162",
"0.71735877",
"0.7172099",
"0.7160517",
"0.7143378",
"0.7143098",
"0.714102",
"0.7093816",
"0.70639753",
"0.70625526",
"0.7052908",
"0.70368093",
"0.70181173",
"0.7016048",
"0.70022386",
"0.6989796",
"0.6986951",
"0.69867414",
"0.6982548",
"0.69743216",
"0.6966561",
"0.6965829",
"0.69575244",
"0.69524825",
"0.6951756",
"0.6941522",
"0.69378024",
"0.6937032",
"0.6928731",
"0.692561",
"0.6899202",
"0.68988115",
"0.68957627",
"0.68884563",
"0.68884563",
"0.68884563",
"0.68868923",
"0.6883527",
"0.68679786",
"0.68580335",
"0.68453836",
"0.68407786",
"0.68372256",
"0.6834954",
"0.68295753",
"0.68256056",
"0.68237185",
"0.6818178",
"0.6817471",
"0.68094397",
"0.6809419",
"0.6804133",
"0.6803508",
"0.6797585",
"0.6786836",
"0.6784567"
] |
0.0
|
-1
|
Update the order of the categories This is called by the Nestable JS code whenever the user drags around the order of the categories.
|
def order
# This will already have been deserialized by Rails, and is thus likely to
# be an array (though maybe a Hash if there's only one of them).
new_order = params[:order]
new_order = [new_order] if new_order.is_a?(Hash)
# Loop the roots and make them roots, then recursively set their children
new_order.each do |h|
id = h['id']
category = Documents::Category.find(id)
category.parent = nil
category.save
set_children_for(category, h)
end
head :no_content
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sort\n section = Section.find(params[:section_id])\n categories = section.categories\n categories.each do |category|\n category.position = params['category'].index(category.id.to_s) + 1\n category.save\n end\n render :nothing => true\n end",
"def camaleon_category_order_on_list_category(values)\n\n plugin_meta = get_plugin.get_meta('_reorder_objects')\n\n if plugin_meta.present?\n plugin_meta[:post_type].each do |meta|\n if meta.to_i == values[:post_type].id.to_i\n append_asset_libraries({reorder: {js: [plugin_asset_path(\"category_reorder.js\")], css: [plugin_asset_path(\"reorder.css\")]}})\n cama_content_append('<script>jQuery(function(){$.fn.reorder({url: \"'+admin_plugins_camaleon_category_order_reorder_categories_path+'\", table: \"#categories-table-list\"});});</script>')\n end\n end\n end\n end",
"def update_categories(cats=[])\n rescue_extra_data\n cats = cats.to_i\n old_categories = categories.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")\n delete_categories = old_categories - cats\n news_categories = cats - old_categories\n term_relationships.where(\"term_taxonomy_id in (?)\", delete_categories ).destroy_all if delete_categories.present?\n news_categories.each do |key|\n term_relationships.create(:term_taxonomy_id => key)\n end\n update_counters(\"categories\")\n end",
"def order_categories!(sort_priorities)\n base = \"sort_priority = CASE id\\n\"\n update_statements = sort_priorities.reduce(base) do |sql, (cat_id, priority)|\n sql + \"WHEN #{cat_id} THEN #{priority}\\n\"\n end\n update_statements += \"END\"\n\n @current_community.categories.update_all(update_statements)\n end",
"def set_category_order\n\n # Get venture for validation\n venture = Category.find(params[:ids].first).venture\n return unless venture.user_id == current_user.id\n\n # Get all category and position ids from user for validation\n category_ids = venture.categories.pluck(:id)\n\n # Validate that categories and positions really belong to user\n return unless (category_ids & params[:ids].map(&:to_i)).size == params[:ids].size\n\n # Update category positions\n params[:ids].each_with_index do |category_id, i|\n Category.update(category_id, :order => i)\n end\n end",
"def sort\r\n key = params.keys.grep(/m(?:aj|in)ors/).shift # Get DOM ID.\r\n order, parent = params[key], key[/\\d+/] # Filter out category ids.\r\n attrs = order, (1..order.length).map { |p| { :position => p } }\r\n unless parent.nil? # Scope\r\n instance.idea_categories.find(parent).subcategories.update *attrs\r\n else\r\n instance.idea_categories.update *attrs\r\n end\r\n render(:update) { |page| page.visual_effect :highlight, key }\r\n end",
"def cat_update_item_count\n self.categories.each do |category|\n if (category.displayed_items.count - 1) == category.item_count\n category.inc_item_count\n end\n if (category.displayed_items.count + 1) == category.item_count\n category.dec_item_count\n end\n end\n end",
"def update_category_counter\r\n end",
"def update_category_item_count\n Rails.logger.debug \"Item saved, updating categories#item_count...\"\n self.categories.each do |category|\n if (category.displayed_items.count - 1) == category.item_count\n category.increment_item_count\n elsif (category.displayed_items.count + 1) == category.item_count\n category.decrement_item_count\n end\n end\n end",
"def touch_category_lists\n\t\tcategory_lists.map &:touch\n\tend",
"def update!(**args)\n @categories = args[:categories] if args.key?(:categories)\n end",
"def update!(**args)\n @categories = args[:categories] if args.key?(:categories)\n end",
"def update_categories\n categories_file = fspath + '@categories'\n update_file = fspath + '.categories_since_last_update'\n if categories_file.exist?\n if !update_file.exist? or\n update_file.mtime < categories_file.mtime or\n update_file.mtime < fspath.ctime\n then\n current_categories = categories_without_update\n current_categories.each { |category| category.send(:add_member, path.to_s) }\n previous_categories = (update_file.read rescue '').lines.\n map { |l| site.page_for l.chomp rescue nil }.\n select { |p| p.is_a? Category }.to_set\n (previous_categories - current_categories).\n each { |category| category.send(:delete_member, path.to_s) }\n update_file.open('w') { |f|\n current_categories.each { |c| f.puts(c.path) }\n }\n return current_categories\n end\n end\n return nil\n end",
"def enforce_positioning\n Category.skip_callback(:save, :after, :enforce_positioning)\n\n last_position = self.position\n categories = Category.where('parent_id = ? AND position >= ? AND id != ?', self.parent_id, self.position, self.id)\n categories.each do |category|\n break if category.position != last_position\n\n category.position = category.position + 1\n category.save\n\n last_position = category.position\n end\n\n Category.set_callback(:save, :after, :enforce_positioning)\n end",
"def update\n update! {admin_categories_path}\n end",
"def sort_page_categories\n params[:pc].each_with_index {|val, index|\n obj = PageCategory.find_by_apikey(val)\n obj.update_attribute(:sort_order, index)\n }\n render :text => \"\"\n end",
"def update_product_category\n return true if self.category.blank?\n categories = self.category.ancestors.collect{|x| x.id}.reverse.push(self.category.id)\n category_names = self.category.ancestors.collect{|x| x.name.downcase}.reverse.push(self.category.name.downcase).join(\" | \")\n product_cat = ProductCat.find_or_create_by_product_id(self.id)\n product_cat.fourth_category_id = categories[3] unless categories[3].blank?\n product_cat.third_category_id = categories[2] unless categories[2].blank?\n product_cat.second_category_id = categories[1] unless categories[1].blank?\n product_cat.first_category_id = categories[0] unless categories[0].blank?\n product_cat.categories_delimited = category_names\n product_cat.user = self.user\n product_cat.save\n end",
"def categories\n Category.position_sorted\n end",
"def category_params\n params.require(:category).permit(:name, :published, :position, :width, :catalog_id, :position, {order: [:id, :position, :catalog_id]})\n end",
"def update_category_lists\n\t\tall_list = CategoryList.all_list\n\t\thome_list = CategoryList.home_list\n\t\tif is_predefined\n\t\t\tall_list.categories << self unless category_lists.include? all_list\n\t\t\tif home_page_column\n\t\t\t\thome_list.categories << self unless category_lists.include? home_list\n\t\t\telse\n\t\t\t\thome_list.categories.delete self if category_lists.include? home_list\n\t\t\tend\n\t\telse\n\t\t\tall_list.categories.delete self if category_lists.include? all_list\n\t\t\thome_list.categories.delete self if category_lists.include? home_list\n\t\tend\n\tend",
"def reorder\n @image = Image.find(params[:image_id])\n @category_ids = selected_ids(:all_categories)\n respond_to do |format|\n if ImageCategory.reorder_categories(@category_ids,@image)\n self.load_view_vars\n flash[:notice] = \"Categories reordered (#{@category_ids.uniq.size}).\" \n format.html { redirect_to image_categories_url(@image) }\n format.xml { head :ok }\n format.js\n else\n @reorder_url = reorder_image_categories_url(@image)\n flash[:notice] = \"Reordering categories failed due to errors.\"\n format.html { redirect_to image_categories_url(@image) }\n format.xml { head :unprocessable_entity }\n format.js\n end\n end\n end",
"def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n req.url \"categories\"\n req.body = options.to_json\n end\n\n resp.status \n end",
"def set_categories\n @categories = Category.order(:name).pluck(:name, :id)\n end",
"def array\n # assign the sorted tree to a variable\n newlist = params[:ul].sort\n # initialize the previous item\n previous = nil\n #loop through each item in the new list (passed via ajax)\n newlist.each_with_index do |array, index|\n # get the category id of the item being moved\n moved_item_id = array[1][:id].gsub(/category_/,'')\n # find the object that is being moved (in database)\n @current_category = Category.find_by_id(moved_item_id)\n # if this is the first item being moved, move it to the root.\n unless previous.nil?\n @previous_item = Category.find_by_id(previous)\n @current_category.move_to_right_of(@previous_item)\n else\n @current_category.move_to_root\n end\n # then, if this item has children we need to loop through them\n unless array[1][:children].blank?\n # NOTE: unless there are no children in the array, send it to the recursive children function\n childstuff(array[1], @current_category)\n end\n # set previous to the last moved item, for the next round\n previous = moved_item_id\n end\n Category.rebuild!\n render :nothing => true\n end",
"def camaleon_category_order_on_upgrade(plugin)\n end",
"def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update_sortable(pos, newVal)\n sort_function = @parent.sort_function(pos)\n if sort_function\n @sortable[pos] = sort_function.call(newVal)\n else\n @sortable[pos] = newVal\n end\n end",
"def update_tag_alias_categories\n consequent_aliases.each do |tag_alias|\n if tag_alias.antecedent_tag.category != category\n tag_alias.antecedent_tag.update!(category: category, updater: updater)\n end\n end\n end",
"def reprocess_ordering\n orderable_scope.each_with_index do |resource, index|\n resource.update_column(:position, index)\n end\n end",
"def category_update\n @finance_category = FinanceTransactionCategory.find(params[:id])\n unless @finance_category.update_attributes(params[:finance_category])\n @errors=true\n end\n @categories = FinanceTransactionCategory.all(:conditions => {:deleted => false}, :order => 'name asc')\n @category_ids = @categories.map { |cat| cat.id if FinanceTransaction.find_by_category_id(cat.id).present? }.compact\n @fixed_categories = @categories.reject { |c| !c.is_fixed }\n @other_categories = @categories.reject { |c| c.is_fixed }\n @multi_config = FinanceTransactionCategory.get_multi_configuration\n end",
"def set_category\n @category = Category.find(params[:id])\n @category.orderable :display_order, :parent_category_id # I'm already calling this in Category::initialize, but apparently `find` doesn't ever `initialize` - be a lot cooler if it did...\n end",
"def index\n @prv_categories = Category.ordered\n end",
"def set_all_categories\n @all_categories = Category.all.order_by_name\n end",
"def update_category_counter_cache\n category_conditions = ['questions_count = ?', Question.count(:id, :conditions => {:category_id => category_id})]\n # if the question moved categories\n if !frozen? && @old_category_id && @old_category_id != category_id\n set_answer_category_id\n Category.update_all ['questions_count = ?, answers_count = ?', \n Question.count(:id, :conditions => {:category_id => @old_category_id}),\n Answer.count(:id, :conditions => {:category_id => @old_category_id})], ['id = ?', @old_category_id]\n end\n # if the question moved categories or was deleted\n if frozen? || (@old_category_id && @old_category_id != category_id)\n category_conditions.first << \", answers_count = ?\"\n category_conditions << Answer.count(:id, :conditions => {:category_id => category_id})\n end\n @voices.each &:update_answers_count if @voices\n Category.update_all category_conditions, ['id = ?', category_id]\n @old_category_id = @voices = nil\n end",
"def set_categories(ids)\n self.categories = Category.find(ids)\n self.save\n end",
"def update\n @word_list = current_user.word_list\n\n #need to first remove categories from the word\n @word.categories.each do |category|\n @word.categories.delete category\n end\n\n #then push categories in from the category_params\n if params[\"category\"].include?(:category_ids)\n (params[\"category\"])[\"category_ids\"].each do |i|\n next if i.to_i == 0\n @word.categories << Category.find(i.to_i) unless @word.categories.include?(Category.find(i.to_i))\n end\n end\n\n if category_params.include?(:title) && ((params[\"category\"])[\"title\"]) != \"\"\n @word.categories << @word_list.categories.build(title: (params[\"category\"])[\"title\"])\n end\n\n respond_to do |format|\n if @word.update(word_params)\n format.html { redirect_to @word_list, notice: 'Word was successfully updated.' }\n #format.json { render :show, status: :ok, location: @word }\n else\n format.html { render :edit }\n #format.json { render json: @word.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_categories\n self.div(:id=>\"contentmetadata_locations_container\").fire_event \"onclick\"\n self.class.class_eval { include AddRemoveCategories }\n end",
"def list\r\n\t\t@current_area = 'categories'\r\n\t\t@current_menu = 'products'\r\n\r\n\t\tif params[:select]\r\n\t\t\tif params[:delete]\r\n\t\t\t\t# you MUST manually move child nodes in an acts_as_tree up before calling\r\n\t\t\t\t# the destroy! method. Otherwise Rails will automatically go and delete all\r\n\t\t\t\t# the child nodes even before the selected nodes' 'before_destroy' callback\r\n\t\t\t\t# is triggered!\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tthe_cat = Category.find(k)\r\n\t\t\t\t\tthe_cat.move_children_up()\r\n\t\t\t\t\tCategory.destroy(the_cat.id)\r\n\t\t\t\tend\r\n\t\t\telsif params[:move_up]\r\n\t\t\t\t# We have to use a Hash as Array iterators do not like sparse indexing.\r\n\t\t\t\tselected_categories = Hash.new\r\n\t\t\t\tcat_index = Hash.new\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tc = Category.find(k)\r\n\t\t\t\t\tif selected_categories[c.parent_id].nil?\r\n\t\t\t\t\t\tselected_categories[c.parent_id] = Hash.new\r\n\t\t\t\t\tend\r\n\t\t\t\t\tselected_categories[c.parent_id][c.id] = c.sequence\r\n\t\t\t\t\tcat_index[c.id] = c\r\n\t\t\t\tend\r\n\t\t\t\tselected_categories.each do |i, parent|\r\n\t\t\t\t\t# Hash.sort converts the hash into a nested array before sorting; [0] = key, [1] = value.\r\n\t\t\t\t\t# Note that we only want the IDs which are contained in the index 'j'.\r\n\t\t\t\t\tparent.sort{|a,b| (a[1]<=>b[1])}.each do |j, the_sequence|\r\n\t\t\t\t\t\tcat_index[j].move_higher\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\telsif params[:move_down]\r\n\t\t\t\t# See comments for move_up above\r\n\t\t\t\tselected_categories = Hash.new\r\n\t\t\t\tcat_index = Hash.new\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tc = Category.find(k)\r\n\t\t\t\t\tif selected_categories[c.parent_id].nil?\r\n\t\t\t\t\t\tselected_categories[c.parent_id] = Hash.new\r\n\t\t\t\t\tend\r\n\t\t\t\t\tselected_categories[c.parent_id][c.id] = c.sequence\r\n\t\t\t\t\tcat_index[c.id] = c\r\n\t\t\t\tend\r\n\t\t\t\tselected_categories.each do |i, parent|\r\n\t\t\t\t\t# Note order of b/a is swapped to move down. This and move_lower instead of move_higher\r\n\t\t\t\t\t# is the only difference between this and the move_up code above.\r\n\t\t\t\t\tparent.sort{|a,b| (b[1]<=>a[1])}.each do |j, the_sequence|\r\n\t\t\t\t\t\tcat_index[j].move_lower\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\texpire_fragment(:controller => :products, :action => :home, :part => 'category_menu')\r\n\t\tend\r\n\r\n\t\t@root_cat = Category.find(1)\r\n\tend",
"def update_magento_category\n self.stores.each do |store|\n response = API::SOAP::Catalog::Category.update(self, store)\n\n unless response.success?\n errors.add(:base, response.body[:faultstring])\n return false\n end\n end\n\n self.sync_needed = false\n return true\n end",
"def update_hierarchy(top_node, retailer)\n @categories_to_save = []\n @translations_to_save = []\n @retailer = retailer\n traverse(top_node, 1, 1)\n \n # In a transaction, i.e. all of these must complete successfully, otherwise nothing is saved or deleted\n ActiveRecord::Base.transaction do\n current_categories = ProductCategory.where(:retailer => retailer)\n if current_categories.size >= 50 \n diff = current_categories.size - @categories_to_save.size\n if diff >= 0.5 * current_categories.size\n # If the number of categories has dropped by more than 50%\n raise BestBuyApi::InvalidFeedError, \"Current number of categories is #{current_categories.size} \" +\n \"while new number of categories is #{@categories_to_save.size}: categories will not be updated\"\n end\n end\n \n # delete the old categories for this retailer\n ProductCategory.where(:retailer => retailer).delete_all\n # save the new categories\n ProductCategory.import @categories_to_save\n # save all translations\n @translations_to_save.each do |key, english_name, french_name|\n I18n.backend.store_translations(:en, { key => {\"name\" => english_name} })\n I18n.backend.store_translations(:fr, { key => {\"name\" => french_name} })\n end\n end\n end",
"def edit\n # populates the category with the existing category assigned\n @categories = Category.all.map{ |c| [c.name, c.id] }\n end",
"def set_category\n end",
"def update\n Category.update(params[:category].keys, params[:category].values)\n\n redirect_to admin_ads_path\n end",
"def camaleon_category_order_on_active(plugin)\n end",
"def update_sort_key\n @item.sort_key = @sortable[@parent.sort_index]\n @item.reversed = @parent.reversed? ? -1 : 1\n end",
"def assign_categories_for_admin\n categories = Category.all\n @categories = []\n categories.each { |category| @categories << [category.name, category.id] }\n end",
"def merge!\n duplicate_category.each_with_children {|subcategory| swap_businesses_and_taggings(subcategory) }\n duplicate_category.destroy\n end",
"def update_positions\n unless request.post?\n head :ok\n return\n end\n\n @assignment = Assignment.find(params[:assignment_id])\n @annotation_categories = @assignment.annotation_categories\n position = 0\n\n params[:annotation_category].each do |id|\n if id != ''\n position += 1\n AnnotationCategory.update(id, position: position)\n end\n end\n end",
"def increment_category_sequence\n self.sequence = Category.count + 1\n end",
"def edit\n #locates the selected category\n @category = Category.find(params[:id])\n #creates a sorted array using all categories\n @all_categories = Category.all.sort {|x,y| x.name <=> y.name }\n #creates an empty hash\n @child_categories = []\n #call to function to remove children - a parent cannot be moved to be a child of its own child.\n remove_children(@all_categories, @category)\n #re-assigns the array minus the categories children\n @all_categories = @all_categories - @child_categories\n\n if(!@category.parent_id.nil?)\n @items_to_select = [Category.find(@category.parent_id)]\n else\n @items_to_select = nil\n end\n\n end",
"def change_order\r\n ids = params[:child_nodes]\r\n \r\n # Update\r\n ProductPackageNode.transaction do\r\n ids.each_index do |index|\r\n ProductPackageNode.update ids[index], :position => index + 1\r\n end\r\n end\r\n \r\n render :nothing => true\r\n end",
"def index\n @categories = Category.all.sort\n end",
"def modify_category(categories)\n begin\n puts Rainbow(\"Current categories: #{categories.join(', ')}\").whitesmoke\n yield\n\n write_json(categories, \"Categories/cat\", \"Available categories are: #{categories.join(', ')}\")\n rescue StandardError\n puts \"There are no categories to delete\"\n end\nend",
"def shift_up_orders()\n Feature.update_all('\"order\" = \"order\" - 1', '\"order\" > '+order.to_s)\n end",
"def set_categories\r\n @categories = Category.where('courses_count > 0').order(:name)\r\n end",
"def update\n respond_to do |format|\n category_params = params[:category]\n if category_params\n category_params[:male_index] = 0 if category_params[:male_index].nil?\n category_params[:female_index] = 0 if category_params[:female_index].nil?\n end\n if category_params.nil? || @category.update_attributes(category_params)\n save_curated_items(@category)\n format.js\n format.html { redirect_back(categories_path, notice: category_params ? 'Category was successfully updated.' : '') }\n format.json { head :no_content }\n else\n set_flash_messages_from_errors(@category)\n format.js\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n json_update(category,category_params, Category)\n end",
"def sorted_by_frequency\n @categories.sort { |a, b| b[1] <=> a[1] }\n end",
"def list_categories\n list_categories_button\n wait_for_ajax\n self.class.class_eval { include AddRemoveCategories }\n end",
"def update_order\n if params[:product]\n params[:product].each_with_index do |id,index|\n Product.find(id).update_attribute(:position,index)\n end\n elsif params[:categorization]\n params[:categorization].each_with_index do |id,index|\n Categorization.find(id).update_attribute(:position,index)\n end\n end\n respond_to do |format|\n format.js { render :text => 'Order successfully updated!' }\n end\n end",
"def update\n @categorization = Categorization.find(params[:id])\n @categories = category_list\n respond_to do |format|\n if @categorization.update_attributes(params[:categorization])\n format.html { redirect_to(admin_categorization_path(@categorization), :notice => 'Categorization was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @categorization.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @categories = Category.includes(:topic).order('topics.order', :order).all\n end",
"def after_update(category)\r\n expire_cache_for(category)\r\n end",
"def set_categories\n @categories = Category.all\n end",
"def touch_category\n self.category.touch\n end",
"def after_update(category)\r\n expire_cache_for(category)\r\n end",
"def save_hot_products_by_category\r\n Subcategory.fill_all_subcategories_of_category(params[:category][:fields][1])\r\n end",
"def sort_by_category\n @category = Category.find(params[:id])\n\n @products = @category.products\n end",
"def pushStatsOrder(iLstLocations, iLstObjects, iLstCategories)\n setupBackend do\n @BackendInstance.put_new_stats_order(DateTime.now, iLstLocations, iLstObjects, iLstCategories, STATS_ORDER_STATUS_TOBEPROCESSED)\n end\n end",
"def sort\n notice = 'Categories successfully sorted.'\n error = 'Could not sort Categories.'\n \n begin \n ShopCategory.sort(CGI::parse(params[:categories])[\"categories[]\"])\n \n respond_to do |format|\n format.html {\n redirect_to admin_shop_products_path\n }\n format.js { render :text => notice, :status => :ok }\n format.json { render :json => { :notice => notice }, :status => :ok }\n end\n rescue\n respond_to do |format|\n format.html {\n flash[:error] = error\n redirect_to admin_shop_products_path\n }\n format.js { render :text => error, :status => :unprocessable_entity }\n format.json { render :json => { :error => error }, :status => :unprocessable_entity }\n end\n end\n end",
"def handle_categories(category_names)\n return if !self.undergrad? || category_names.nil?\n self.categories = [] # eliminates any previous interests so as to avoid duplicates\n category_array = []\n category_array = category_names.split(',').uniq if category_names\n category_array.each do |cat|\n self.categories << Category.find_or_create_by(name: cat.downcase.strip)\n end\n end",
"def set_category\n\t\tself.category_type=\"Main\"\n\t\tself.save\n\tend",
"def update(request)\n if options[:multiple]\n cats = request.every(options[:category])\n cats.each do |cat|\n if cat || options[:nils]\n @categories[cat] ||= 0\n @categories[cat] += 1\n end \n end\n \n else\n cat = @categorizer.call(request)\n if cat || options[:nils]\n @categories[cat] ||= 0\n @categories[cat] += 1\n end\n end\n end",
"def update_keyword_categories(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/KeywordCategories\")\n results = put(uri,data,generate_objects)\n end",
"def index\n @parent_categories = ParentCategory.all.order(:display_order)\n end",
"def update\n # update attribute\n if @category.update_attributes(category_params)\n # flash message\n flash.now[:success] = \"更新完了しました。\"\n # get category data\n all_categories\n else\n render 'edit'\n end\n end",
"def update!(**args)\n @category_name = args[:category_name] if args.key?(:category_name)\n end",
"def update\n \n #My product belongs_to category relationship won't work so I made this so when I update it reflects changes\n category_name = set_category.name\n Product.all.each do |product|\n product.category = category_params[:name] if product.category == category_name\n product.save\n end\n \n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n if @auction_category.update_category!(auction_category_params, params[:auction_category][:attribute_ids])\n flash_msg('success', '修改分类成功!', 'index')\n end\n rescue Exception => e\n flash['danger'] = '修改分类失败!#{error_msg(@auction_category)}'\n return redict_to action: 'edit', id: @auction_category.id\n end\n end",
"def update\n @category = Category.find(params[:id])\n @rollover = @category.rollover\n \n unless params[:category][:parent_id].empty?\n @parent = Category.find(params[:category][:parent_id])\n @category.move_to_child_of(@parent) if @parent != @category.parent\n end\n \n respond_to do |format|\n if @category.update_attributes(params[:category]) and ( @rollover.update_attributes(params[:rollover]) unless @category.is_home?)\n flash[:notice] = 'Category was successfully updated.'\n format.html { redirect_to(@category) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @categoria = Categorium.order(\"categoria\")\n end",
"def set_to_ordered\n self.status = \"ordered\"\n self.save\n end",
"def sort_categories\n #loop to sort categories parents and children\n for cat in @all_categories\n #if category parent id == nill then hash = current category else if parent id of category = nil then parent id hash is nil\n if(cat.parent_id.nil?)\n @all_categories_hash[0] = [cat]\n else\n if(@all_categories_hash[cat.parent_id].nil?)\n @all_categories_hash[cat.parent_id] = []\n end\n @all_categories_hash[cat.parent_id].push(cat)\n end\n end\n #Sort loop for categories\n for key in @all_categories_hash.keys\n @all_categories_hash[key].sort!{|x,y| x.name <=> y.name}\n end\n end",
"def update_news_article_category_counter_cache\n if !frozen? && @old_category_id && self.new_category_title.blank?\n NewsArticleCategory.decrement_counter(:news_articles_count, @old_category_id)\n NewsArticleCategory.increment_counter(:news_articles_count, self.news_article_category_id)\n end\n end",
"def save\n check_category! if self.category\n super\n end",
"def update_order\n update_positions params[:sorted_ids]\n render nothing: true\n end",
"def set_categories\n\t\t@categories = Category.all\t\n\tend",
"def edit\n \t@category = Category.find(params[:id])\n @categories = Category.all.order(:category_name)\n end",
"def merge\n @category_to_merge = Category.find(params[:id])\n @other_categories = Category.find(:all, :order => 'name asc')\n @other_categories.delete(@category_to_merge)\n end",
"def update_factcat\n cat = Category.find(self.category_id)\n self.factcat_id = cat.get_factcat_from_category.id\n self.save!\n end",
"def set_categories\r\n csv = CSV.readlines(File.join('data', 'categories.csv'))\r\n @categories = csv.each_with_object({}) do |(key, val), hsh|\r\n hsh[key] = val\r\n end\r\n\r\n @items.each do |i|\r\n i.category = @categories[i.category]\r\n end\r\nend",
"def categories\n self.button(:id=>\"entity_group_permissions\").click\n self.button(:text=>\"Categories\").click\n self.wait_until { self.text.include? \"Assign a category\" }\n self.class.class_eval { include AddRemoveCategories }\n end",
"def original_order\n end",
"def set_category_window(window)\n @category_window = window\n end",
"def index\n @categories = Category.all.order('name ASC')\n end",
"def sort_categories\n for cat in @all_categories\n if(cat.parent_id == nil)\n @all_categories_hash[0] = [cat]\n else\n if(@all_categories_hash[cat.parent_id] == nil)\n @all_categories_hash[cat.parent_id] = []\n end\n @all_categories_hash[cat.parent_id].push(cat)\n end\n end\n for key in @all_categories_hash.keys\n @all_categories_hash[key].sort!{|x,y| x.name <=> y.name}\n end\n end",
"def categories=(value)\n @categories = value\n end",
"def update\n @categorias = CategoriaObjeto.all.order(:nome).map { |categoria| [categoria.nome, categoria.id]}.prepend(['Selecione uma categoria', 0])\n \n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_position\n if scope_changed?\n decrement(all_next_was)\n if range.include?(position)\n reorder(position_was, position)\n else\n add_to_bottom\n end\n else\n if range.include?(position)\n reorder(position_was, position)\n else\n self.position = position_was # Keep original position\n end\n end\n end",
"def update_positions\n assignment = Assignment.find(params[:assignment_id])\n position = 0\n\n params[:annotation_category].compact.each do |id|\n annotation_category = assignment.annotation_categories.find_by(id: id)\n next if annotation_category.nil?\n\n annotation_category.update(position: position)\n position += 1\n end\n\n head :ok\n end"
] |
[
"0.6584422",
"0.6371153",
"0.62728024",
"0.6264131",
"0.626053",
"0.62382644",
"0.60091114",
"0.59790504",
"0.5962407",
"0.582009",
"0.5813241",
"0.5813241",
"0.5769764",
"0.57682264",
"0.5711186",
"0.5660341",
"0.56225234",
"0.5621562",
"0.55066544",
"0.5427976",
"0.54192454",
"0.5415255",
"0.53882164",
"0.537798",
"0.53741115",
"0.5373611",
"0.53704876",
"0.53646725",
"0.53608924",
"0.5354196",
"0.53390497",
"0.532722",
"0.5325439",
"0.53128314",
"0.5282885",
"0.5281707",
"0.5278264",
"0.52773875",
"0.5268498",
"0.5251465",
"0.52413344",
"0.52411944",
"0.52369523",
"0.5223473",
"0.52009296",
"0.51967007",
"0.51423264",
"0.51305884",
"0.5130515",
"0.51260394",
"0.5114773",
"0.5111917",
"0.5110511",
"0.5090696",
"0.5088761",
"0.50792664",
"0.5067126",
"0.5066845",
"0.50602806",
"0.5059491",
"0.50583184",
"0.5053212",
"0.5033404",
"0.50333166",
"0.5029982",
"0.50041217",
"0.5001847",
"0.50003856",
"0.49988878",
"0.49982",
"0.49888787",
"0.49869972",
"0.49868843",
"0.49854898",
"0.4984979",
"0.49776098",
"0.49768767",
"0.49740958",
"0.49713716",
"0.4968533",
"0.49661335",
"0.4965145",
"0.49643955",
"0.49619222",
"0.49613464",
"0.49610204",
"0.49576357",
"0.49555913",
"0.4951162",
"0.49414867",
"0.49402672",
"0.49393427",
"0.49381047",
"0.49355704",
"0.49270883",
"0.49259314",
"0.49213418",
"0.4920341",
"0.4919821",
"0.49196887"
] |
0.5757854
|
14
|
Show the details of an individual category
|
def show
@category = Documents::Category.find(params[:id])
render layout: false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @category = @item.category\n end",
"def show # display one category\n @category = Category.find(params[:id])\n end",
"def show\n @category = Category.find(params[:category_id])\n end",
"def show\n @category = Category.find(params[:id])\n end",
"def show\n @category = Category.find(params[:id])\n end",
"def show\n @category = Category.find(params[:id])\n end",
"def show\n # now in get_category method\n \t# @category = Category.find(params[:id])\n\n end",
"def show\n @catogory = Catogory.find(params[:id])\n end",
"def show_category\n category_id == nil ? \"\" : category.category_name\n end",
"def show\n @title = 'Categories'\n @recipes = @category.recipes.each{|c| [c.name, c.id] }\n end",
"def show\n\t\t@category = Category.find(params[:id])\n\t\t@sub_categories = @category.sub_categories\n\tend",
"def show\n @category = Category.find(params[:id])\n @recipes = Recipe.find(:all, :conditions => ['category_id = ?', @category.id], :order => 'title')\n\n @movies = Movie.find(:all, :conditions => ['category_id = ?', @category.id], :order => 'title, year')\n @movietotal = Movie.catcount(@category.id)\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end",
"def category\n @data['category']\n end",
"def get_category_info\n category = self.category_id\n return Category.find_by_id(category)\n end",
"def show\n cat = @cathegory.sub_cathegories.map(&:id) << @cathegory.id\n @articles = Article.where(cathegory_id: cat)\n\n end",
"def show\n @o_single = Category.find(params[:id])\n end",
"def show\n @title = t(\"h2.categories\")\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end",
"def show\n @products_category = ProductsCategory.find(params[:id])\n @pagetitle = \"Product categories - #{@products_category.category}\"\n end",
"def show\n # Find the category belonging to the given id\n @clase_unit = ClaseUnit.find(params[:id])\n # Grab all sub-categories\n @clase_units = @clase_unit.subcategorias\n # We want to reuse the index renderer:\n render :action => :index\n end",
"def category\n data['category']\n end",
"def category\n client.categories.find(data[\"categoryId\"])\n end",
"def show\n @category = Category.friendly.find(params[:id])\n @title = @category.name\n @description = @category.meta_desc if @category.meta_desc.present?\n @keywords = @category.meta_key if @category.meta_key.present?\n @categories = Category.all\n @products = Product.where(category_id: @category, visible: 1).paginate(:page => params[:page], :per_page => 12).order(\"sort_top = 1 DESC\").order(name: :asc)\n end",
"def show\n @category_id = params[:category_id]\n @categories_associated = @product_type.category\n end",
"def show\n authorize! :read, @category\n end",
"def category\n Category.find(params[:id])\n end",
"def show\n @category = Category.find(params[:id])\n @articles = @category.articles\n # Automatically looks for and renders views/categories/show.html.erb\n end",
"def show\n @category = Category.find(params[:id])\n @title = \"Категория: \" << @category.title\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def show\n @products = @category.products\n end",
"def show\n @category = Category.find(params[:id]);\n @posts = @category.posts\n end",
"def category_name\n category.name\n end",
"def show\n\t @category = Category.find(params[:id])\n\n\t respond_to do |format|\n\t\tformat.html # show.html.erb\n\t\tformat.json { render json: @category }\n\t end\n\tend",
"def show\n @category = @current_user.categories.find_by_id(params[:id])\n add_breadcrumb I18n.t('layout.categories.title'), categories_path\n add_breadcrumb I18n.t('layout.categories.name'), category_path(@category.id)\n\tif @category \n\t \n\t\trespond_to do |format|\n\t\t format.html # show.html.erb\n\t\tend\n\telse\n\t\tredirect_to(categories_path)\n\tend\n end",
"def category\n @ole.Category\n end",
"def get_category\n \t\t@category = Category.find(params[:category_id])\n end",
"def show\n if params[:id].to_i < 1\n pl = Permalink.find_by_url(params[:id])\n @category = pl ? pl.linkable : Category.first\n else\n @category = Category.find(params[:id])\n end\n if @category.public || current_user\n # Fetch Postings\n @items = @category.categorizables.descend_by_updated_at.paginate(:page => params[:page], :per_page => POSTINGS_PER_PAGE)\n # Append other 'categorizable' models to @items here...\n else\n flash[:error] = t(:this_category_is_not_public,:name => @category.name)\n redirect_to categories_path\n end\n end",
"def show\r\n @ccategory = Ccategory.find(params[:id])\r\n @products = @ccategory.getproducts\r\n @pcategory = Pcategory.find_by_title(@ccategory.ptitle)\r\n @cart = current_cart\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @ccategory }\r\n end\r\n end",
"def show\n authorize! :read, @category\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def category_lister\n Category.all.each_with_index do |cat, idx|\n puts \"#{idx + 1}: #{cat.name}\"\n end\n end",
"def get_category id\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.get CATEGORIES, id )\n\t\t\t\tend",
"def get_category\n @category = Category.find(params[:id])\nend",
"def show\r\n @category = Category.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @category }\r\n end\r\n end",
"def show\n if params[:category_id]\n @category = Category.find(params[:category_id])\n #category = Category.find(params[:category_id])\n @tutorials = Tutorial.where(:category_id => @category)\n else\n @tutorials = Tutorial.all\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def categoryname\n\t\t\tcategory.category_name\n\t\tend",
"def category_name\n category = Category.find_by_id(self.category_id)\n return category.name\n end",
"def show\n @post_category = Post::Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post_category }\n end\n end",
"def show\n @category = current_mall.categories.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def show\n @category =\n Category.includes(:companies).find(params[:id])\n if @category\n @keyword = String.new\n @keyword << @category.name << \" \"\n @coms = @category.companies.paginate(:page => params[:page],\n :per_page => 15)\n unless @category.leaf?\n @children = @category.children.sort! {|a,b| a.name<=>b.name}\n @children.each do |child|\n @keyword << child.name << \" \"\n end\n end\n if @category.child?\n @category.ancestors.each do |ac|\n ariane.add ac.name, category_path(ac)\n end\n end\n unless @category.companies.blank?\n @json = @category.companies.to_gmaps4rails\n @coms_max = @category.companies.maximum(:updated_at)\n end\n ariane.add @category.name, @category\n else\n flash.now[:error] = \"Category not found.\"\n end\n end",
"def show\n @p_cats = PCat.all\n end",
"def show\n @cate_item = CateItem.find(params[:id])\n end",
"def show\n @category = Category.find(params[:id])\n\n # respond_to do |format|\n # format.html # show.html.erb\n # format.json { render json: @category }\n # end\n end",
"def category_name \n\tself.category.name \n end",
"def index\n @cathegories = Cathegory.all\n end",
"def by_category\n @category = Category.roots.find_by_slug(params[:category])\n raise ListingException, \"missing category\" if @category.blank?\n @subcategory = @category.children.find_by_slug(params[:subcategory]) if params[:subcategory].present?\n terms = [ListingFilter.category(@subcategory.present? ? @subcategory.id : @category.id), ListingFilter.state('active')]\n query = {filter: {bool: {must: terms}}, sort: {id: \"desc\"}}\n @listings = Listing.search(query).page(page).per(per).records\n\n @subcategories = @category.children.with_listings\n\n @title = [@category.name, @subcategory.try(:name)].compact.join(\" : \") + \" | Category\"\n\n respond_to do |format|\n format.html { render(action: :index, layout: !request.xhr?) }\n end\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def show\n @page_title = params[:id].capitalize\n @things = Thing.paginate(:page => page, :per_page => Setting.articles_per_page, :order => \"created_at DESC\", 'categories.name' => params[:id])\n @sources = Source.all('categories.name' => params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end",
"def show\n @category = Category.find_by(slug: params[:id])\nend",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end",
"def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end",
"def index\n ##########\n @category = current_user.category\n end",
"def show_category_name\n return @show_category_name\n end",
"def show\n @pro_category = params[:category_id]\n end",
"def index\n @category = Category.all\n end",
"def show\n @echocategory = Echocategory.friendly.find(params[:id])\n @echocategories = Echocategory.all # list all echocategories on echocategory page\n end",
"def show\n @categorization = Categorization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @categorization }\n end\n end",
"def show\n @category = Category.find(params[:id])\n @products = Product.find :all, conditions: [\"category_id = ?\",params[:id]]\n end",
"def show\n render json: @category\n end",
"def show\n @categories = Category.order(\"name ASC\")\n end",
"def show\n if(params[:category_id].nil?)\n @category = @product.categories.first\n else\n @category = Category.find(params[:category_id])\n end \n end",
"def show\n @category = Category.find(params[:id])\n @products = Product.find_by_category_id(params[:id])\n end",
"def show\n @activity = Activity.find(params[:id])\n @profile = current_user.profile\n @categories = Category.all\n end",
"def show\n @pcategory = Pcategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pcategory }\n end\n end",
"def show\n @post_category = PostCategory.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post_category }\n end\n end",
"def show\n @images = @category.images\n end",
"def index\n @cp_categories = Category.all\n @title = \"Categories\"\n end",
"def show\n @admin_section = true\n @course_category = CourseCategory.find(params[:id])\n @page_title = \"Course Category Details\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @course_category }\n end\n end",
"def load_category\n @category = Category.friendly.find(params[:id])\n end",
"def get_category\n current_category = self.category.name\n end",
"def getCategory( category_id)\n params = Hash.new\n params['category_id'] = category_id\n return doCurl(\"get\",\"/category\",params)\n end",
"def show\n @category = Category.find(params[:id])\n \n \n # taken from pages#home action\n @default_post_offset = APP_CONFIG['default_post_offset']\n @posts = @category.posts.published.recent.limit(5)\n @tips = @category.tips.published.recent.limit(3)\n @questions = @category.questions.published.recent.limit(3)\n @top_tips = Tip.published.recent.limit(3)\n @events = @category.events.published.limit(3)\n @product_tests = @category.product_tests.published.recent.limit(3)\n @top_posts = Post.published.recent.limit(5)\n @top_product_tests = ProductTest.published.recent.limit(3)\n @tags = ActsAsTaggableOn::Tag.all\n @displayed_posts = @posts.length\n @remaining_posts = Post.count - @displayed_posts\n \n add_breadcrumb @category.name, :category_path\n respond_with\n end",
"def show\r\n @administration_categories = Category.where('parent_id=0').where('active=1')\r\n @current_category = Category.find(params[:id])\r\n end",
"def show\n @kategory = Kategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kategory }\n end\n end",
"def show\n @recipe_category = RecipeCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_category }\n end\n end",
"def show\n @cover_cat = CoverCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cover_cat }\n end\n end",
"def show\n @pcategory = Pcategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pcategory }\n end\n end",
"def find_category\n @category = Category.find(params[:category_id])\n end",
"def category()\n sql = \"SELECT * FROM categories WHERE id = $1 ORDER BY name;\"\n values = [@category_id]\n sql_result = SqlRunner.run(sql, values)\n return Category.new(sql_result[0])\n end",
"def name\n description_category\n end"
] |
[
"0.79321426",
"0.7852637",
"0.7715413",
"0.77126575",
"0.7693542",
"0.7693542",
"0.7614634",
"0.75701904",
"0.7492496",
"0.7393042",
"0.7386335",
"0.7377195",
"0.73524606",
"0.73068535",
"0.7292557",
"0.7274844",
"0.72538275",
"0.7251925",
"0.7207638",
"0.72055984",
"0.7178107",
"0.7167977",
"0.71469796",
"0.71465516",
"0.70968115",
"0.7077766",
"0.70732874",
"0.70470864",
"0.7045982",
"0.7039268",
"0.7010936",
"0.7009578",
"0.7006046",
"0.69856954",
"0.6983924",
"0.6969461",
"0.69619936",
"0.6961126",
"0.6961126",
"0.6961126",
"0.6961126",
"0.6961126",
"0.6961126",
"0.6961126",
"0.6926675",
"0.6916452",
"0.69086134",
"0.6907197",
"0.6900867",
"0.68882895",
"0.6887637",
"0.68845",
"0.68745124",
"0.6866504",
"0.6860406",
"0.6859569",
"0.6836611",
"0.68278223",
"0.6822344",
"0.6817436",
"0.6809536",
"0.6809536",
"0.6809536",
"0.6809536",
"0.6809536",
"0.6809536",
"0.6804135",
"0.68005556",
"0.6800539",
"0.6800539",
"0.67995226",
"0.67956156",
"0.6785585",
"0.67753005",
"0.67515",
"0.6747958",
"0.6746413",
"0.6730672",
"0.6723007",
"0.6720506",
"0.67154044",
"0.67080927",
"0.6707071",
"0.67044926",
"0.6695941",
"0.6695049",
"0.6694904",
"0.66915476",
"0.6688847",
"0.66883886",
"0.6686048",
"0.6682093",
"0.6678322",
"0.6671787",
"0.6671402",
"0.6667744",
"0.66631496",
"0.666253",
"0.66543674",
"0.665407"
] |
0.7041066
|
29
|
Show the category creation form
|
def new
@journals = journal_list
@category = Documents::Category.new
render layout: false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def htmlcreate\n @category = Category.new(category_params)\n if @category.save\n flash[:success] = t('admin.categories.create.created')\n redirect_to admin_categories_path\n else\n render 'new'\n end\n end",
"def create\n @category_form_url = forum_categories_path\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n if @category.save\n redirect_to editor_category_path(@category), notice: \"Category was successfully created.\"\n else\n render :new\n end\n end",
"def create\n\t\tif @category.save\n\t\t\tflash[:notice] = \"Category was created successfully!\"\n\t\t\tredirect_to @category\n\t\telse\n\t\t\tflash[:error] = get_all_errors\n\t\t\trender 'new'\n\t\tend\n\tend",
"def create\n \t@category = Category.new(category_params)\n \tif category.save\n \t\tredirect_to category_show\n \telse\n \t\trender :new\n \tend\n end",
"def create\n\t @category = Category.new(params[:category])\n\n\t respond_to do |format|\n\t\tif @category.save\n\t\t format.html { redirect_to [:admin, @category], notice: 'Categoria creada exitosamente.' }\n\t\telse\n\t\t format.html { render action: \"new\" }\n\t\tend\n\t end\n\tend",
"def create\n @category = Category.new(category_params)\n\n if @category.save\n redirect_to [:admin, :categories], notice: 'Category created!'\n else\n render :new\n end\n\n end",
"def create\n @category = Category.create(params[:category])\n \n if @category.save\n redirect_to categories_path\n else\n render 'new'\n end\n \n end",
"def create\n\t\t@category = Category.new(params[:category])\n\t\t@category.save\n\t\tredirect_to :action => \"index\"\n\tend",
"def create\n @category = Category.new(category_params)\n if @category.save \n redirect_to categories_url, notice: 'Category was successfully created.'\n else\n render :new\n end\n end",
"def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_categories_url, notice: 'Добавлена новая категоря.' }\n else\n format.html { render :new }\n end\n end\n end",
"def new\n\t\t@category = Category.new\n\tend",
"def new\n\t\t@category = Category.new\n\tend",
"def create\n if admin\n @category = Category.new(category_params)\n\n if @category.save\n redirect_to @category\n else\n render 'new'\n end\n else\n redirect_to categories_path\n end\n end",
"def new\n @category = Category.new\n end",
"def new\n @category = Category.new\n end",
"def new\n @category = Category.new\n end",
"def new\n @category = Category.new\n end",
"def new\n @category = Category.new\n end",
"def new\n @category = Category.new\n end",
"def new\n @category = Category.new\n end",
"def new\n @category = Category.new\n end",
"def create\n @o_single = Category.new(params[:category])\n if @o_single.save\n flash[:notice] = t(\"general.successfully_created\")\n redirect_to categories_path\n else\n render :action => 'new'\n end\n end",
"def create_category\n @category = TestCategory.new(params[:category])\n @category.save\n @categories = TestCategory.find(:all)\n redraw 'categories'\n end",
"def new\n @cat = Category.new\n end",
"def create\n @cat = Category.new(cat_params)\n if @cat.save\n flash[:success] = \"successfully created new category #{@cat.name}.\"\n redirect_to dashboard_path\n else\n flash[:error] = @cat.errors.messages\n render :new, status: :bad_request\n end\n return\n end",
"def create\n\t\t@category = Category.new(category_params)\n\t\t@category.user = current_user\n\t\tif(category_params[:titulo] == \"Geral\")\n\t\t\t@category.titulo = \"Geral (nova)\"\n\t\tend\n\t\trespond_to do |format|\n\t\t\tif @category.save\n\t\t\t\tformat.html { redirect_to @category, notice: 'Category criada com sucesso!' }\n\t\t\t\tformat.json { render :show, status: :created, location: @category }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @category.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_dashboard_categories_path, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category =Category.new(category_params)\n\n if @category.save\n flash[:success] = \"Category Created\"\n\n #go back to home page\n redirect_to root_path\n\n else\n #if category does not save we want to output some errors\n # we have already got a new.html.erb\n # we want a new form\n render \"new\"\n\n end\n \n \n end",
"def new\n \t@category = Category.new\n end",
"def create\n admins_only do\n @category = Category.new(category_params)\n @category.name = params[:category][:name].to_s.camelcase\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to category_index_path, notice: 'Category was successfully created.' }\n format.json { render action: 'index', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n category = Documents::Category.create(category_params)\n if category.save\n redirect_to categories_path\n else\n redirect_to categories_path, alert: I18n.t('admin.categories.validation_error')\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_category_path(@category), notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n flash[:notice] = \"Category successfully created\" if @category.save\n redirect_to categories_path\n end",
"def new\n\t @category = Category.new\n\n\t respond_to do |format|\n\t\tformat.html # new.html.erb\n\t end\n\tend",
"def new\n \t@category =Category.new\n end",
"def new\n @title = \"Upload Categories\"\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_url, notice: 'Category was successfully created.' }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Category was successfully created.'\n format.html { redirect_to(categories_url) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to adminpanel_categories_path, notice: \"Категория #{@category.name} успешно создана\" }\n format.json { render :show, status: :created, location: adminpanel_categories_path }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Category was successfully created.'\n format.html { redirect_to(admin_categories_path) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @categoria = Categoria.new\n\n render :layout => false\n end",
"def create\n @categoria = Categoria.new(params[:categoria])\n\n @categoria.save\n render :layout => false\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:success] = 'Category was successfully created.'\n format.html { redirect_to(admin_categories_url) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n flash[:error] = 'Category could not be created. See errors below.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @cp_category = Category.new(cp_category_params)\n\n respond_to do |format|\n if @cp_category.save\n format.html { redirect_to @cp_category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @cp_category }\n else\n format.html { render :new }\n format.json { render json: @cp_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to [:admin, @category], notice: t('messages.created', model:Category.model_name.human) }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n @title = \"Neue Kategorie erstellen\"\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_path, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to edit_dashboard_category_path(@category), notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @categorization = Categorization.new(params[:categorization])\n @categories = category_list\n respond_to do |format|\n if @categorization.save\n format.html { redirect_to(admin_categorization_path(@categorization), :notice => 'Categorization was successfully created.') }\n format.xml { render :xml => @categorization, :status => :created, :location => @categorization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @categorization.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to management_categories_path }\n format.json { render json: @category, status: :created }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @categ = Categ.new(categ_params)\n\n respond_to do |format|\n if @categ.save\n format.html { redirect_to @categ, notice: 'Categ was successfully created.' }\n format.json { render :show, status: :created, location: @categ }\n else\n format.html { render :new }\n format.json { render json: @categ.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @categories = Category.all\n\n @category = Category.create(category_params)\n flash[:notice]=\"Catégorie créer avec succès!!!\"\n end",
"def new\n @category = Category.new\nend",
"def create\n @category = current_user.categories.build(category_params)\n\n if @category.save\n redirect_to(@category, notice: \"Journal was successfully created.\") and return\n render :show, status: :created, location: @category\n else\n flash.now[:messages] = @category.errors.full_messages[0]\n render :show_form\n end\n end",
"def create\n @categoria = Categoria.new(categoria_params)\n\n if @categoria.save\n flash[:success] = 'Se inserto exitosamente la nueva categoría.'\n redirect_to categorias_path\n else\n render 'new'\n end\n end",
"def create\n @admin_category = Admin::Category.new(admin_category_params)\n\n respond_to do |format|\n if @admin_category.save\n format.html { redirect_to @admin_category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @admin_category }\n else\n format.html { render :new }\n format.json { render json: @admin_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\r\n\t\tif params[:create]\r\n\t\t\t@root_category = Category.find(:first, :conditions => 'parent_id IS NULL') || Category.create\r\n\t\t\tparams[:category][:parent_id] = @root_category.id unless !params[:category][:parent_id].empty?\r\n\t\t\t@category = Category.new(params[:category])\r\n\t\t\tif @category.save\r\n\t\t\t\texpire_fragment(:controller => :products, :action => :home, :part => 'category_menu')\r\n\r\n\t\t\t\t# Requested after a usability review so people can add the description and SEO options\r\n\t\t\t\t# without having to click through. If you disagree with this then swap for the\r\n\t\t\t\t# commented-out code below.\r\n\t\t\t\tredirect_to(:action => :edit, :id => @category.id) and return true\r\n#\t\t\t\tflash.now[:notice] = 'Category successfully created'\r\n\t\t\telse\r\n\t\t\t\tflash.now[:notice] = 'Error creating category'\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\tredirect_to(:action => :list)\r\n\tend",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Kategoria została stworzona poprawnie.'\n format.html { redirect_to([:admin, @category]) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_path, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course_category = CourseCategory.new(params[:course_category])\n @admin_section = true\n @page_title = \"New Course Category\"\n \n respond_to do |format|\n if @course_category.save\n format.html { redirect_to(course_categories_url, :notice => 'Course category was successfully created.') }\n format.xml { render :xml => @course_category, :status => :created, :location => @course_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course_category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_path, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cat = Cat.new(catparams)\n if @cat.save\n redirect_to @cat\n else\n render 'new'\n end\n end",
"def create\n @category = Category.new(params.require(:category).permit(:name))\n respond_to do |format|\n if @category.save\n # render plain: \"#{@category.name} Category was successfully created.\"\n format.html { redirect_to \"/categories/new\", notice: \"Category was successfully created.\" }\n else\n format.html { redirect_to \"/categories/new\", notice: \"Category wasn't successfully created.\" }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to root_path, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n flash.alert = @category.errors.full_messages\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n if @category.save\n flash[:notice] = 'Categoria criada com sucesso.'\n else\n flash[:notice] = 'Erro ao salvar a categoria.'\n end\n\n # respond_to do |format|\n # if @category.save\n # format.html { redirect_to categories_path}\n # format.json { render json: @category, status: :created, location: @category }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @category.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if !logged_in?\n flash[:danger] = \"Not authorized\"\n redirect_to root_path\n return\n end\n @category = Category.new(category_params)\n\n if @category.save\n flash[:success] = \"Category was successfully created.\"\n redirect_to all_courses_path\n else\n render :new\n flash[:danger] = @course.errors.full_messages\n end\n end",
"def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n flash[:success] = 'Category was successfully created.'\n format.html do \n redirect_to admin_category_url(@category)\n end \n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n category = Category.create!(category_params)\n render json: {\n :html => render_to_string(\n :partial => \"setups/category\",\n :layout => false,\n :locals => {:category => category})\n }\n end",
"def uhook_create_category\n category = ::Category.new(params[:category])\n category.locale = current_locale\n category\n end",
"def create\n @category = PostCategory.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to cm_post_categories_url, notice: 'PostCategory was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = '分类创建成功.'\n format.html { redirect_to(cpanel_categories_url) }\n format.xml { render :xml => @menu, :status => :created, :location => @menu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html {\n redirect_to @category, notice: 'Category was successfully created.'\n }\n format.json {\n render json: @category, status: :created, location: @category\n }\n else\n format.html { render action: \"new\" }\n format.json {\n render json: @category.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to(@category, :notice => 'Category was successfully created.') }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to(@category, :notice => 'Category was successfully created.') }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n # category instance\n @category = Category.new\n end",
"def create\n @category = Category.new(category_params)\n @category.user = current_user\n\n respond_to do |format|\n if @category.save\n format.js { render :hide_form }\n else\n format.js { render :show_form }\n end\n end\n end",
"def create\r\n @administration_category = Category.new(params[:category])\r\n\r\n respond_to do |format|\r\n if @administration_category.save\r\n format.html { redirect_to [:administration, @administration_category], notice: 'Category was successfully created.' }\r\n format.json { render json: @administration_category, status: :created, location: @administration_category }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @administration_category.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n #render :text => rcadmin_category_params.inspect and return false\n @rcadmin_category = current_admin.categories.build rcadmin_category_params\n\n respond_to do |format|\n if @rcadmin_category.save\n\tflash[:notice] = 'Category was successfully created.'\n format.html { redirect_to rcadmin_categories_url }\n format.json { render action: 'show', status: :created, location: @rcadmin_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @rcadmin_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created!!' }\n format.json { render json: @category, status: :created, location: @category }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @o_single = Category.new\n end"
] |
[
"0.7819558",
"0.7788304",
"0.77093476",
"0.77029514",
"0.764286",
"0.75418794",
"0.7522999",
"0.74815714",
"0.7454076",
"0.74234504",
"0.7395623",
"0.7371044",
"0.7371044",
"0.73696023",
"0.7360548",
"0.7360548",
"0.7360548",
"0.7360548",
"0.7360548",
"0.7360548",
"0.7360548",
"0.7360548",
"0.73450583",
"0.7330856",
"0.7329457",
"0.7306087",
"0.7304123",
"0.7298683",
"0.7296139",
"0.72910583",
"0.7283225",
"0.7281873",
"0.7273023",
"0.7272873",
"0.72662026",
"0.72641194",
"0.7258886",
"0.7258686",
"0.7237844",
"0.721171",
"0.72063845",
"0.7205524",
"0.7203139",
"0.7188465",
"0.71807593",
"0.7174535",
"0.7174449",
"0.71633816",
"0.7158201",
"0.71545947",
"0.7144008",
"0.7141061",
"0.7137252",
"0.71323127",
"0.7130903",
"0.7128163",
"0.71220416",
"0.71179545",
"0.71143115",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71109486",
"0.71086407",
"0.71017814",
"0.7098868",
"0.70945406",
"0.7091396",
"0.70894617",
"0.7085378",
"0.70815647",
"0.7074555",
"0.70648605",
"0.70646894",
"0.7056586",
"0.7056586",
"0.7056586",
"0.7056586",
"0.7056586",
"0.7056193",
"0.70550776",
"0.70544595",
"0.704884",
"0.7039139",
"0.70316744",
"0.7015344",
"0.70051754",
"0.70051754",
"0.7004847",
"0.69878227",
"0.69817775",
"0.69812894",
"0.69808733",
"0.6980145"
] |
0.0
|
-1
|
Create a new category
|
def create
category = Documents::Category.create(category_params)
if category.save
redirect_to categories_path
else
redirect_to categories_path, alert: I18n.t('admin.categories.validation_error')
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def uhook_create_category\n category = ::Category.new(params[:category])\n category.locale = current_locale\n category\n end",
"def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend",
"def create_category(cat_name)\n category = Spree::Taxonomy.where(name: 'Categories').first\n category = Spree::Taxonomy.create(name: 'Categories') if category.nil?\n taxon = Spree::Taxon.find_by(name: cat_name, taxonomy_id: category.id)\n if taxon.present?\n spree_taxons.append(taxon)\n else\n taxon = Spree::Taxon.new(name: cat_name, taxonomy_id: category.id, parent_id: category.root.id)\n if taxon.save\n spree_taxons.append(taxon)\n else\n Rails.logger.info \"Error! #{taxon.errors.full_messages}\"\n end\n end\n end",
"def create\n @category = Category.create(params[:category])\n \n if @category.save\n redirect_to categories_path\n else\n render 'new'\n end\n \n end",
"def create_category(category_node)\n url = category_node.xpath(\"./a[1]/@href\").text\n name = url.sub(URL,'').delete('/')\n name_ru = category_node.xpath(\"./a[last()]\").text\n is_new = category_node.xpath(\"./a[2]/img[@class='img_new']\").any?\n Category.create(name: name, name_ru: name_ru, url: url, is_new: is_new)\n end",
"def create\n @o_single = Category.new(params[:category])\n if @o_single.save\n flash[:notice] = t(\"general.successfully_created\")\n redirect_to categories_path\n else\n render :action => 'new'\n end\n end",
"def create\n init = params[:category][:name][0]\n division = Division.find_by_name(params[:division_id].upcase)\n category_number = Category.create_number(params)\n @category = Category.new(category_params.merge(:code => (('%03d' % ((Category.last.code.to_i rescue 0)+1)))).merge(:division_id => division.id))\n if @category.save\n flash[:notice] = 'Category was successfully added'\n redirect_to categories_path\n else\n flash[:error] = @category.errors.full_messages\n render \"new\"\n end\n end",
"def createCategory(category_name)\n category = Category.create(name: category_name, complete: false)\n puts \"category #{category_name} created\"\n category\nend",
"def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@category = Category.new(params[:category])\n\t\t@category.save\n\t\tredirect_to :action => \"index\"\n\tend",
"def create\n @category = Category.new(category_params)\n @category.save\n end",
"def create\n @category = Category.new(category_params)\n @category.save\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Категория добавлена.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_url, notice: 'Category was successfully created.' }\n end\n end\n end",
"def create\n @post_category = Post::Category.new(params[:post_category])\n\n respond_to do |format|\n if @post_category.save\n format.html { redirect_to @post_category, notice: 'Category was successfully created.' }\n format.json { render json: @post_category, status: :created, location: @post_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Category was successfully created.'\n format.html { redirect_to(categories_url) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to Category.find(@category.category_id), notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if @category.save\n render json: @category, status: :created, location: @category\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end",
"def create_category(options = {})\n ActiveSupport::Deprecation.warn('create_category deprecated. Will be removed. Use community.categories.create.')\n self.categories.create options\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html {\n redirect_to @category, notice: 'Category was successfully created.'\n }\n format.json {\n render json: @category, status: :created, location: @category\n }\n else\n format.html { render action: \"new\" }\n format.json {\n render json: @category.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def create\n\t\t@category = Category.new(category_params)\n\t\t@category.user = current_user\n\t\tif(category_params[:titulo] == \"Geral\")\n\t\t\t@category.titulo = \"Geral (nova)\"\n\t\tend\n\t\trespond_to do |format|\n\t\t\tif @category.save\n\t\t\t\tformat.html { redirect_to @category, notice: 'Category criada com sucesso!' }\n\t\t\t\tformat.json { render :show, status: :created, location: @category }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @category.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @category = Category.new(params[:category]) \n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: t(:created_category_success)}\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n json_create(category_params, Category)\n end",
"def create\n @category = Category.new(params[:category])\n @title = \"Neue Kategorie erstellen\"\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_path, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n flash[:notice] = \"Category successfully created\" if @category.save\n redirect_to categories_path\n end",
"def create_category(opts = {})\n data, _status_code, _headers = create_category_with_http_info(opts)\n return data\n end",
"def create_category category_parent_id, category_name\n # Create a new category\n @server.call(\"call\", @session_id, \"catalog_category.create\", [category_parent_id, {:name => category_name, :is_active => 1, :include_in_menu => 1, :available_sort_by => \"*\", :default_sort_by => 0}])\n rescue XMLRPC::FaultException => exception\n return exception\n end",
"def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_categories_url, notice: 'Добавлена новая категоря.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to(@category, :notice => 'Category was successfully created.') }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to(@category, :notice => 'Category was successfully created.') }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created!!' }\n format.json { render json: @category, status: :created, location: @category }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t @category = Category.new(params[:category])\n\n\t respond_to do |format|\n\t\tif @category.save\n\t\t format.html { redirect_to [:admin, @category], notice: 'Categoria creada exitosamente.' }\n\t\telse\n\t\t format.html { render action: \"new\" }\n\t\tend\n\t end\n\tend",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_category(category_name)\n category = Category.new(:name => category_name)\n if category.save\n notify \"Created category: #{category_name}\"\n else\n error_string = \"Error creating category\"\n unless category.valid?\n category.errors.each { |k,v| error_string << \"\\n#{k}: #{v}\" }\n end\n notify error_string\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Category was successfully created.'\n format.html { redirect_to(admin_categories_path) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tif @category.save\n\t\t\tflash[:notice] = \"Category was created successfully!\"\n\t\t\tredirect_to @category\n\t\telse\n\t\t\tflash[:error] = get_all_errors\n\t\t\trender 'new'\n\t\tend\n\tend",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_path, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cat = Category.new(cat_params)\n if @cat.save\n flash[:success] = \"successfully created new category #{@cat.name}.\"\n redirect_to dashboard_path\n else\n flash[:error] = @cat.errors.messages\n render :new, status: :bad_request\n end\n return\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:success] = 'Category was successfully created.'\n format.html { redirect_to(admin_categories_url) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n flash[:error] = 'Category could not be created. See errors below.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_category\n @category = TestCategory.new(params[:category])\n @category.save\n @categories = TestCategory.find(:all)\n redraw 'categories'\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_path, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n admins_only do\n @category = Category.new(category_params)\n @category.name = params[:category][:name].to_s.camelcase\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to category_index_path, notice: 'Category was successfully created.' }\n format.json { render action: 'index', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def add_cat(name_en, name_nl)\n c = Category.new(name_en: name_en, name_nl: name_nl)\n c.save!\nend",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_dashboard_categories_path, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Category was successfully created.'\n format.html { redirect_to(@category) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to management_categories_path }\n format.json { render json: @category, status: :created }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = PostCategory.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to cm_post_categories_url, notice: 'PostCategory was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = current_user.categories.new(name: params[:name])\n if @category.save\n render \"create.json.jbuilder\", status: :created\n else\n render json: { errors: @category.errors.full_messages }, status: :unprocessable_entity\n end\n end",
"def create\n @category = @collection.categories.new(category_params)\n\n if @category.save\n ActionCable.server.broadcast 'categories',\n title: @category.title,\n collection_id: @category.collection_id\n head :ok\n else\n\n end\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to edit_dashboard_category_path(@category), notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_path, notice: 'Категория была успешно создана'}\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Kategoria została stworzona poprawnie.'\n format.html { redirect_to([:admin, @category]) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @cp_category = Category.new(cp_category_params)\n\n respond_to do |format|\n if @cp_category.save\n format.html { redirect_to @cp_category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @cp_category }\n else\n format.html { render :new }\n format.json { render json: @cp_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Category.create\n\n redirect_to admin_ads_path\n end",
"def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to adminpanel_categories_path, notice: \"Категория #{@category.name} успешно создана\" }\n format.json { render :show, status: :created, location: adminpanel_categories_path }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n auction_category = Auction::Category.new(auction_category_params)\n\n begin\n if auction_category.save_category!(params[:auction_category][:attribute_ids])\n flash_msg('success', '添加分类成功!', 'index')\n end\n rescue Exception => e\n flash_render('danger', \"添加分类失败!#{error_msg(auction_category)}\", 'new')\n end\n end",
"def create\n category = Category.create(category_params)\n\n \n if category\n render json:{\n status: :created,\n category: category}\n else\n render json: { status: 500 }\n end\n end",
"def create\n @category = Category.new(category_params)\n if @category.save \n redirect_to categories_url, notice: 'Category was successfully created.'\n else\n render :new\n end\n end",
"def new\n # category instance\n @category = Category.new\n end",
"def create\n\n # @category = Category.new(params[:category])\n @category = current_user.categories.build(params[:category])\n\n respond_to do |format|\n if @category.save\n # format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.html { redirect_to categories_path, notice: 'Pomyślnie utworzono kategorię.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n # format.html { render action: \"new\" }\n format.html { redirect_to categories_path, :flash => { :error => 'Nie udało się utworzyć kategorii' } }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @categories = Category.all\n\n @category = Category.create(category_params)\n flash[:notice]=\"Catégorie créer avec succès!!!\"\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_category_path(@category), notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def addCat()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n c = Category.new(name: params[:name])\n status = c.save\n error = \"\"\n if(c.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end",
"def create\n @category = Category.new(params[:category])\n\n if @category.save\n flash[:notice] = 'Categoria criada com sucesso.'\n else\n flash[:notice] = 'Erro ao salvar a categoria.'\n end\n\n # respond_to do |format|\n # if @category.save\n # format.html { redirect_to categories_path}\n # format.json { render json: @category, status: :created, location: @category }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @category.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @category = Category.new(params[:category].permit(:name, :category_id))\n\n if @category.save\n redirect_to [:admin, @category]\n end\n end",
"def create\n @category_form_url = forum_categories_path\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = current_mall.categories.new(params[:category])\n\n if @category.save\n render json: @category, status: :created\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end",
"def create\n @category = Category.new(category_params)\n authorize! :create, @category\n if @category.save\n render json: @category, status: :created\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end",
"def create\n @category = Category.new(category_params)\n @category.user_id = current_user.id\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: t('create.notice', name: t('activerecord.models.category')) }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post_category = PostCategory.new(params[:post_category])\n \n respond_to do |format|\n if @post_category.save\n format.html { redirect_to(@post_category, :notice => 'Category was successfully created.') }\n format.xml { render :xml => @post_category, :status => :created, :location => @post_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post_category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n @category.category_group_id ||= params[:category_group_id]\n\n respond_to do |format|\n if @category.save\n save_curated_items(@category)\n format.html { redirect_to(categories_path, notice: 'Category was successfully created.') }\n format.json { render json: @category, status: :created, location: @category }\n else\n set_flash_messages_from_errors(@category)\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category = Category.new(params[:category])\n @category.format_name = params[:category][:name].gsub(/ /, \"_\").downcase\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_scenic_spots_path, notice: 'Article was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@category = Category.new\n\tend",
"def new\n\t\t@category = Category.new\n\tend",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to root_path, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n flash.alert = @category.errors.full_messages\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @category = Category.new(category_params)\n @category.category = @category.category.strip\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n \n \n end",
"def create\n @category = Category.new(category_params)\n if @category.save\n redirect_to editor_category_path(@category), notice: \"Category was successfully created.\"\n else\n render :new\n end\n end",
"def create\n \t@category = Category.new(category_params)\n \tif category.save\n \t\tredirect_to category_show\n \telse\n \t\trender :new\n \tend\n end",
"def new\n \t@category =Category.new\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to [:admin, @category], notice: t('messages.created', model:Category.model_name.human) }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.81160194",
"0.79922956",
"0.79185677",
"0.7793888",
"0.7780137",
"0.76504683",
"0.7639943",
"0.7604499",
"0.7575602",
"0.7570226",
"0.7570197",
"0.7563525",
"0.7563525",
"0.7531577",
"0.7520709",
"0.7518989",
"0.7510849",
"0.75061625",
"0.75061625",
"0.75061625",
"0.75061625",
"0.75061625",
"0.7498464",
"0.74878716",
"0.7475418",
"0.74751306",
"0.7467286",
"0.74598575",
"0.7452464",
"0.7452353",
"0.74426985",
"0.7429094",
"0.7419631",
"0.7409714",
"0.7405502",
"0.7402482",
"0.7402482",
"0.73960996",
"0.73882204",
"0.7383971",
"0.73799425",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73778796",
"0.73772013",
"0.7375748",
"0.73698556",
"0.7365127",
"0.73619884",
"0.7355143",
"0.7334376",
"0.73318833",
"0.7327368",
"0.73269826",
"0.732657",
"0.7326151",
"0.7324812",
"0.7313437",
"0.7306478",
"0.7306006",
"0.7305818",
"0.7305508",
"0.7303877",
"0.7301783",
"0.72973526",
"0.7295354",
"0.729163",
"0.7283666",
"0.7275561",
"0.7274696",
"0.7274097",
"0.72738695",
"0.72717494",
"0.72661674",
"0.725932",
"0.72481304",
"0.72369266",
"0.7225721",
"0.72250736",
"0.7221626",
"0.72040135",
"0.7202842",
"0.7196974",
"0.71898395",
"0.7177079",
"0.7177079",
"0.71706355",
"0.71676654",
"0.71669334",
"0.7160158",
"0.7159869",
"0.71464634"
] |
0.78885597
|
3
|
Show the edit form for an existing category
|
def edit
@journals = journal_list
@category = Documents::Category.find(params[:id])
render layout: false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def edit\n\t\t@category = Category.find(params[:id])\n\tend",
"def edit\n\t\t@category = Category.find(params[:id])\n\tend",
"def edit\n @category = Category.find(params[:id])\n end",
"def edit\n @category = Category.find(params[:id])\n end",
"def edit\n @category = Category.find(params[:id])\n end",
"def edit\n @category = Category.find(params[:id])\n end",
"def edit\n # this is now in get_category\n #@category = Category.find(params[:id])\n end",
"def edit\n @category = Category.find(params[:id])\n\n end",
"def edit\n @category = Category.find(params[:id])\n #@category = Category.new\n end",
"def edit \n @category = Category.find(params[:id]) \n end",
"def edit\n @category=Category.find(params[:id])\n end",
"def edit\n if admin\n @category = Category.find(params[:id])\n else\n redirect_to categories_path\n end\n end",
"def edit\n \t@category = Category.find(params[:id])\n @categories = Category.all.order(:category_name)\n end",
"def edit\n # populates the category with the existing category assigned\n @categories = Category.all.map{ |c| [c.name, c.id] }\n end",
"def edit\n @o_single = Category.find(params[:id])\n end",
"def edit_name\n @category = Category.find(params[:id])\n render(:partial => 'edit')\n end",
"def edit\n @category = Category.find(params[:id])\n respond_with(@category)\n end",
"def update\n \t@category = Category.find(params[:id])\n \tif @category.update_attributes(category_params)\n \t\tredirect_to new_category_path\n \telse\n \t\trender 'edit'\n \tend\n end",
"def edit\n @product = Product.find(params[:id])\n @categories = Category.find(:all)\n end",
"def edit\n\t\t@ssccategory = Ssccategory.find(params[:id])\n\tend",
"def edit\n render json: { content: render_to_string(partial: 'integral/backend/categories/modal', locals: { category: @resource, title: 'Edit Category', modal_id: \"modal--category-edit-#{@resource.id}\" }) }\n end",
"def edit\r\n\t\t@current_area = 'categories'\r\n\t\t@current_menu = 'products'\r\n\r\n\t\t@category = Category.find(params[:id])\r\n\t\tif params[:save]\r\n\t\t\tflash[:notice] = 'Saving'\r\n\t\t\tif @category.update_attributes(params[:category])\r\n\t\t\t\tflash[:notice] = 'Updated successfully'\r\n\t\t\t\texpire_fragment(:controller => :products, :action => :home, :part => 'category_menu')\r\n\r\n\t\t\t\tif @category.id == 1\r\n\t\t\t\t\tlines = Array.new\r\n\t\t\t\t\tfound = false\r\n\t\t\t\t\topen(\"#{RAILS_ROOT}/config/routes.rb\").each do |cur_line|\r\n\t\t\t\t\t\tif found\r\n\t\t\t\t\t\t\tfound = false\r\n\t\t\t\t\t\t\tlines << \" map.connect '#{@category.filename}/*categories', :controller => 'products', :action => 'category'\\n\"\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tlines << cur_line\r\n\t\t\t\t\t\tend\r\n\r\n\t\t\t\t\t\tif cur_line =~ /^ #-PRODUCTS/\r\n\t\t\t\t\t\t\tfound = true\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\r\n\t\t\t\t\topen(\"#{RAILS_ROOT}/config/routes.rb\", \"w\") do |router|\r\n\t\t\t\t\t\tlines.each do |cur_line|\r\n\t\t\t\t\t\t\trouter.write(cur_line)\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\r\n\t\t\t\tredirect_to :action => :list\r\n\t\t\telse\r\n\t\t\t\tflash[:notice] = 'Update failed'\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def edit\n authorize @category\n end",
"def update\n\t @category = Category.find(params[:id])\n\n\t respond_to do |format|\n\t\tif @category.update_attributes(params[:category])\n\t\t format.html { redirect_to [:admin, @category], notice: 'Categoria actualizada exitosamente.' }\n\t\telse\n\t\t format.html { render action: \"edit\" }\n\t\tend\n\t end\n\tend",
"def edit\n # checking if the user has the ability to modify if not error\n # redirect_to root_path, alert: \"Access denied.\" unless can? :edit, @post\n @category_options = Category.all.map{|u| [u.title, u.id]}\n end",
"def update\n if @cat.update(cat_params)\n redirect_to @cat, notice: 'Cat was successfully updated.'\n else\n render :edit\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n if @category.update_attributes(category_params)\n # If successful UPDATE, this will happen\n flash[:success] = \"Successfully Update\" \n redirect_to admin_categories_url\n else\n # If user doesn't input anything, render Edit again\n render 'edit'\n end\n end",
"def update\n if admin\n @category = Category.find(params[:id])\n\n # Can pass only the attributes you want to update\n if @category.update(category_params)\n redirect_to @category\n else\n render \"edit\"\n end\n else\n redirect_to categories_path\n end\n end",
"def update\n\t\tif @category.update(category_params)\n\t\t\tredirect_to categories_url\n\n\t\telse\n\t\t\tformat.html { render action: 'edit' }\n\t\t\tformat.json { render json: @category.errors, status: :unprocessable_entity }\n\t\tend\n\tend",
"def update\n @category = Category.find(params[:id])\n @title = 'Kategorie ' + @category.title + ' bearbeiten'\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to categories_path, notice: 'Category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tif @category.update(category_params)\n\t\t\tflash[:notice] = \"Successfully updated Category\"\n\t\t\tredirect_to @category\n\t\telse\n\t\t\tflash[:error] = get_all_errors\n\t\t\trender 'edit'\n\t\tend\n\tend",
"def update\n\n if\n # get_category\n #updates based on secure below\n @category.update(category_params)\n \n flash[:success] = \"Category Updated\"\n redirect_to root_path\n else\n\n #show the edit form again if it does not update\n #edit.html.erb in our views\n\n render :edit\n\n end\n \n\nend",
"def edit\n @cate_item = CateItem.find(params[:id])\n end",
"def update\n @category = Category.find(params[:id])\n if @category.update_attributes(category_params)\n flash[:notice] = 'Category was successfully updated.'\n redirect_to categories_path\n else\n flash[:error] = @category.errors.full_messages\n # format.js\n render \"edit\"\n end\n end",
"def update\n @category = Category.find(params[:id])\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Saved successfully!'\n redirect_to root_path\n else\n render :action => 'edit'\n end\n\n end",
"def update\n @cat = Cat.find(params[:id])\n if @cat.update(catparams)\n redirect_to @cat\n else\n render 'edit'\n end\n end",
"def edit\n\t\t@categories = Category.all.map{|c| [c.name, c.id] }\n\tend",
"def update\n begin\n new_name = params[:name]\n category_id = params[:id]\n @category = Category.find(params[:id])\n original_name = @category.name\n @category.name = new_name\n existing_category = Category.find_by_name(new_name)\n \n saved = @category.save\n if saved\n render(:partial => '/admin/attribute', :locals => {:record => @category, :name => 'name'})\n else\n render(:partial => 'edit')\n end\n rescue Exception => e\n stack_trace = e.backtrace.join(\"\\n\")\n RACING_ON_RAILS_DEFAULT_LOGGER.error(\"#{e}\\n#{stack_trace}\")\n @category.name = original_name\n @category.errors.add('name', e)\n render(:partial => 'edit')\n end\n end",
"def editCat()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n c = Category.find(params[:id])\n status = c.update(name: params[:name])\n error = \"\"\n if(c.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end",
"def update\n @category = Category.find(params[:id])\n if @category.update_attributes(category_params)\n # Successfully updated the category\n flash[:success] = \"Successfully updated category.\"\n redirect_to @category\n else\n # There was an error updating the category. Show error and return to the 'edit' page\n flash[:error] = \"Failed to update category!\"\n render 'edit'\n end\n end",
"def edit\n @categories = Category.pluck(:name, :id)\n super\n end",
"def uhook_edit_category_sidebar category\n show_translations(category, :hide_preview_link => true)\n end",
"def edit\n @product = Product.find(params[:id])\n\n # Retrieve the categories to display in the caterogy filter dropdown\n @all_categories = Category.where(parent_id: nil).order(:name)\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Category was successfully updated.'\n format.html { redirect_to(@category) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # update attribute\n if @category.update_attributes(category_params)\n # flash message\n flash.now[:success] = \"更新完了しました。\"\n # get category data\n all_categories\n else\n render 'edit'\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Kategoria została zapisana poprawnie.'\n format.html { redirect_to([:admin, @category]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n\t\t#for each student, find that student using the student id\n\t\t@student = Student.find(params[:id])\n\t\t#each category is an array with 3 items - with @ so that view controller can find it, and displays those labels (on edit form)\n\t\t@cats = [\"email\", \"phone\", \"slack\"]\n\t\t#go to the new student page in order to edit\n\t\trender :new\n\t#wraps up \"edit\" action\n\tend",
"def edit\n # Renders the edit form\n end",
"def update\n \n if @category.update(category_params)\n redirect_to experts_path\n else\n redirect_to edit_category_path\n end\n \n end",
"def update\n return unless admin?\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Category was successfully updated.'\n format.html { redirect_to(admin_categories_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tif (@category.titulo != \"Geral\")\n\t\t\trespond_to do |format|\n\t\t\t\tif @category.update(category_params)\n\t\t\t\t\tformat.html { redirect_to @category, notice: 'Categoria atualizada com sucesso.' }\n\t\t\t\t\tformat.json { head :no_content }\n\t\t\t\telse\n\t\t\t\t\tformat.html { render action: 'edit' }\n\t\t\t\t\tformat.json { render json: @category.errors, status: :unprocessable_entity }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course_category = CourseCategory.find(params[:id])\n @admin_section = true\n @page_title = \"Edit Course Category\"\n \n respond_to do |format|\n if @course_category.update_attributes(params[:course_category])\n format.html { redirect_to(course_categories_url, :notice => 'Course category was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course_category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @categoria.update(categoria_params)\n flash[:success] = 'Se actualizó exitosamente la Categoría.'\n redirect_to categorias_path\n else\n render 'edit'\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html {\n redirect_to @category, notice: 'Category was successfully updated.'\n }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json {\n render json: @category.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n \n #if @category.update_attributes(params[:category])\n if @category.update_attributes(name: params[:category][:name])\n redirect_to categories_path\n else\n render 'edit'\n end\n end",
"def update\n @headline = t(:update_category)\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: t(:updated_category_success) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n render partial: \"vocabulary_terms/form\",\n locals: { vocabulary: @term.vocabulary,\n term: @term }\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: t(:category_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @category = @section.dish_categories.build\n\n\n respond_to do |format|\n format.html { render \"edit\"}\n format.json { render json: @category }\n end\n end",
"def new\n if admin\n @category = Category.new\n else\n redirect_to categories_path\n end\n end",
"def update\n #locates the category to be updated\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @ccategory = Ccategory.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @ccategory.update_attributes(params[:ccategory])\r\n format.html { redirect_to(pcategories_path, :notice => 'Ccategory was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @ccategory.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Category was successfully updated.'\n format.html { redirect_to(@category) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to cm_post_categories_url, notice: 'PostCategory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = current_user.categories.find(params[:id])\n @category.update(category_params)\n if @category.save\n redirect_to(root_path, notice: \"Journal was successfully updated.\") and return\n render :show, status: :created, location: @category\n else\n flash.now[:messages] = @category.errors.full_messages[0]\n render :show_form\n end\n end",
"def update\n if @category.update(category_params)\n redirect_to @category.topic, notice: 'Category was successfully updated.'\n else\n render action: 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @category.update category_params\n format.html { redirect_to admin_categories_url, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:success] = 'Category was successfully updated.'\n format.html { redirect_to(admin_categories_url) }\n format.xml { head :ok }\n else\n flash[:error] = 'Category could not be updated. Please see errors below.'\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to [:admin, @category], notice: t('messages.updated', model:Category.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_category.update(admin_category_params)\n format.html { redirect_to @admin_category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_category }\n else\n format.html { render :edit }\n format.json { render json: @admin_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to :back, notice: 'category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to admin_dashboard_categories_path, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n flash[:success] = 'Category was successfully updated.'\n format.html { redirect_to admin_category_url(@category) }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to management_categories_path }\n format.json { render json: @category, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = @current_user.categories.find_by_id(params[:id])\n \tif @category\n \t\trespond_to do |format|\n \t\t if @category.update_attributes(params[:category])\n \t\t\tflash[:notice] = I18n.t('layout.categories.notice_message') % @category.name\n \t\t\tformat.html { redirect_to(categories_path) }\n \t\t else\n \t\t\tformat.html { render :action => \"edit\" }\n \t\t end\n \t\tend\n \telse\n \t\tredirect_to(categories_path)\n \tend\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = '分类修改成功.'\n format.html { redirect_to(cpanel_categories_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @o_single = Category.find(params[:id])\n if @o_single.update_attributes(params[:category])\n flash[:notice] = t(\"general.successfully_updated\")\n redirect_to categories_path\n else\n render :action => 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to categories_path, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to category_index_path, notice: 'Categorie was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n respond_to do |format|\n if @category.update(category_params)\n format.js { render :hide_form }\n else\n format.js { render :show_form }\n end\n end\n end",
"def update\n @post_category = Post::Category.find(params[:id])\n\n respond_to do |format|\n if @post_category.update_attributes(params[:post_category])\n format.html { redirect_to @post_category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @components_category = Components::Category.find(params[:id])\n index\n respond_to do |format|\n if @components_category.update_attributes(params[:components_category])\n format.js { \n @notice = 'Categoria actualizada correctamente' \n render 'index'\n }\n else\n format.js { \n @notice = \"Error al actualizar categoria\"\n render action: \"edit\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update_attributes(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @administration_category = Category.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @administration_category.update_attributes(params[:category])\r\n format.html { redirect_to [:administration, @administration_category], notice: 'Category was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @administration_category.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def uhook_edit_category category\n unless category.in_locale?(current_locale)\n redirect_to(ubiquo.category_set_categories_url)\n false\n end\n end"
] |
[
"0.83586824",
"0.83586824",
"0.83143604",
"0.82791364",
"0.82552385",
"0.82552385",
"0.821831",
"0.82134056",
"0.8122081",
"0.8110967",
"0.7894507",
"0.77133536",
"0.76443094",
"0.75298023",
"0.7527637",
"0.7417307",
"0.73672897",
"0.7328644",
"0.72957647",
"0.72689146",
"0.7230332",
"0.71598953",
"0.7077143",
"0.70684004",
"0.7066528",
"0.70076764",
"0.70035654",
"0.69920236",
"0.69901836",
"0.69238496",
"0.6921903",
"0.6916479",
"0.6891948",
"0.6869018",
"0.6866007",
"0.68514735",
"0.6845623",
"0.6839887",
"0.6820186",
"0.68031794",
"0.6802563",
"0.67942953",
"0.67850363",
"0.6752877",
"0.67467916",
"0.6735804",
"0.67350394",
"0.67225766",
"0.67100567",
"0.67084163",
"0.6692131",
"0.66840976",
"0.66257983",
"0.66257983",
"0.66257983",
"0.66257983",
"0.66257983",
"0.66257983",
"0.66257983",
"0.662462",
"0.6609603",
"0.6602037",
"0.66008943",
"0.65968674",
"0.65947914",
"0.6585333",
"0.6582966",
"0.65666115",
"0.65599644",
"0.65599644",
"0.6554375",
"0.655419",
"0.6533783",
"0.6532096",
"0.65306145",
"0.65266216",
"0.6512905",
"0.6512183",
"0.65086526",
"0.6508171",
"0.6505744",
"0.6497278",
"0.649543",
"0.6494672",
"0.64919317",
"0.64919317",
"0.64918816",
"0.6479981",
"0.64785033",
"0.64717335",
"0.64711154",
"0.64699763",
"0.64623094",
"0.6455671",
"0.6449929",
"0.6447622",
"0.6441354",
"0.64372605",
"0.64304537",
"0.6429645"
] |
0.65123755
|
77
|
Update the parameters of an existing category
|
def update
category = Documents::Category.find(params[:id])
category.update!(category_params)
redirect_to categories_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @category.update(category_params)\n end",
"def update\n Category.update(params[:category].keys, params[:category].values)\n\n redirect_to admin_ads_path\n end",
"def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n category= Category.find(params[:id])\n category.update(category_params)\n \n end",
"def update!(**args)\n @category_name = args[:category_name] if args.key?(:category_name)\n end",
"def update\n json_update(category,category_params, Category)\n end",
"def update!(**args)\n @additional_categories = args[:additional_categories] if args.key?(:additional_categories)\n @primary_category = args[:primary_category] if args.key?(:primary_category)\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @confidence = args[:confidence] if args.key?(:confidence)\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @tag = args[:tag] if args.key?(:tag)\n end",
"def update!(**args)\n @categories = args[:categories] if args.key?(:categories)\n end",
"def update!(**args)\n @categories = args[:categories] if args.key?(:categories)\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @label = args[:label] if args.key?(:label)\n end",
"def update!(**args)\n @category_id = args[:category_id] if args.key?(:category_id)\n @confidence = args[:confidence] if args.key?(:confidence)\n end",
"def update\n # update attribute\n if @category.update_attributes(category_params)\n # flash message\n flash.now[:success] = \"更新完了しました。\"\n # get category data\n all_categories\n else\n render 'edit'\n end\n end",
"def update\n @category.assign_attributes(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to edit_category_url(@category), notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n #My product belongs_to category relationship won't work so I made this so when I update it reflects changes\n category_name = set_category.name\n Product.all.each do |product|\n product.category = category_params[:name] if product.category == category_name\n product.save\n end\n \n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @state = args[:state] if args.key?(:state)\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @price_list_item_id = args[:price_list_item_id] if args.key?(:price_list_item_id)\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @price_list_item_id = args[:price_list_item_id] if args.key?(:price_list_item_id)\n end",
"def update\n \n if @category.update(category_params)\n redirect_to experts_path\n else\n redirect_to edit_category_path\n end\n \n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to api_v1_category_path(@category), notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_categoryall = Categoryall.find(params[:id])\n\n if @admin_categoryall.update_attributes(params[:admin_categoryall])\n params.keys.each do |k|\n set_params(k)\n end\n \n else\n flash[:notice] = t(\"admin.categoryalls.update.notice_failure\") \n respond_with(@admin_categoryall)\n end\n end",
"def update\n @headline = t(:update_category)\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: t(:updated_category_success) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tif @category.update(category_params)\n\t\t\tredirect_to categories_url\n\n\t\telse\n\t\t\tformat.html { render action: 'edit' }\n\t\t\tformat.json { render json: @category.errors, status: :unprocessable_entity }\n\t\tend\n\tend",
"def update_factcat\n cat = Category.find(self.category_id)\n self.factcat_id = cat.get_factcat_from_category.id\n self.save!\n end",
"def update\n @category = Category.find(params[:id])\n \n #if @category.update_attributes(params[:category])\n if @category.update_attributes(name: params[:category][:name])\n redirect_to categories_path\n else\n render 'edit'\n end\n end",
"def update!(**args)\n @category_id = args[:category_id] if args.key?(:category_id)\n @display_name = args[:display_name] if args.key?(:display_name)\n end",
"def update!(**args)\n @category_id = args[:category_id] if args.key?(:category_id)\n @display_name = args[:display_name] if args.key?(:display_name)\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: t('update.notice', name: t('activerecord.models.category')) }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n if @auction_category.update_category!(auction_category_params, params[:auction_category][:attribute_ids])\n flash_msg('success', '修改分类成功!', 'index')\n end\n rescue Exception => e\n flash['danger'] = '修改分类失败!#{error_msg(@auction_category)}'\n return redict_to action: 'edit', id: @auction_category.id\n end\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @confidence = args[:confidence] if args.key?(:confidence)\n @is_restricted = args[:is_restricted] if args.key?(:is_restricted)\n @mid = args[:mid] if args.key?(:mid)\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Категория была успешно изменена' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to category_index_path, notice: 'Categorie was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n MediaCategory.update(params[:category].keys, params[:category].values)\n\n redirect_to admin_medias_path\n end",
"def update\n\t\tif (@category.titulo != \"Geral\")\n\t\t\trespond_to do |format|\n\t\t\t\tif @category.update(category_params)\n\t\t\t\t\tformat.html { redirect_to @category, notice: 'Categoria atualizada com sucesso.' }\n\t\t\t\t\tformat.json { head :no_content }\n\t\t\t\telse\n\t\t\t\t\tformat.html { render action: 'edit' }\n\t\t\t\t\tformat.json { render json: @category.errors, status: :unprocessable_entity }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @category.update_attributes(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to adminpanel_categories_path, notice: \"Категория #{@category.name} успешно обновлена\" }\n format.json { render :show, status: :ok, location: adminpanel_categories_path }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @customer_category.update(customer_category_params)\n CustomerCategoryParameter.set_irrelevant(@customer_category.id)\n @customer_category.customer_category_parameters.set_relevant\n flash[:success] = 'Категория успешно отредактирована.'\n format.html { redirect_to edit_customer_category_path(@customer_category) }\n else\n flash[:danger] = 'Ошибка редактирования категории.'\n format.html { redirect_to edit_customer_category_path(@customer_category) }\n end\n end\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @domain = args[:domain] if args.key?(:domain)\n @features = args[:features] if args.key?(:features)\n @score = args[:score] if args.key?(:score)\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cp_category.update(cp_category_params)\n format.html { redirect_to @cp_category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @cp_category }\n else\n format.html { render :edit }\n format.json { render json: @cp_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to admin_dashboard_categories_path, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n @category.format_name = params[:category][:name].gsub(/ /, \"_\").downcase\n \n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to admin_scenic_spots_url, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @category_group = args[:category_group] if args.key?(:category_group)\n @state = args[:state] if args.key?(:state)\n end",
"def update\n if @category.update(category_params)\n render json: @category, status: :ok\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to edit_dashboard_category_path(@category), notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category.update_attributes(params[:category])\n respond_with(@category)\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.json { render :show, status: :ok, location: @category }\n else\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @categories = Category.all\n #@category =Categorie.find(params[:id])\n @category.update(category_params)\n flash[:notice]=\"Catégorie Modifié avec succès!!!\"\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to cm_post_categories_url, notice: 'PostCategory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category=Category.find(params[:id])\n @category.update_attributes(params[:category].permit(:name))\n if @category.save\n redirect_to categories_path\n else\n render action: 'new'\n end\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @classifier_version = args[:classifier_version] if args.key?(:classifier_version)\n @taxonomy = args[:taxonomy] if args.key?(:taxonomy)\n @taxonomy_name = args[:taxonomy_name] if args.key?(:taxonomy_name)\n end",
"def update\n @category = Category.find(params[:id])\n\n path = admin_categories_path\n if @category.category_id\n path = admin_category_path(@category.category_id)\n end\n\n if @category.update(params[:category].permit(:name))\n redirect_to path\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to management_categories_path }\n format.json { render json: @category, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @category_id = args[:category_id] if args.key?(:category_id)\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to categories_path, notice: \"Category was successfully updated.\" }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \t@category = Category.find(params[:id])\n \tif @category.update_attributes(category_params)\n \t\tredirect_to new_category_path\n \telse\n \t\trender 'edit'\n \tend\n end",
"def update\n respond_to do |format|\n if @category.update category_params\n format.html { redirect_to admin_categories_url, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to backoffice_categories_path,\n notice: notification_alert('success', 'Updated!', \"Category [#{@category.description}] was successfully updated.\") \n }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n flash[:success] = 'Category was successfully updated.'\n format.html { redirect_to admin_category_url(@category) }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #locates the category to be updated\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product.category_id = params[:category_id]\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Kategoria została zapisana poprawnie.'\n format.html { redirect_to([:admin, @category]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t @category = Category.find(params[:id])\n\n\t respond_to do |format|\n\t\tif @category.update_attributes(params[:category])\n\t\t format.html { redirect_to [:admin, @category], notice: 'Categoria actualizada exitosamente.' }\n\t\telse\n\t\t format.html { render action: \"edit\" }\n\t\tend\n\t end\n\tend",
"def update\n @category = Category.find(params[:id])\n\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Sucesso - update'\n else\n flash[:notice] = 'Falha ao atualizar a categoria'\n end\n\n # respond_to do |format|\n # if @category.update_attributes(params[:category])\n # format.html { redirect_to categories_path}\n # format.json { head :no_content }\n # else\n # format.html { render action: \"edit\" }\n # format.json { render json: @category.errors, status: :unprocessable_entity }\n \n # end\n # end\n end",
"def update\n respond_to do |format|\n if @gt_category.update(gt_category_params)\n format.html { redirect_to @gt_category, notice: 'Gt category was successfully updated.' }\n format.json { render :show, status: :ok, location: @gt_category }\n else\n format.html { render :edit }\n format.json { render json: @gt_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def category_params\n end",
"def update\n @pcategory = Pcategory.find(params[:id])\n\n respond_to do |format|\n if @pcategory.update_attributes(params[:pcategory])\n format.html { redirect_to @pcategory, notice: 'La categoria se modifico satisfactoriamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pcategory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n\r\n @event.category_id = params[:category_id]\r\n super(@event, 'Post atualizado com sucesso', event_params);\r\n end",
"def update\n @category = Category.find(params[:id])\n @category.update_attributes(params[:category])\n respond_with(@category, location: categories_url)\n end",
"def update\n if @category.update_attributes(params[:category])\n flash[:notice] = \"Категория успешно изменена\"\n else\n flash[:alert] = \"Ошибка изменения категории: #{@category.errors.full_messages}\"\n end\n respond_to do |format|\n format.html { redirect_to categories_path }\n end\n end",
"def update\n authorize @category\n\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to admin_project_path(@category.project_id), notice: t('actions.updated_with_success')}\n format.json { render :edit, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def category_update\n @finance_category = FinanceTransactionCategory.find(params[:id])\n unless @finance_category.update_attributes(params[:finance_category])\n @errors=true\n end\n @categories = FinanceTransactionCategory.all(:conditions => {:deleted => false}, :order => 'name asc')\n @category_ids = @categories.map { |cat| cat.id if FinanceTransaction.find_by_category_id(cat.id).present? }.compact\n @fixed_categories = @categories.reject { |c| !c.is_fixed }\n @other_categories = @categories.reject { |c| c.is_fixed }\n @multi_config = FinanceTransactionCategory.get_multi_configuration\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to admin_good_categories_url, notice: 'GoodCategory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to :back, notice: 'Kategori diperbarui.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category_to_category.update(category_to_category_params)\n format.html { redirect_to @category_to_category, notice: 'Category to category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category_to_category }\n else\n format.html { render :edit }\n format.json { render json: @category_to_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n @title = 'Kategorie ' + @category.title + ' bearbeiten'\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to categories_path, notice: 'Category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @category = args[:category] if args.key?(:category)\n @patch_name = args[:patch_name] if args.key?(:patch_name)\n @severity = args[:severity] if args.key?(:severity)\n @summary = args[:summary] if args.key?(:summary)\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to categories_url, notice: 'Category was successfully updated.' }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update_attributes(params[:category])\n if @category.cambio_algo\n format.html {redirect_to notify_changes_category_url}\n else\n format.html { redirect_to(@category, :notice => t('scaffold.notice.updated', :item=> Category.model_name.human)) }\n format.xml { head :ok }\n end\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if admin\n @category = Category.find(params[:id])\n\n # Can pass only the attributes you want to update\n if @category.update(category_params)\n redirect_to @category\n else\n render \"edit\"\n end\n else\n redirect_to categories_path\n end\n end",
"def update\n @category = Category.find(params[:id])\n if @category.update_attributes(category_params)\n # Successfully updated the category\n flash[:success] = \"Successfully updated category.\"\n redirect_to @category\n else\n # There was an error updating the category. Show error and return to the 'edit' page\n flash[:error] = \"Failed to update category!\"\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @categorization = Categorization.find(params[:id])\n @categories = category_list\n respond_to do |format|\n if @categorization.update_attributes(params[:categorization])\n format.html { redirect_to(admin_categorization_path(@categorization), :notice => 'Categorization was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @categorization.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Категория изменена.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7718946",
"0.7666295",
"0.76174384",
"0.7557798",
"0.75098485",
"0.7487584",
"0.72935927",
"0.7286536",
"0.72782093",
"0.7273553",
"0.7273553",
"0.7253039",
"0.722008",
"0.71962404",
"0.7191206",
"0.7124601",
"0.7100617",
"0.70849836",
"0.70849836",
"0.70797753",
"0.7023971",
"0.7018208",
"0.7013842",
"0.6997889",
"0.69825405",
"0.6972485",
"0.69723415",
"0.69723415",
"0.6945254",
"0.6935358",
"0.69340754",
"0.6932712",
"0.6928643",
"0.69114274",
"0.69103086",
"0.68954706",
"0.68912876",
"0.68906707",
"0.6889239",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6889046",
"0.6879776",
"0.68686664",
"0.6868032",
"0.6867322",
"0.6858081",
"0.6854076",
"0.68525696",
"0.68521184",
"0.6850619",
"0.68481547",
"0.68339753",
"0.68281823",
"0.682787",
"0.6825916",
"0.68253225",
"0.6816579",
"0.680596",
"0.6785251",
"0.6782679",
"0.67722034",
"0.6771536",
"0.67713064",
"0.6770366",
"0.6767127",
"0.6765668",
"0.67593116",
"0.6758422",
"0.6755432",
"0.67553353",
"0.6751728",
"0.6748149",
"0.6743735",
"0.6739143",
"0.67268425",
"0.6726588",
"0.67213917",
"0.6719496",
"0.67173547",
"0.67157936",
"0.67111814",
"0.6700596",
"0.6700531",
"0.67002386",
"0.67002386",
"0.66967344",
"0.6691683"
] |
0.7105396
|
16
|
Delete an individual category
|
def destroy
category = Documents::Category.find(params[:id])
category.destroy
redirect_to categories_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_category(category)\n data.delete_category(category)\n end",
"def destroy\n @category.delete\n end",
"def remove_category category_name\r\n delete category_name\r\n end",
"def destroy\n @category.destroy\n end",
"def delete_category id\n\t\t\t\t\tFreshdesk::Api::Client.delete_status_wrapper do\n\t\t\t\t\t\t( @connection.delete CATEGORIES, id ).code\n\t\t\t\t\tend\n\t\t\t\tend",
"def delete_category( category )\n MovieUserCategory.destroy_all [ \"movie_id = ? and category_id = ?\", self.id, category.id ]\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n end",
"def destroy\n @category = Category.find(params[:id])\n begin\n @category.destroy\n rescue ActiveRecord::DeleteRestrictionError\n error = 'Эта категория не может быть удалена, пока с ней связан хоть один файл.'\n ensure\n respond_to do |format|\n format.html { redirect_to categories_url, notice: error }\n format.json { head :ok }\n end\n end\n end",
"def destroy\n @category.destroy\n head :no_content\n end",
"def deleteCat()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n c = Category.find(params[:id])\n status = c.destroy\n error = \"\"\n if(c.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: true, reason: error, data: \"\"}\n end",
"def destroy\n\t\t@category = Category.find(params[:id])\n\t\t@category.destroy\n\t\tredirect_to new_category_path\n\tend",
"def destroy\n\t\t\n\t\t@category = Category.find(params[:id])\n\t\t@category.destroy\n\t\tredirect_to categories_url\n\tend",
"def destroy\r\n @category = Category.find(params[:id])\r\n @categorization = Categorization.find(:all, :conditions=>[\"category_id = ?\", params[:id]])\r\n if @categorization.size > 0\r\n flash[:notice] = 'You cannot delete the category it is linked to Companies.'\r\n else\r\n @category.destroy\r\n end \r\n\r\n respond_to do |format|\r\n format.html { redirect_to(admin_categories_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n\t @category = Category.find(params[:id])\n\t @category.destroy\n\n\t respond_to do |format|\n\t\tformat.html { redirect_to admin_categories_url, notice: 'Categoria eliminada exitosamente.' }\n\t end\n\tend",
"def destroy\n Category.find(params[:id]).destroy\n\n redirect_to admin_ads_path\n end",
"def destroy\n @category.destroy\n redirect_to dashboard_categories_url, notice: 'Category was successfully destroyed.'\n end",
"def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @categoria.destroy\n flash[:success] = 'Se eliminó correctamente la categoría.'\n redirect_to categorias_url\n end",
"def destroy\n @categorie = Categorie.find(params[:id])\n @categorie.destroy\n end",
"def destroy\n begin\n @category.destroy\n flash[:success] = \"successfully destroyed.\"\n rescue ActiveRecord::DeleteRestrictionError => e\n @category.errors.add(:base, e)\n flash[:error] = \"#{e}\"\n redirect_to category_url\n else\n redirect_to categories_url\n end\n end",
"def destroy\n\t\t@category = Category.find(params[:id])\n \t@category.destroy\n \tredirect_to :action => \"index\"\n end",
"def delete\n Category.destroy( params[:category_id] )\n redirect_to :controller => \"category\", :action => \"index\"\n rescue ActiveRecord::RecordNotFound\n flash[:error] = \"Could not delete category.\"\n redirect_to :controller => \"category\", :action => \"index\"\n end",
"def destroy\n @categories=Category.all\n @category.destroy\n flash[:notice]=\"Supprimé avec succès!!!\"\n \n end",
"def destroy\n @category = Category.find(params[:id])\n flash[:notice] = \"Category successfully deleted\" if @category.destroy\n redirect_to categories_path\n end",
"def destroy\n\t\t@category.destroy\n\t\tflash[:notice] = \"Category was successfully removed.\"\n\t\tredirect_to categories_path\n\tend",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(cpanel_categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n flash[:success] = 'Category was deleted.'\n format.html { redirect_to(admin_categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to admin_categories_url, notice: 'Вы удалили категорию и список услуг.' }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_categories_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n if @category.destroyed?\n flash[:notice] = 'Kategoria została usunięta poprawnie.'\n else\n flash[:notice] = 'Wystąpił błąd podczas usuwania kategorii.'\n end\n\n respond_to do |format|\n format.html { redirect_to(admin_categories_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n\t\tSsccategory.find(params[:id]).destroy\n\t\tredirect_to :action => 'list'\n\tend",
"def destroy\r\n @ccategory = Ccategory.find(params[:id])\r\n @ccategory.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(ccategories_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end",
"def delete(category_id)\n response, status = BeyondApi::Request.delete(@session, \"/categories/#{category_id}\")\n\n handle_response(response, status, respond_with_true: true)\n end",
"def destroy\n if admin\n @category = Category.find(params[:id])\n @category.destroy\n else\n redirect_to categories_path\n end\n end",
"def destroy\n @category.destroy\n render json: { notice: 'Categoria eliminada exitosamente' }\n end",
"def destroy\n @category = Category.find(params[:id])\n \n path = admin_categories_path\n if @category.category_id\n path = admin_category_path(@category.category_id)\n end\n\n if @category.destroy\n redirect_to path\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: '分类删除成功~' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_path, notice: 'Category was successfully destroyed.' }\n end\n end",
"def destroy\n @categorization = Categorization.find(params[:id])\n @categorization.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_categorizations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n flash[:notice] = 'Article destroyed!'\n redirect_to root_path\n end",
"def destroy\n @category = @collection.category.find(params[:id])\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_category\n if self.foods.empty?\n self.destroy\n else\n false\n end\n end",
"def delete_category(category_)\n @mutex.synchronize do\n raise ConfigurationLockedError if @locked\n @categories.delete(category_)\n end\n self\n end",
"def destroy\n @post_category = Post::Category.find(params[:id])\n @post_category.destroy\n\n respond_to do |format|\n format.html { redirect_to post_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = @current_user.categories.find_by_id(params[:id])\n \tif @category\n \t\t@category.destroy\n\n \t\trespond_to do |format|\n \t\t flash[:notice] = I18n.t('layout.categories.delete_message') % @category.name\n \t\t format.html { redirect_to(categories_path) }\n \t\tend\n \telse\n \t\tredirect_to(categories_path)\n \tend\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :ok }\n end\n end",
"def destroy\n category = set_category\n if category.destroy\n head :no_content\n else\n render json: { status: 500 }\n end\n \n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to cm_post_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n flash[:success] =\"Category was successfully destroyed.\"\n redirect_to admin_categories_url\n end",
"def destroy\n @complaint_category.destroy\n redirect_to complaint_categories_url,\n notice: 'Complaint category was successfully destroyed.'\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n flash[:success] = 'Category was successfully deleted.'\n format.html { redirect_to admin_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n topic = @category.topic\n if @category.destroy\n redirect_to topic, notice: 'Category was successfully destroyed.'\n else\n redirect_to topic, alert: @category.errors[:base].join(' ')\n end\n end",
"def destroy\n @rcadmin_category.destroy\n respond_to do |format|\n flash[:notice] = 'Category was successfully deleted.'\n format.html { redirect_to rcadmin_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_category.destroy\n end",
"def remove\n authorize @category\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: \"Journal was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to admin_categories_url }\n format.json { head :no_content }\n end\n end",
"def delete_category(category_type_, *category_spec_)\n @config.lock\n\n if @categories.include?(category_type_)\n spec_ = category_spec_.size == 1 && category_spec_.first.is_a?(::Array) ? category_spec_.first : category_spec_\n if (tuple_hash_ = (@catdata[category_type_] ||= {})[spec_])\n @mutex.synchronize do\n tuple_hash_.values.each do |objdata_|\n @objects.delete(objdata_[0].object_id)\n objdata_[2].each_key{ |tup_| _remove_tuple(objdata_, tup_) }\n end\n end\n end\n end\n self\n end",
"def destroy\n authorize @category\n respond_to do |format|\n if @category.remove? params[:category_name]\n format.html { redirect_to staff_categories_url, notice: 'Category was successfully destroyed.' }\n else\n format.html { render :remove }\n end\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_categories_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n @category.destroy\n respond_to do |format|\n format.html { redirect_to admin_categories_url, notice: t('messages.deleted', model:Category.model_name.human) }\n format.json { head :no_content }\n end\n rescue ActiveRecord::InvalidForeignKey => e\n flash[:error] = t 'errors.messages.delete_fail.being_used', model:@category.name\n flash[:error_details] = e\n redirect_to [:admin, @category]\n rescue ActiveRecord::StatementInvalid => e\n flash[:error] = t 'errors.messages.ops'\n flash[:error_details] = e\n redirect_to [:admin, @category]\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to forum_categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: t('destroy.notice', name: t('activerecord.models.category')) }\n format.json { head :no_content }\n end\n end",
"def destroy\n audit(@accessory_category, current_user)\n @accessory_category.destroy\n \n\n head :no_content\n end",
"def remove_category(category)\n @redis.srem category_collection_key, category\n end",
"def destroy\n\t\t@category.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to categories_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n return unless admin?\n\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @administration_category = Category.find(params[:id])\r\n @administration_category.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to administration_categories_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @brand_category.destroy\n\n head :no_content\n end",
"def destroy\n @categoria.destroy\n respond_to do |format|\n format.html { redirect_to categorias_path, notice: @@titulo + t('msg.remove') }\n format.json { head :no_content }\n end\n end",
"def destroy\n \tauthorize! :destroy, @category\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\tif (@category.titulo != \"Geral\")\n\t\t\t@category.destroy\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to categories_url, notice: 'Categoria apagada com sucesso!' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\tend\n\t\telse\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to categories_url, notice: 'Essa categoria nao pode ser destruida!' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\tend\n\t\tend\n\tend",
"def destroy\n @post_category = PostCategory.find(params[:id])\n @post_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(post_categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # authorize\n authorize! :delete, @article_category\n @article_category.destroy\n \n render nothing:true\n flash[:notice] = 'Xóa chuyên mục bài viết thành công.'\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to admin_good_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @categoria = Categoria.find(params[:id])\n @categoria.destroy\n\n respond_to do |format|\n format.html { redirect_to categoria_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @category\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: t('.success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_scenic_spots_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = DishCategory.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Категория удалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = current_mall.categories.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to api_wmall_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxonomy_category = TaxonomyCategory.find(params[:id])\n @taxonomy_category.destroy\n\n respond_to do |format|\n format.html { redirect_to taxonomy_categories_url }\n format.json { head :ok }\n end\n end"
] |
[
"0.8705136",
"0.8388428",
"0.8312891",
"0.8121466",
"0.8097138",
"0.79967153",
"0.797505",
"0.794454",
"0.7801204",
"0.77812016",
"0.7749321",
"0.76878387",
"0.76784784",
"0.766632",
"0.7646991",
"0.76065975",
"0.75989985",
"0.75985354",
"0.75846106",
"0.75823075",
"0.75819755",
"0.75724936",
"0.75624835",
"0.7559493",
"0.7556293",
"0.755011",
"0.7549661",
"0.754236",
"0.75336933",
"0.7528201",
"0.7523881",
"0.7499908",
"0.74956906",
"0.7493596",
"0.7484362",
"0.7484009",
"0.7468447",
"0.7457309",
"0.7440581",
"0.74373657",
"0.7437",
"0.7421686",
"0.74167037",
"0.74109143",
"0.74092776",
"0.7388811",
"0.73879415",
"0.73777044",
"0.7370902",
"0.7369395",
"0.7369395",
"0.7369395",
"0.736927",
"0.7354393",
"0.7346263",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.7332146",
"0.73206776",
"0.7320122",
"0.7308354",
"0.7304575",
"0.7293505",
"0.72915703",
"0.72863364",
"0.7259881",
"0.7259467",
"0.72517246",
"0.72495115",
"0.72384274",
"0.72376066",
"0.7237093",
"0.7236586",
"0.7232988",
"0.72309506",
"0.7227029",
"0.7225702",
"0.7219615",
"0.7210769",
"0.72088593",
"0.7208461",
"0.72056335",
"0.72044766",
"0.7202594",
"0.72005856",
"0.7199795",
"0.71969986",
"0.7193848",
"0.719198",
"0.71886957",
"0.71864617"
] |
0.7862209
|
8
|
Whitelist acceptable category parameters
|
def category_params
params.require(:documents_category).permit(:name, journals: [])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def category_params\n params[:category][:related_category_ids].reject! { |c| c.empty? } if params[:category][:related_category_ids]\n params[:category][:related_by_category_ids].reject! { |c| c.empty? } if params[:category][:related_by_category_ids]\n params[:category][:suggested_category_ids].reject! { |c| c.empty? } if params[:category][:suggested_category_ids]\n params[:category][:suggested_by_category_ids].reject! { |c| c.empty? } if params[:category][:suggested_by_category_ids]\n \n params.require(:category).permit(:name, :is_course_type, :related_category_ids => [], :related_by_category_ids => [], :suggested_category_ids => [], :suggested_by_category_ids => [])\n end",
"def explore_params\n params.permit(category:[])\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def allowed_cat_entries(options)\n rails_logger('allowed_cat_entries', 0)\n @values[\"#{options[:prov_field_name]}_category\".to_sym] = options[:category]\n cat = Classification.lookup_by_name(options[:category].to_s)\n result = cat ? cat.entries.each_with_object({}) { |e, h| h[e.name] = e.description } : {}\n rails_logger('allowed_cat_entries', 1)\n result\n end",
"def category_params\n end",
"def category_params\n params.require(:category).permit(:code, :name, :description, :hidden, :picture, :title, :meta_description, :meta_keywords, property_group_ids: [])\n end",
"def suggested_category_params\n params.require(:suggested_category).permit(:category, :approved)\n end",
"def category_params\n params.require(:category).permit(:belongs_to, :name, :subcats, :filterables)\n end",
"def category_params\n params.require(:category).permit(:category)\n end",
"def category_params\n params.require(:category).permit(:category)\n end",
"def category_params\n params.require(:category).permit(:category_name)\n end",
"def category_params\n \t\tparams.require(:category).permit(:category_name)\n \tend",
"def category_params\n\t\tparams.require(:category).permit(:name, :desccriptioin)\n\tend",
"def category_params\n params[:category].permit(:topic_id, :name, :displayed_name, :active)\n end",
"def check_or_create_unauthorized_category(cat_params)\n new_cat = Category.find_or_create_by_name('Unauthorized')\n add_this_params = cat_params - new_cat.parameters.all\n add_this_params.each do |param_to_create|\n new_cat.parameters.create(param_to_create)\n return new_cat\n end\n end",
"def category_params\n params.require(:category).permit(:english_name, :welsh_name, :inactive)\n end",
"def available_category_params\n params.require(:available_category).permit(:name, :color, :icon)\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def allowed_category_ids\n @allowed_category_ids ||=\n begin\n unrestricted = Category.where(read_restricted: false).pluck(:id)\n unrestricted.concat(secure_category_ids)\n end\n end",
"def param_whitelist\n [:role, :title]\n end",
"def category_params\n params.require(:category).permit(:name, :priority)\n end",
"def category_params\n params.require(:category).permit(\n :name\n )\n end",
"def advert_category_params\n params[:advert_category].permit(:product_category_id, :show_in_products, :views, :time_days)\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def ilance_category_params\n params.fetch(:ilance_category, {})\n end",
"def category_params\n\t\tparams.require(:category).permit(:name)\n\tend",
"def sanitized_category\n return category.underscore.gsub(/ /, '_').gsub(/[^a-z_0-9]/,'')\n end",
"def category_params\n params.require(:category).permit(:name)\n # if want to create post, it need :user_id, :place_name, :place_type, :address, \n # :bedroom, :bath, :amenity, :cost_per_night,:description validation\n end",
"def category_params\n params[:advertiser_id] = current_advertiser.id if advertiser_signed_in?\n params.permit *%i[id advertiser_id category_code category_name parent_category_id parent_category_code]\n end",
"def category_params\n params.permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name, :visible, :project_id)\n end",
"def cp_category_params\n params.require(:category).permit(:name, :description)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name)\n end",
"def category_params\r\n params.require(:category).permit(:name)\r\n end",
"def categories_params\r\n params.require(:category).permit(:name)\r\n end",
"def cat_params\n params.require(:cat).permit(:user_id, :cat_type_id, :location_id, :name,\n :age, :color, :hyperactivity, :health, :about,\n :image, :gender)\n end",
"def admin_category_params\n params.require(:category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:user_id, :name, :is_disabled, :order)\n end",
"def category_params\n params.require(:category).permit(:categoryTitle, :categoryColor, :userId)\n end",
"def law_category_params\n params.require(:law_category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name, :auto, :priority, :contexts, :templates,\n intent_user_says_attributes: [:text, :alias, :meta, :id, :_destroy],\n intent_responses_attributes: [:reset_contexts, :action, :speech, :id, :_destroy,\n intent_affected_contexts_attributes: [:name, :lifespan, :id, :_destroy],\n intent_parameters_attributes: [:data_type, :name, :value, :id, :_destroy]]\n )\n end",
"def category_params \n params.require(:category).permit(:name) \n end",
"def category_params\n params.require(:post_category).permit(:name)\n end",
"def alien_category_params\n params.require(:alien_category).permit(:name)\n end",
"def category_params\n params.require(:category).permit(:name, :show, :description)\n end",
"def internal_category_params\n params.require(:internal_category).permit(:name)\n end",
"def thing_category_params\n params.require(:thing_category).permit(:name)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def category_params\n params.require(:category).permit(:name,\t:ancestry, :weight, :enable, :icon)\n end",
"def sanitized_allowed_tags=(tags); end",
"def sanitized_allowed_tags=(tags); end",
"def admin_category_params\n params.require(:category).permit(:name)\n\n end",
"def category_params\n params.require(:category).permit(:name, :description, :term, :task_ids => [])\n end",
"def patrimony_item_category_params\n params.require(:patrimony_item_category).permit(:category)\n end",
"def category_params\n params.require(:category).permit(:name,:nice_url,:site_id)\n end",
"def category_params\n params.require(:category).permit(:name, :layer_id, :description, :infolink)\n end",
"def schema_category_params\n params.fetch(:schema_category).permit(:name, :description)\n end",
"def category_params\n params.require(:category).permit(:name, :image_category, :user_id, :owner_id)\n end",
"def category_params\n params.require(:category).permit(:code, :nom, :description, :is_active)\n end",
"def category_params\n params.require(:category).permit :name,\n :item_ids => []\n end",
"def hive_category_params\n params.require(:hive_category).permit(:cat_id, :name, :description, :is_active)\n end",
"def category_params\n params.require(:top_category).permit(:name, :shortDescription, :enabled, :deleted, :user_id)\n end",
"def category_params\n params.require(:category).permit(:name,\n :description)\n end",
"def category_params\n params.require(:category).permit(:name, :abbr)\n end",
"def category_params\n params.require(:category).permit(:category_id, :name)\n end",
"def prv_category_params\n params.require(:category).permit(:name, :is_active, :image, :description)\n end",
"def categories\n add_to_query restrict_kind: 'category'\n end",
"def category_params\n params.require(:category).permit(:name, :meta_desc, :meta_key, :image)\n end",
"def flag_category_params\n params.require(:flag_category).permit(\n :name\n )\n end",
"def caste_category_params\n params.require(:caste_category).permit(:category)\n end",
"def mytag_params\n params.require(:mytag).permit(:category)\n end",
"def category_params\n params.require(:category).permit(:name, :description)\n end"
] |
[
"0.65918785",
"0.6520349",
"0.65130043",
"0.65064466",
"0.64219385",
"0.63662845",
"0.632107",
"0.6259186",
"0.62589496",
"0.6247059",
"0.62397075",
"0.62171",
"0.6213012",
"0.6188303",
"0.6176929",
"0.6173933",
"0.61540216",
"0.6151966",
"0.61365944",
"0.6126754",
"0.6120913",
"0.6105324",
"0.6089254",
"0.6088011",
"0.6073856",
"0.60697407",
"0.6068959",
"0.606726",
"0.60618126",
"0.6061598",
"0.605204",
"0.6047867",
"0.6046762",
"0.6046762",
"0.6046762",
"0.6046762",
"0.6046762",
"0.6046762",
"0.6046762",
"0.6046762",
"0.6046762",
"0.6046762",
"0.6046015",
"0.6042961",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6041886",
"0.6029429",
"0.60177827",
"0.6017706",
"0.6017564",
"0.6016303",
"0.6014488",
"0.6009418",
"0.6005995",
"0.60016227",
"0.5996644",
"0.59820026",
"0.59778637",
"0.5973849",
"0.5968628",
"0.5968612",
"0.59673035",
"0.59650254",
"0.59650254",
"0.59618825",
"0.59608334",
"0.59594333",
"0.59396577",
"0.593886",
"0.5936837",
"0.5936081",
"0.5931851",
"0.5930169",
"0.59271085",
"0.5922598",
"0.59161705",
"0.5913697",
"0.59116113",
"0.59021115",
"0.59005564",
"0.58909756",
"0.5887711",
"0.5883779",
"0.58737165",
"0.5873305"
] |
0.0
|
-1
|
Take the given hash and category, and set its children as appropriate
|
def set_children_for(category, hash)
if hash['children']
hash['children'].each do |ch|
child = Documents::Category.find(ch['id'])
child.parent = category
child.save
set_children_for(child, ch)
end
else
# Can't remove children, so nil out the parent of anything that's listed
# as a child of this node
category.children.each do |c|
c.parent = nil
c.save
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_categories(product)\n categories = value('category').split('&')\n\n categories.each do |category_string|\n category_string.strip!\n subcategories = category_string.split('>')\n parent_id = self.root_category.id\n subcategories.each do |category_url_key|\n category_url_key.strip!\n category = Gemgento::Category.find_by(url_key: category_url_key, parent_id: parent_id)\n unless category.nil?\n pc = Gemgento::ProductCategory.find_or_create_by!(category: category, product: product, store: self.store)\n parent_id = category.id\n pc.sync_needed = true\n pc.save\n else\n self.process_errors << \"Row ##{@index}: Unknown category url key '#{category_url_key}' - skipped\"\n end\n end\n end\n end",
"def categories_attributes=(category_hashes)\n #hash looks like this {\"0\"={name:\"New Category\"}, \"1\"={name:\"Other New Category\"}}\n #for every value in the categoery_attributes hash...\n category_hashes.value.each do |i,category_attr|\n #each will be this: {name:\"New Category\"} - a hash that can be used to create a new cateogry\n #find or create a category by that attribute (will pass key and value in?)\n category=Category.find_or_create_by(name: category_attr[:name])\n\n #make a new post_category instance using the category\n #will make a new post_category with post_id of self.id and category_id of category.id\n self.post_categories.build(category:category)\n end\n end",
"def categories_attributes=(categories_hash)\n # {\"0\"=>{\"name\"=>\"Romance\"}, \"1\"=>{\"name\"=>\"\"}}\n # raise categories_attributes.inspect\n categories_hash.each do |index, category_attribute|\n # find or create if post doesn't have this category BAD\n # self.category.find_or_create_by(name: category_attribute[:name])\n # find or create if this post doesn't exist yet GOOD\n if category_attribute[:name].present?\n category = Category.find_or_create_by(name: category_attribute[:name])\n if !self.categories.include?(category)\n self.post_categories.build(:category => category)\n end\n end\n end\n end",
"def categories_from_hash(hash)\n cat = []\n (1..hash.size).each { |i|\n cat.push(Item_Category.new(hash[i][0], hash[i][1]))\n }\n cat\n end",
"def category_tree\n @category_tree = {}\n get_category_browse_nodes.each do |n|\n build_category_tree(n)\n end\n @category_tree\n end",
"def categories_attributes=(categories_hashes)\n categories_hashes.each do |i, category_attributes|\n if category_attributes[:name].present?\n category = Category.find_or_create_by(name: category_attributes[:name])\n if !self.categories.include?(category)\n self.post_categories.build(:category => category)\n end\n end\n end\n end",
"def category_attributes=(category_attributes) # setter\n # raise category_attributes.inspect\n category_attributes.keys.each do |key|\n categories.new(category_attributes[key])\n end\n end",
"def categories_attributes=(category_hashes)\n # needed so post new form can be used to create categories_attributes\n category_hashes.each do | index, category_attributes |\n if category_attributes[:name].present?\n category = Category.find_or_create_by(name: category_attributes[:name])\n # if category already exists for post, don't add it\n if !self.categories.include?(category)\n self.categories << category # inefficient!\n self.save\n end\n end\n end\n end",
"def categories_attributes=(categories_hashes) #writer\n #{\"0\"=>{\"name\"=>\"new catogory 1\"}, \"1\"=>{\"name\"=>\"new catogory 2\"}}\n #raise category_hashes.inspect\n #How would I create a catogory for each of the hashes inside categories_hashes\n categories_hashes.values.each do |category_attributes|\n\n #DO NOT CREATE A CATEGORY IF IT DOESN'T HAVE NAME\n #if category_attributes[:name].present?\n\n #create a new catogory if this post doesn't already have this catogory\n #find or create the catogory regardless of whether this post has it.\n category = Category.find_or_create_by(category_attributes)\n #ALSO DON'T DUPLICATE POST IF IT ALREADY HAVE IT.\n #How do i check if this post has this category already?\n if !self.categories.include?(category)\n #this is ineffecient because it will pull all catogories\n #self.categories << category 47:55\n self.post_categories.build(:category => category)\n\n #I need to create a catogory that is already associated with this post\n # and i need to make sure that this category already doesn't exist by name.\n end\n #end\n end\n\n end",
"def categories_attributes=(categories_hashes)\n # raise categories_hashes.inspect\n # {\"0\"=>{\"name\"=>\"new cat 1\"}, \"1\"=>{\"name\"=>new cat 2\"}}\n categories_hashes.each do |index, category_attributes|\n #need to create a category that is alrady assoicated with this post and make sure that this cateogry doesn't already exist\n\n #DO NOT CREATE A CATEGOERY if it doesn't have a name\n if category_attributes[:name].present?\n # also don't add a category if it already has it\n\n category = Category.find_or_create_by(name: category_attributes[:name])\n if !self.categories.include?(category)\n # post_categories\n # self.categories<< category\n self.post_categories.build(:category => category)\n end\n end\n end\n end",
"def categories_attributes=(categories_hashes)\n categories_hashes.each do |index, categories_attributes|\n if categories_attributes[:name].present?\n category = Category.find_or_create_by(name: categories_attributes[:name])\n if !self.categories.include?(category)\n self.post_categories.build(:category => category)\n end\n end\n end\n end",
"def generateChildNodeBy(hashCategory)\n\t\tif hashCategory.nil? then return nil\n\t\telse return treeDisplay(hashCategory) end\n\tend",
"def set_category\n @category = Category.find(params[:id])\n @category.orderable :display_order, :parent_category_id # I'm already calling this in Category::initialize, but apparently `find` doesn't ever `initialize` - be a lot cooler if it did...\n end",
"def set_hash\n # Create a new hash for the renderd boxes\n\t\t@categories = {\n 'purchasers' => {\n \"class\": Purchaser,\n \"name\": 'Purchaser'\n },\n 'endusers' => {\n \"class\": EndUser,\n \"name\":'End User'\n },\n 'purchaseorders' => {\n \"class\": PurchaseOrder,\n \"name\": 'Purchase Order'\n },\n 'keys' => {\n \"class\": Key,\n \"name\": 'Key'\n }\n }\n end",
"def set_categories\r\n csv = CSV.readlines(File.join('data', 'categories.csv'))\r\n @categories = csv.each_with_object({}) do |(key, val), hsh|\r\n hsh[key] = val\r\n end\r\n\r\n @items.each do |i|\r\n i.category = @categories[i.category]\r\n end\r\nend",
"def sort_categories\n #loop to sort categories parents and children\n for cat in @all_categories\n #if category parent id == nill then hash = current category else if parent id of category = nil then parent id hash is nil\n if(cat.parent_id.nil?)\n @all_categories_hash[0] = [cat]\n else\n if(@all_categories_hash[cat.parent_id].nil?)\n @all_categories_hash[cat.parent_id] = []\n end\n @all_categories_hash[cat.parent_id].push(cat)\n end\n end\n #Sort loop for categories\n for key in @all_categories_hash.keys\n @all_categories_hash[key].sort!{|x,y| x.name <=> y.name}\n end\n end",
"def create_child_items\n category.path.each do |category|\n create_child_item_for_category category\n end\n end",
"def add_category(hash, json) \n found = false\n hash[\"categories\"].each_with_index do |cat,index|\n if cat[\"name\"] == json[\"name\"]\n hash[\"categories\"][index] = json;\n found = true \n end\n break if found = true\n end\n #If we finished the loop without finding a same-name category,\n #append the new category\n if !found\n hash[\"categories\"] << json\n end\n end",
"def assign_category\n path = @row[:category]\n root = path.shift\n\n # this just needs to be set, for apparently no valid reason\n # I think think model is complely useless\n taxonomy = Spree::Taxonomy.find_or_create_by!(name:root)\n\n # here is real root of taxonomy tree\n taxon = Spree::Taxon.find_or_create_by!(parent_id: nil, taxonomy_id: taxonomy.id, name: root)\n\n # now check for existance of 2 parent elements, 3 and n+ is ignorred\n taxon = Spree::Taxon.find_or_create_by!(parent_id: taxon.id, taxonomy_id: taxonomy.id, name: path[0]) if path[0]\n taxon = Spree::Taxon.find_or_create_by!(parent_id: taxon.id, taxonomy_id: taxonomy.id, name: path[1]) if path[1]\n\n # it is weird why this model is named Spree::Classification instead of Spree::ProductsTaxon\n # it maps to \"spree_products_taxons\" table\n Spree::Classification.find_or_create_by! product_id: @product.id, taxon_id: taxon.id\n end",
"def edit\n #locates the selected category\n @category = Category.find(params[:id])\n #creates a sorted array using all categories\n @all_categories = Category.all.sort {|x,y| x.name <=> y.name }\n #creates an empty hash\n @child_categories = []\n #call to function to remove children - a parent cannot be moved to be a child of its own child.\n remove_children(@all_categories, @category)\n #re-assigns the array minus the categories children\n @all_categories = @all_categories - @child_categories\n\n if(!@category.parent_id.nil?)\n @items_to_select = [Category.find(@category.parent_id)]\n else\n @items_to_select = nil\n end\n\n end",
"def reset_hierarchy(categories_to_reset = self.all)\n ids = categories_to_reset.collect(&:id)\n\n link_table_entries.where(\"parent_id IN (?) OR child_id IN (?)\", ids, ids).delete_all\n\n descendant_table_entries.where(\"descendant_id IN (?) OR ancestor_id IN (?)\", ids, ids).delete_all\n\n categories_to_reset.each do |category|\n category.send :initialize_dag\n end\n end",
"def parse_categories_structure(category_id = nil)\n super category_id, { product_link: '.productsArea .productArea .productDetail a',\n next_page_link: '.productsArea .tsk-pageview .next a' }\n end",
"def move_to_child_of(category)\n self.update_attribute(:parent_id, category.id) unless self.parent_id == category.id\n end",
"def merge!\n duplicate_category.each_with_children {|subcategory| swap_businesses_and_taggings(subcategory) }\n duplicate_category.destroy\n end",
"def leaf_ids=(lids)\n\n save! if new_record?\n\n # Clear out all mention of the product from the entire tree.\n CategoryProduct.delete_all([\"product_id = ?\", self.id])\n\n lids.each do |lid|\n next if lid == \"none\"\n category = Category.find(lid)\n category.add_product(self, auto_prop)\n end\n end",
"def remove_children(categories, category)\n for cat in categories\n if(cat.parent_id == category.id)\n @child_categories.push(cat)\n remove_children(categories, cat)\n end\n end\n @child_categories.push(category)\n end",
"def from_hash(hash)\n hash.each do |key,value|\n new_node = value.is_a?(Hash) ? Tree::TreeNode.new(key).from_hash(value) : Tree::TreeNode.new(key,value)\n self << new_node\n end\n\n return self\n end",
"def parse_category_tree\n dry_run_notification\n\n page_html = get_page_html @donor.url\n\n if page_html\n main_category_last = page_html.css('.content > .main-cat').last\n return false if main_category_last.nil?\n main_category_last.css('> .cat-item > .middle').each do |parent_category|\n parent_category_link = get_category_link(parent_category.at_css('a'))\n\n next if parent_category_link[:name].empty? && parent_category_link[:path].empty?\n\n category_parent = save_category(parent_category_link) unless DRY_RUN\n display_category_structure(parent_category_link, \"#{'-' * 80}\\n\")\n\n if parent_category\n parent_category.css('.main-cat > .cat-item > .middle').each do |subcategory_first_level_node|\n subcategory_first_level_link = get_category_link(subcategory_first_level_node.at_css('a'))\n\n subcategory_first_level = save_category(subcategory_first_level_link, category_parent.id) unless DRY_RUN\n display_category_structure(subcategory_first_level_link, ' ' * 2)\n\n subcategory_first_level_node.css('.main-cat > .cat-item > .middle').each do |subcategory_second_level_node|\n subcategory_second_level_link = get_category_link(subcategory_second_level_node.at_css('a'))\n\n save_category(subcategory_second_level_link, subcategory_first_level.id) unless DRY_RUN\n display_category_structure(subcategory_second_level_link, ' ' * 4)\n end\n end\n end\n end\n end\n end",
"def set_category\n @category = LibraryCategory.find_by(:object_key => params[:library_category_id])\n\n add_breadcrumb @category.name, library_category_path(@category)\n end",
"def build_category_tree(n, child = nil)\n amz_node = BrowseNode.parse(n.to_s)\n amz_node.child = child unless child.nil?\n\n if n.search(\"./IsCategoryRoot\").size > 0\n @category_tree[amz_node.name] ||= []\n @category_tree[amz_node.name] << amz_node\n else\n parents = n.search(\"./Ancestors/BrowseNode\")\n if parents.size > 0\n build_category_tree(parents[0], amz_node)\n end\n end\n\n\n end",
"def categories_attributes=(categories_attributes)\n categories_attributes.values.each do |category_attributes|\n if category_attributes[:id].nil? and category_attributes[:name].present?\n category = Category.find_by_name(category_attributes[:name])\n if category.present?\n category_attributes[:id] = category.id\n ## FIXME? check if we are adding twice?\n self.categories << category\n end\n end\n end\n assign_nested_attributes_for_collection_association(:categories, categories_attributes.values, mass_assignment_options)\n end",
"def parse_category_tree\n dry_run_notification\n\n page_html = get_page_html \"#{@donor.url}/mall/index.htm\"\n return display_error \"\\e[33;1m#{self.class}##{__method__}\\e[0m failed to get page html\" if page_html.blank?\n\n page_html.css('#headerWarp .cateAllList ul li').each do |menu_item|\n category_link_level_1 = get_link menu_item.at_css('dt a')\n category_level_1 = save_category(category_link_level_1) unless DRY_RUN\n display_category_structure category_link_level_1, \"#{'-' * 80}\\n\"\n\n menu_item.css('dd a').each do |menu_sub_item|\n category_link_level_2 = get_link menu_sub_item\n save_category(category_link_level_2, category_level_1.id) unless DRY_RUN\n display_category_structure category_link_level_2, ' '\n end\n end\n end",
"def create_child_item_for_category(category)\n category.child_items.create(categorizable: self.categorizable, master_item: self)\n end",
"def set_categories\n @categories = {}\n @mechanize.page.search('//*[@id=\"prtcalst\"]//li').each do |cat|\n cat_link = cat.search('a')[0]\n cat_name = cat.search('.//em')[0].inner_text()\n catObj = Category.new()\n catObj.elem = cat_link\n catObj.name = cat_name\n @categories[cat_name] = catObj\n\n puts(\"#{cat_name}\")\n puts(\"-------------------\")\n end\n end",
"def update_nesting_categories(favorite_token)\n case favorite_token\n when '0'\n change_parent_favorite_to_zero\n when '1'\n change_parent_favorite_to_one\n end\n end",
"def save_hot_products_by_category\r\n Subcategory.fill_all_subcategories_of_category(params[:category][:fields][1])\r\n end",
"def destroy_category(category)\n #if category and id are nil return, else destroy all children of category then destroy parent.\n if(category.nil? || category.id.nil?)\n return\n end\n if(!@all_categories_hash[category.id].nil?)\n for child in @all_categories_hash[category.id]\n #calls itself to destroy children.\n destroy_category(child)\n end\n end\n #destroy parent category\n category.destroy\n end",
"def all_category_hash(item=nil)\n hash = {}\n items = []\n if(!item.nil?)\n for cat in @all_categories\n if(cat.parent_id.eql?(item.id))\n items.push(cat)\n end\n end\n else\n for cat in @all_categories\n if(cat.parent_id.nil?)\n items.push(cat)\n end\n end\n end\n for cat in items\n hash[cat] = all_category_hash(cat)\n end\n return hash\n end",
"def initialize(tree_hash)\n tree_hash.each do |k, v|\n @node_name = k\n @children = get_children_from(v)\n end\n end",
"def add_child\n category_id = params[:id].gsub('category_', '')\n @category = Category.find(category_id)\n parent_id = params[:parent_id]\n if parent_id\n @parent = Category.find(parent_id)\n @category.parent = @parent \n else\n @category.parent = nil\n end\n @category.save!\n render :update do |page|\n page.remove(\"category_#{@category.id}_row\")\n if @parent\n if @parent.name == ASSOCIATION.short_name\n page.replace_html(\"category_root\", :partial => \"category\", :collection => @parent.children.sort)\n else\n page.call(:expandDisclosure, parent_id)\n end\n end\n if @parent.nil?\n page.replace_html(\"unknown_category_root\", :partial => \"category\", :collection => Category.find_all_unknowns.sort)\n end\n end\n end",
"def categories_attributes=(categories)\n \tcategories.each do |index, category_hash|\n \t\tif category_hash[:name].present?\n\t\t\tcategory = Category.find_or_create_by(name: category_hash[:name])\n\t\t\tif !self.categories.include?(category)\n\t\t\t self.post_categories.build(:category => category) \n\t\t\tend\n end\n \tend\n end",
"def expand_category_ids\n\n #if we are on the filters brand page and the original url contains /categories we need to insert a dpc key into params\n if params[:originalURL].to_s.include?(\"/categories/\")\n parsed_original_url = params[:originalURL].split(\"/\")\n dpc_id = DPCategory.where(\"id = ? or param = ?\", parsed_original_url[2], parsed_original_url[2]).first.id\n #then we are on search/products or a brand page\n elsif !params[:id].nil? && params[:controller] == \"categories\" && params[:dpc].nil?\n dpc_id = DPCategory.where(\"id = ? or param = ?\", params[:id], params[:id]).first.id\n else\n #provides support for dpc[any] or dpc[all] in url\n params[:dpc] = nil if params[:dpc] == \"\"\n dpc_id = params[:dpc].try(:[],:any) || params[:dpc].try(:[],:all)\n end\n #match the DPCategory.id DPCategory.name that has been turned into a slug\n @dp_category = DPCategory.where(\"id in (?) or param in (?)\", dpc_id, dpc_id).first\n\n #we must set @dpc_param as nil here. otherwise we pass dpc with empty arrays to the searcher which will force zero results\n if @dp_category.blank?\n @dpc_param = nil\n #if we are working with a parent id\n elsif @dp_category.parent_id.blank?\n #expand the\n categories = []\n @dp_category.children.each do |dp_catg| \n categories << dp_catg.id\n dp_catg.children.each do |dp_catg_c|\n categories << dp_catg_c.id\n end\n end\n categories << @dp_category.id if categories.empty?\n @dpc_param = { :any => categories, :exact => [@dp_category.id] } \n elsif @dp_category.b_level? \n @dpc_param = { :any => @dp_category.children.collect { |dp_catg| dp_catg.id } << @dp_category.id, :exact => [@dp_category.id] }\n else\n @dpc_param = { :any => [ @dp_category.id ], :exact => [@dp_category.id] }\n end\n end",
"def category_attributes=(category_attributes) # arg. will be key value pair to search for/create\n self.category = Category.find_or_create_by(category_attributes)\n end",
"def set_category\n @category = @current_branch.categories.find(params[:id])\n end",
"def build_categories(product, mapped_categories)\n collection = []\n\n product[:categories].each do |category_name|\n mapped_categories.each do |mapped_category|\n build_category_tree(collection, category_name, mapped_category)\n end\n end\n\n collection\n end",
"def load_categories\n q = @db.query(\"select t.term_id, t.name, t.slug\n from wp_terms as t join wp_term_taxonomy as x\n on t.term_id = x.term_id\n where x.taxonomy = 'category'\")\n\n q.each_hash { |c| os = OpenStruct.new(c) ; @categories[os.term_id.to_i] = OpenStruct.new(c) }\n end",
"def categories_attributes=(category_attributes)\n # byebug\n category_attributes.values.each do |category_attribute|\n unless category_attribute['name'].empty?\n category = Category.find_or_create_by(category_attribute)\n self.categories << category \n end \n end\n end",
"def assign_category(categories_id)\n categories_id = [categories_id] if categories_id.is_a?(Integer)\n rescue_extra_data\n categories_id.each do |key|\n term_relationships.where(:term_taxonomy_id => key).first_or_create!\n end\n update_counters(\"categories\")\n end",
"def update_product_category\n return true if self.category.blank?\n categories = self.category.ancestors.collect{|x| x.id}.reverse.push(self.category.id)\n category_names = self.category.ancestors.collect{|x| x.name.downcase}.reverse.push(self.category.name.downcase).join(\" | \")\n product_cat = ProductCat.find_or_create_by_product_id(self.id)\n product_cat.fourth_category_id = categories[3] unless categories[3].blank?\n product_cat.third_category_id = categories[2] unless categories[2].blank?\n product_cat.second_category_id = categories[1] unless categories[1].blank?\n product_cat.first_category_id = categories[0] unless categories[0].blank?\n product_cat.categories_delimited = category_names\n product_cat.user = self.user\n product_cat.save\n end",
"def order\n # This will already have been deserialized by Rails, and is thus likely to\n # be an array (though maybe a Hash if there's only one of them).\n new_order = params[:order]\n new_order = [new_order] if new_order.is_a?(Hash)\n\n # Loop the roots and make them roots, then recursively set their children\n new_order.each do |h|\n id = h['id']\n category = Documents::Category.find(id)\n category.parent = nil\n category.save\n\n set_children_for(category, h)\n end\n\n head :no_content\n end",
"def categories_attributes=(category_attributes)\n category_attributes.values.each do |category_attribute|\n if !category_attribute[:name].empty?\n category = Category.find_or_create_by(category_attribute)\n self.categories << category\n end\n end \n \n end",
"def set_category\n end",
"def initialize()\n @childs = {}\n end",
"def initialize()\n @childs = {}\n end",
"def category_attributes=(category_attributes)\n category_attributes.values.each do |category_attribute|\n category = Category.find_or_create_by(category_attribute)\n self.categories << category\n end\n end",
"def populate_category\n\t\t\t\tif params[:purpose] == \"category\"\n\t\t\t\t\t\tcategory = Category.find(params[:category_id])\n\t\t\t\t\t\t@sub_categories = category.sub_categories\n\t\t\t\telsif params[:purpose] == \"sub_category\"\n\t\t\t\t\t\tsub_category = SubCategory.find(params[:category_id])\n\t\t\t\t\t\t@inner_categories = sub_category.inner_categories\n\t\t\t\tend\n\t\tend",
"def categories_attributes=(category_attributes)\t\n category_attributes.values.each do |category_attribute|\t\n category = Category.find_or_create_by(category_attribute)\t\n self.categories << category\t\n end\t\n end",
"def return_categories(key)\n if $redis.exists(key)\n categories = JSON.parse($redis.get(key))\n categories\n else\n data = fetch_categories()\n current_categories = []\n data.each do |child|\n add_category(key, child, current_categories)\n end\n return_categories(key)\n end\nend",
"def update\n @category = Category.find(params[:id])\n @rollover = @category.rollover\n \n unless params[:category][:parent_id].empty?\n @parent = Category.find(params[:category][:parent_id])\n @category.move_to_child_of(@parent) if @parent != @category.parent\n end\n \n respond_to do |format|\n if @category.update_attributes(params[:category]) and ( @rollover.update_attributes(params[:rollover]) unless @category.is_home?)\n flash[:notice] = 'Category was successfully updated.'\n format.html { redirect_to(@category) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def sort_categories\n for cat in @all_categories\n if(cat.parent_id == nil)\n @all_categories_hash[0] = [cat]\n else\n if(@all_categories_hash[cat.parent_id] == nil)\n @all_categories_hash[cat.parent_id] = []\n end\n @all_categories_hash[cat.parent_id].push(cat)\n end\n end\n for key in @all_categories_hash.keys\n @all_categories_hash[key].sort!{|x,y| x.name <=> y.name}\n end\n end",
"def filter_connec_entity_for_id_refs_helper(entity_hash, tree)\n return if tree.empty?\n\n entity_hash.slice!(*tree.keys)\n\n tree.each do |key, children|\n case entity_hash[key]\n when Array\n entity_hash[key].each do |hash|\n filter_connec_entity_for_id_refs_helper(hash, children)\n end\n when Hash\n filter_connec_entity_for_id_refs_helper(entity_hash[key], children)\n end\n end\n end",
"def update_hierarchy(top_node, retailer)\n @categories_to_save = []\n @translations_to_save = []\n @retailer = retailer\n traverse(top_node, 1, 1)\n \n # In a transaction, i.e. all of these must complete successfully, otherwise nothing is saved or deleted\n ActiveRecord::Base.transaction do\n current_categories = ProductCategory.where(:retailer => retailer)\n if current_categories.size >= 50 \n diff = current_categories.size - @categories_to_save.size\n if diff >= 0.5 * current_categories.size\n # If the number of categories has dropped by more than 50%\n raise BestBuyApi::InvalidFeedError, \"Current number of categories is #{current_categories.size} \" +\n \"while new number of categories is #{@categories_to_save.size}: categories will not be updated\"\n end\n end\n \n # delete the old categories for this retailer\n ProductCategory.where(:retailer => retailer).delete_all\n # save the new categories\n ProductCategory.import @categories_to_save\n # save all translations\n @translations_to_save.each do |key, english_name, french_name|\n I18n.backend.store_translations(:en, { key => {\"name\" => english_name} })\n I18n.backend.store_translations(:fr, { key => {\"name\" => french_name} })\n end\n end\n end",
"def categories_attributes=(attributes)\n attributes.each do |index, attribute|\n unless attribute[:title].blank? || self.categories.map(&:title).include?(attribute[:title])\n existing_category = self.categories[index.to_i]\n if existing_category == nil\n new_category = Category.create(title: attribute[:title])\n self.categories << new_category\n else\n existing_category.update(title: attribute[:title])\n end\n end\n end\n end",
"def categories()\n @web.get('http://www.waymarking.com/cat/categorydirectory.aspx') do |page|\n ile = 0\n #puts page.parser.to_html.to_s\n cache = {}\n\n page.parser.css('div#content div.gutter a').each do |cat|\n href = cat.attr('href')\n m = Category::GUID_REGEXP.match href\n key = Waymarking::Utils.parameterize(cat.text)\n unless m.nil? then\n ile +=1\n raise DuplicatedCategory if cache.has_key? key\n\n cache[key] = m[1]\n #puts \"#{ile} #{key} #{cat.text} #{m[1]}\"\n else\n puts href\n end\n\n end\n\n cache2 = {}\n cache.keys.each do |key|\n @web.get(\"http://www.waymarking.com/cat/details.aspx?f=1&guid=#{cache[key]}&exp=True\") do |page2|\n begin\n cat = Waymarking::Category.from_html(page2)\n cache2[key] = cat\n rescue\n puts key\n end\n end\n end\n\n File.open('categories.yml', 'w') do |f|\n f.write YAML::dump(cache2)\n end\n end\n end",
"def set_heirarchy\n @heirarchy = Heirarchy.find(params[:id])\n end",
"def initial_replace_sections(diary)\n\t\treturn if diary.nil? or !diary.visible? or !diary.categorizable?\n\n\t\tcategorized = categorize_diary(diary)\n\t\tcategorized.keys.each do |c|\n\t\t\tPStore.new(cache_file(c)).transaction do |db|\n\t\t\t\tdb['category'] = {} unless db.root?('category')\n\t\t\t\tdb['category'].update(categorized[c])\n\t\t\tend\n\t\tend\n\tend",
"def add_categories(collection)\n\tcategory = \"\"\n\tcollection[\"results\"][\"collection1\"].each do |article|\n\t\tif article[\"category\"] == \"\"\n article[\"category\"] = category\n else\n category = article[\"category\"]\n end\n\tend\nend",
"def placeIntoHashTree(hash, path, value)\n splitPath = path.split(%r{\\s*[:;]\\s*})\n deeper(hash, splitPath, value)\n end",
"def set_herb_category\n @herb_category = HerbCategory.find(params[:id])\n end",
"def parse_category_tree\n dry_run_notification\n sub_menu_url = \"#{donor_domain}/web/index.php/home/data_sub_menu\"\n page_html = get_page_html \"#{donor_domain}/web/\"\n page_html.css('#menu_ul li').each do |parent_category|\n parent_category_id = parent_category[:source3]\n next if parent_category_id.blank?\n\n # Get sub menu html by category id\n sub_menu_page_html = get_page_html(sub_menu_url, :post, { cat_id: parent_category_id })\n\n next if sub_menu_page_html.blank?\n\n parent_category_link = get_link sub_menu_page_html.at_css('a')\n\n # Parent category name en/th language versions separated by \"/\"\n parent_category_link[:name] = parent_category_link[:name].split(' / ')[('en' == @lang) ? 0 : 1]\n category_parent = save_category(parent_category_link) unless DRY_RUN\n display_category_structure(parent_category_link, \"#{'-' * 80}\\n\")\n\n sub_menu_page_html.css('.inner > ul > li').each do |subcategory_first_level_node|\n subcategory_first_level_link_node = subcategory_first_level_node.at_css('.a_header')\n subcategory_first_level_link = get_link(subcategory_first_level_link_node)\n # Name convert notes:\n # 1. Get raw link html with inner_html() in order to get en/th language versions separated by \"<br>\"\n # 2. Method content() convert html entities to characters: &Amp; --> &, โท --> โท\n # 3. Converting methods order: squish() must be the last operation, otherwise spaces left\n subcategory_first_level_link[:name] = get_name(\n Nokogiri::HTML.fragment subcategory_first_level_link_node.inner_html.split('<br>')[('en' == @lang) ? 0 : 1]\n )\n subcategory_first_level = save_category(subcategory_first_level_link, category_parent.id) unless DRY_RUN\n display_category_structure(subcategory_first_level_link, ' ' * 2)\n\n subcategory_first_level_node.css('.sub_menu a').each do |subcategory_second_level_node|\n subcategory_second_level_link = get_link(subcategory_second_level_node)\n save_category(subcategory_second_level_link, subcategory_first_level.id) unless DRY_RUN\n display_category_structure(subcategory_second_level_link, ' ' * 4)\n end\n end\n end if page_html\n end",
"def update_for_parent_store( parent_hash, key )\n \n unless @replaced_parents[ key ]\n \n register_parent_key( parent_hash, key )\n \n parent_hash_for_child = self\n\n @children.each do |this_hash|\n this_hash.instance_eval { update_for_parent_store( parent_hash_for_child, key ) }\n end\n \n end\n \n return self\n \n end",
"def categories_attributes=(category_attributes)\n category_attributes.values.each do |category_attribute|\n if category_attribute[\"name\"].present?\n category = Category.find_or_create_by(category_attribute)\n self.categories << category\n end\n end\n end",
"def set_categories(ids)\n self.categories = Category.find(ids)\n self.save\n end",
"def array\n # assign the sorted tree to a variable\n newlist = params[:ul].sort\n # initialize the previous item\n previous = nil\n #loop through each item in the new list (passed via ajax)\n newlist.each_with_index do |array, index|\n # get the category id of the item being moved\n moved_item_id = array[1][:id].gsub(/category_/,'')\n # find the object that is being moved (in database)\n @current_category = Category.find_by_id(moved_item_id)\n # if this is the first item being moved, move it to the root.\n unless previous.nil?\n @previous_item = Category.find_by_id(previous)\n @current_category.move_to_right_of(@previous_item)\n else\n @current_category.move_to_root\n end\n # then, if this item has children we need to loop through them\n unless array[1][:children].blank?\n # NOTE: unless there are no children in the array, send it to the recursive children function\n childstuff(array[1], @current_category)\n end\n # set previous to the last moved item, for the next round\n previous = moved_item_id\n end\n Category.rebuild!\n render :nothing => true\n end",
"def fetch_categories\r\n page = File.open(\"#{Rails.root}/public/Categories.html\") { |f| Nokogiri::HTML(f) }\r\n Category.save_fetched_categories_and_subcategories(page)\r\n end",
"def list\r\n\t\t@current_area = 'categories'\r\n\t\t@current_menu = 'products'\r\n\r\n\t\tif params[:select]\r\n\t\t\tif params[:delete]\r\n\t\t\t\t# you MUST manually move child nodes in an acts_as_tree up before calling\r\n\t\t\t\t# the destroy! method. Otherwise Rails will automatically go and delete all\r\n\t\t\t\t# the child nodes even before the selected nodes' 'before_destroy' callback\r\n\t\t\t\t# is triggered!\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tthe_cat = Category.find(k)\r\n\t\t\t\t\tthe_cat.move_children_up()\r\n\t\t\t\t\tCategory.destroy(the_cat.id)\r\n\t\t\t\tend\r\n\t\t\telsif params[:move_up]\r\n\t\t\t\t# We have to use a Hash as Array iterators do not like sparse indexing.\r\n\t\t\t\tselected_categories = Hash.new\r\n\t\t\t\tcat_index = Hash.new\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tc = Category.find(k)\r\n\t\t\t\t\tif selected_categories[c.parent_id].nil?\r\n\t\t\t\t\t\tselected_categories[c.parent_id] = Hash.new\r\n\t\t\t\t\tend\r\n\t\t\t\t\tselected_categories[c.parent_id][c.id] = c.sequence\r\n\t\t\t\t\tcat_index[c.id] = c\r\n\t\t\t\tend\r\n\t\t\t\tselected_categories.each do |i, parent|\r\n\t\t\t\t\t# Hash.sort converts the hash into a nested array before sorting; [0] = key, [1] = value.\r\n\t\t\t\t\t# Note that we only want the IDs which are contained in the index 'j'.\r\n\t\t\t\t\tparent.sort{|a,b| (a[1]<=>b[1])}.each do |j, the_sequence|\r\n\t\t\t\t\t\tcat_index[j].move_higher\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\telsif params[:move_down]\r\n\t\t\t\t# See comments for move_up above\r\n\t\t\t\tselected_categories = Hash.new\r\n\t\t\t\tcat_index = Hash.new\r\n\t\t\t\tparams[:select].keys.each do |k|\r\n\t\t\t\t\tc = Category.find(k)\r\n\t\t\t\t\tif selected_categories[c.parent_id].nil?\r\n\t\t\t\t\t\tselected_categories[c.parent_id] = Hash.new\r\n\t\t\t\t\tend\r\n\t\t\t\t\tselected_categories[c.parent_id][c.id] = c.sequence\r\n\t\t\t\t\tcat_index[c.id] = c\r\n\t\t\t\tend\r\n\t\t\t\tselected_categories.each do |i, parent|\r\n\t\t\t\t\t# Note order of b/a is swapped to move down. This and move_lower instead of move_higher\r\n\t\t\t\t\t# is the only difference between this and the move_up code above.\r\n\t\t\t\t\tparent.sort{|a,b| (b[1]<=>a[1])}.each do |j, the_sequence|\r\n\t\t\t\t\t\tcat_index[j].move_lower\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\texpire_fragment(:controller => :products, :action => :home, :part => 'category_menu')\r\n\t\tend\r\n\r\n\t\t@root_cat = Category.find(1)\r\n\tend",
"def category_candidates(category)\n return @category_cache[category] unless @category_cache[category].nil?\n candidates = candidates_for_name(singularize_name(category.name, category.head), @category_filters)\n if !candidates.empty?\n candidate_set = create_candidate_set(category.name,candidates)\n else\n candidate_set = candidate_set_for_syntax_trees(category.head_trees,@category_filters)\n end\n if candidate_set.empty?\n candidates = candidates_for_name(category.name, @category_filters)\n candidate_set = create_candidate_set(category.name,candidates) unless candidates.empty?\n end\n @category_cache[category] = candidate_set\n end",
"def exercise_category_attributes=(category)\n self.exercise_category = ExerciseCategory.find_by_id(category[:category])\n unless self.exercise_category\n self.exercise_category = ExerciseCategory.find_or_initialize_by_category(category)\n end\n end",
"def apply_category_filter\n top_level_category_ids = Category.top_level.\n where(id: @category_ids).\n pluck(:id)\n subcategory_ids = @category_ids +\n Category.where(parent_id: top_level_category_ids).pluck(:id)\n\n subcategory_ids\n end",
"def categories_by_taxonomy\n\n self.categories.inject({}) do |result, category|\n \n if result.has_key?(category.taxonomy.id.to_sym)\n result[category.taxonomy.id.to_sym] << category\n else\n result[category.taxonomy.id.to_sym] = [category]\n end\n \n result \n end \n\n end",
"def orphan_child_categories\n self.children.each do |child|\n child.parent_id = nil\n child.save\n end\n end",
"def children= (c)\n end",
"def set_root_category\n @root_category = RootCategory.find(params[:id])\n end",
"def build_accounts_by_tree(root_category)\n accounts = root_category.accounts.to_a\n if root_category.has_children?\n root_category.children.each {|category|\n accounts.concat(build_accounts_by_tree(category))\n }\n end\n accounts\n end",
"def sort\r\n key = params.keys.grep(/m(?:aj|in)ors/).shift # Get DOM ID.\r\n order, parent = params[key], key[/\\d+/] # Filter out category ids.\r\n attrs = order, (1..order.length).map { |p| { :position => p } }\r\n unless parent.nil? # Scope\r\n instance.idea_categories.find(parent).subcategories.update *attrs\r\n else\r\n instance.idea_categories.update *attrs\r\n end\r\n render(:update) { |page| page.visual_effect :highlight, key }\r\n end",
"def parse_categories_structure(category_id)\n dry_run_notification\n\n total_products_count = 0\n categories = donor_categories_to_parse(category_id)\n display_info \"Total categories count: \\e[34;1m#{categories.count}\\e[0m\"\n\n initialize_capybara do\n categories.find_each do |category|\n category_name = \"#{category.name_eng.blank? ? category.name : category.name_eng} (id: #{category.id})\"\n category_products_count = parse_category category.id, category_name, \"#{@donor.url}#{category.path}\"\n total_products_count += category_products_count\n category_post_processing_message (category_products_count > 0), category_name, category_products_count\n # category.update(product_list_parsed_at: Time.zone.now) unless DRY_RUN # Update category product list parse date\n end\n end\n display_info \"Total products count: \\e[34;1m#{total_products_count}\\e[0m\"\n end",
"def massageHash(h,top)\n resourceType = nil\n \n # if this is a FHIR class, convert to a hash\n if is_fhir_class?(h.class.name)\n resourceType = h.class.name.demodulize\n h = Marshal.load(Marshal.dump(h.attributes))\n end\n \n if h.is_a? Hash\n # remove \"_id\" attributes\n h.delete(\"_id\")\n # loop through all the entries in the hash\n h.each do |key,value|\n # massage entries that are also hashes...\n if value.is_a? Hash\n h[key] = massageHash(value,false)\n # massage entries that are arrays...\n elsif value.is_a? Array\n # replace each item in the array...\n value.map! do |item|\n if item.is_a? Hash\n next massageHash(item,false) # .. with a massaged hash\n # serialize FHIR children correctly\n elsif is_fhir_class?(item.class.name)\n next massageHash(item,false) # .. with a hash representation of an object\n else\n next item # .. or with the item itself (probably primitive data type)\n end\n end\n # after massaging the array, remove empty arrays\n if value.empty?\n h.delete(key)\n end\n # remove empty attributes\n elsif value.nil?\n h.delete(key)\n # massage entires that are FHIR classes...\n elsif is_fhir_class?(value.class.name)\n h[key] = massageHash(value,false)\n else\n #puts \"Ignoring '#{key}' inside '#{value.class.name}' of type '#{value.class.name}'\"\n end\n \n # add W3C namespace to <div/> tags\n # if key == 'div'\n # i = (h[key] =~ /^<div>/)\n # j = (h[key] =~ /^<div/)\n # if i==0\n # # replace the <div/> tag w/ one with the namespace\n # h[key] = '<div xmlns=\"http://www.w3.org/1999/xhtml\">' + value[5..value.length]\n # elsif i!=0 and j!=0\n # # there is no div tag at all -- add the full <div/> tag w/ namespace\n # h[key] = '<div xmlns=\"http://www.w3.org/1999/xhtml\">' + value + '</div>'\n # end\n # end\n \n end \n end\n \n # if this is a FHIR class, add the 'resourceType' attribute\n if top and !resourceType.nil?\n h['resourceType'] = resourceType\n end\n \n fix_all_keys(h)\n end",
"def category= arg\n cat_arr = arg.to_s.split(':')[0..@depth-1] || []\n @category = cat_arr.join(':').to_s\n end",
"def create\n #Creates the category to be saved in the db\n @category = Category.new(params[:category])\n @all_categories = Category.all\n\n #Set Component Group to nil\n if(!@category.parent_id.nil?)\n @category.parent_id = nil\n end\n #Sets Component Group with new params\n if(!params[:parent_ids].nil?)\n for id in params[:parent_ids]\n @category.parent_id = id\n end\n end\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n next if k[:xml_name] == 'ConsAssm'\n\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def update_categories(cats=[])\n rescue_extra_data\n cats = cats.to_i\n old_categories = categories.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")\n delete_categories = old_categories - cats\n news_categories = cats - old_categories\n term_relationships.where(\"term_taxonomy_id in (?)\", delete_categories ).destroy_all if delete_categories.present?\n news_categories.each do |key|\n term_relationships.create(:term_taxonomy_id => key)\n end\n update_counters(\"categories\")\n end",
"def children=(node_or_tags); end",
"def children=(node_or_tags); end",
"def category_menu_items(aRootCategory, aOptions={})\n\t\t\taBaseUrl = (aOptions[:base_url] || '')\n\t\t\taIdPrefix = (aOptions[:id_prefix] || '')\n\t\t\tcategory = aOptions[:category]\n\t\t\tcategory = category.name.urlize('+') if category.is_a?(Category)\n\t\t\ttree_nodes = construct_category_tree(aRootCategory)\n\t\n\t\t\t# now turn tree_nodes into menu items, still as array of levels\n\t\t\ttree_items = []\n\t\t\tlast_lvl = nil\n\t\t\ttree_nodes.each do |lvl|\n\t\t\t\titem_level = []\n\t\t\t\tlvl.each do |node|\n\t\t\t\t\tname = (node.name.index('/') ? File.basename(node.name) : node.name)\n\t\t\t\t\titem = {:id => aIdPrefix+node.id.to_s, :name => name }\t\n\t\t\t\t\titem[:node] = node\n\t\t\t\t\tif last_lvl && parent_item = last_lvl.find {|i| i[:node].id == node.parent_id}\n\t\t\t\t\t\tparent_item[:children] ||= []\n\t\t\t\t\t\tparent_item[:children] << item\n\t\t\t\t\t\titem[:url] = parent_item[:url]\n\t\t\t\t\t\titem[:url] += '+' unless item[:url]=='' || item[:url].ends_with?('/') || item[:url].ends_with?('+')\n\t\t\t\t\t\titem[:url] += name.urlize('-')\n\t\t\t\t\telse\n\t\t\t\t\t\titem[:url] = File.join(aBaseUrl,name.urlize('-'))\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\titem[:selected] = true if category && (category==node.name.urlize('+'))\n\t\t\t\t\titem[:order] = aOptions[:order_proc].call(item) if aOptions.has_key?(:order_proc)\n\t\t\t\t\titem_level << item\n\t\t\t\tend\n\t\t\t\ttree_items << item_level\n\t\t\t\tlast_lvl = item_level\n\t\t\tend\n\t\t\t# clean\n\t\t\ttree_items.each do |lvl|\n\t\t\t\tlvl.each do |i| \n\t\t\t\t\ti.filter_include!([:url,:selected,:id,:name,:children,:order])\n\t\t\t\t\ti[:children].sort! {|a,b| a[:order].to_i <=> b[:order].to_i} if i[:children].is_a?(Array)\n\t\t\t\tend\n\t\t\tend\n\t\t\ttree_items.first.sort! {|a,b| a[:order].to_i <=> b[:order].to_i}\n\t\t\ttree_items.first\n\t\tend",
"def categories(options = {})\n fetch_categories.at('categories').children_of_type('category').inject([]){ |r, i| r << parse_single_category_xml(i) }\n\tend",
"def initialize_copy(_original)\n new_children = {}\n @children.each do |child_name, child_group|\n new_children[child_name] = []\n child_group.each do |child|\n cloned_child = child.clone\n cloned_child.parent = self\n # cloned_child.root = @root\n new_children[child_name] << cloned_child\n end\n end\n @children = new_children\n end",
"def db_seed_categories\n path = Rails.root.join('db','seeds','categories.yml')\n File.open(path) do |file|\n YAML.load_stream(file) do |doc|\n doc.keys.sort.each do |key|\n # puts \"Seeding comparison category structure #{key}\"\n # puts \"Warning this will delete any comparison category <-> question relationships existing for any duplicate categories\"\n attributes = doc[key]\n db_seed_category(attributes)\n end\n end\n end\nend",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end"
] |
[
"0.6269093",
"0.60685337",
"0.60029465",
"0.6001196",
"0.58774406",
"0.5875418",
"0.5862771",
"0.586245",
"0.58206314",
"0.57982236",
"0.5791305",
"0.5769516",
"0.5747947",
"0.5711258",
"0.56724143",
"0.5650478",
"0.5640234",
"0.55902344",
"0.5530768",
"0.55278486",
"0.55253804",
"0.5500232",
"0.54738146",
"0.5460295",
"0.54552174",
"0.54301167",
"0.54275656",
"0.5408158",
"0.5386429",
"0.53656596",
"0.535843",
"0.5355695",
"0.5352052",
"0.53500646",
"0.5344809",
"0.53068775",
"0.52939904",
"0.529225",
"0.52784735",
"0.5274937",
"0.52597106",
"0.5252179",
"0.52484787",
"0.5235359",
"0.5227233",
"0.52217245",
"0.52163213",
"0.5209415",
"0.5197461",
"0.51783884",
"0.51592255",
"0.51567465",
"0.5147327",
"0.5147327",
"0.5147099",
"0.51452714",
"0.51434654",
"0.5139292",
"0.5132446",
"0.5126414",
"0.51145875",
"0.51136047",
"0.5111638",
"0.5102205",
"0.5098487",
"0.5095696",
"0.5063991",
"0.50631136",
"0.50464",
"0.50363374",
"0.5035228",
"0.50277334",
"0.50246346",
"0.50176674",
"0.49950847",
"0.49812084",
"0.49793813",
"0.49778172",
"0.4970951",
"0.49658975",
"0.496388",
"0.4963012",
"0.4957822",
"0.49539703",
"0.495392",
"0.49532944",
"0.49477404",
"0.4946834",
"0.49295506",
"0.49238348",
"0.4921829",
"0.49218267",
"0.49218267",
"0.49187836",
"0.49187312",
"0.49141595",
"0.49121505",
"0.4907145",
"0.4907145",
"0.4907145"
] |
0.80368084
|
0
|
Return a list of all journals that can be added to a category
|
def journal_list
ret = []
offset = 0
loop do
result = RLetters::Solr::Connection.search(
q: '*:*',
def_type: 'lucene',
rows: 1,
'facet.count': '100',
'facet.offset': offset.to_s
)
break unless result.facets
facets = result.facets.for_field(:journal_facet)
break unless facets
break if facets.empty?
available_facets = facets.map do |f|
f.hits.positive? ? f.value : nil
end
available_facets.compact!
break if available_facets.empty?
ret.concat(available_facets)
offset += 100
end
ret
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def meal_categories\n # API EXAMPLE: https://www.themealdb.com/api/json/v1/1/list.php?c=list\n content = api_call('list.php?c=list')\n validate(content)\n content\n end",
"def list\n @journals = Journal.all\n end",
"def all_categories\n end",
"def categories\n add_to_query restrict_kind: 'category'\n end",
"def journals\n subcomponents[\"VJOURNAL\"]\n end",
"def all_categories\n stories.map(&:category).delete_if {|c| c.nil?}.uniq\n end",
"def categories\n category\n end",
"def categories\n []\n end",
"def check_categories!\n\n self.categories.map! do |category|\n if (not category.saved?) and loaded_category = Term.get(category.id)\n loaded_category\n else\n category\n end\n end\n\n end",
"def multiple_categories\n @categories = Category.all\n end",
"def get_missions_in_cat\r\n missions = []\r\n \r\n return missions\r\n end",
"def list\n categories = Meal.distinct.pluck(:category)\n meal_list = []\n categories.each { |category|\n obj = {\n groupName: category.capitalize,\n options: Meal.where(category: category).select(:id, :name)\n }\n meal_list.push(obj)\n }\n\n render json: meal_list\n end",
"def getCategories\n @categories = []\n @categories << Category.new(name: \"All\", id: -1)\n @categories += Category.all\n end",
"def index\n # @categories = current_user.categories\n @categories = Category.accessible_by(current_ability).all\n end",
"def category_params\n params.require(:documents_category).permit(:name, journals: [])\n end",
"def categories\n\t\t\t@cat_cache ||= @db.js('musicthoughts.all_categories()').map {|c| c.merge(category: c[@lang]) }\n\t\t\t@cat_cache\n\t\tend",
"def journals(options = {})\n options[:page] ||= 1\n options[:per_page] ||= REGISTRY[:journals_per_page]\n\n journals =\n if self.has_access?(:journal_show_all)\n if options[:page].to_i < 4 # only cache first pages, since they're used more often\n cache_fetch(\"journals_all_paged_#{options[:page]}_#{options[:per_page]}\") do\n Journal.paginate(:all, options)\n end\n else\n Journal.paginate(:all, options)\n end\n elsif self.has_access?(:journal_show_centeradm)\n cache_fetch(\"journals_groups_#{self.center_id}_paged_#{options[:page]}_#{options[:per_page]}\", :expires_in => 10.minutes) do\n Journal.in_center(self.center).paginate(:all, options)\n end\n elsif self.has_access?(:journal_show_member)\n group_ids = self.group_ids(options[:reload]) # get teams and center ids for this user\n if options[:page].to_i < 4 # only cache first 5 pages\n journals = cache_fetch(\"journals_groups_#{group_ids.join(\"_\")}_paged_#{options[:page]}_#{options[:per_page]}\") do\n Journal.all_parents(group_ids).paginate(:all, options)\n end\n else \n Journal.all_parents(group_ids).paginate(:all, options)\n end\n elsif self.has_access?(:login_user)\n entry = JournalEntry.find_by_user_id(self.id)\n [entry.journal]\n elsif self.has_access?(:journal_show_none)\n journals = []\n journals = WillPaginate::Collection.create(options[:page], options[:per_page]) do |pager|\n pager.replace(journals) # inject the result array into the paginated collection:\n end\n else # for login-user\n [] # or should it be the journal the login_user is connected to?\n end\n return journals\n end",
"def categories_list\n self.categories.collect{|c| c.name}\n end",
"def categories\n notify Category.all(:order => \"name ASC\").collect {|c| c.name_with_id }.join(\"\\n\")\n end",
"def journals(options = {})\n options[:page] ||= 1\n options[:per_page] ||= REGISTRY[:journals_per_page]\n\n journals =\n if self.has_access?(:journal_show_all)\n if options[:page].to_i < 4 # only cache first pages, since they're used more often\n Rails.cache.fetch(\"journals_all_paged_#{options[:page]}_#{options[:per_page]}\") do\n Journal.and_person_info.paginate(:all, options)\n end\n else\n Journal.and_person_info.paginate(:all, options)\n end\n elsif self.has_access?(:journal_show_centeradm)\n Rails.cache.fetch(\"journals_groups_#{self.center_id}_paged_#{options[:page]}_#{options[:per_page]}\", :expires_in => 10.minutes) do\n Journal.and_person_info.in_center(self.center).paginate(:all, options)\n end\n elsif self.has_access?(:journal_show_member)\n group_ids = self.group_ids(options[:reload]) # get teams and center ids for this user\n if options[:page].to_i < 4 # only cache first 5 pages\n journals = Rails.cache.fetch(\"journals_groups_#{group_ids.join(\"_\")}_paged_#{options[:page]}_#{options[:per_page]}\") do\n Journal.and_person_info.all_parents(group_ids).paginate(:all, options)\n end\n else \n Journal.and_person_info.all_parents(group_ids).paginate(:all, options)\n end\n elsif self.has_access?(:login_user)\n entry = JournalEntry.find_by_user_id(self.id)\n [entry.journal]\n elsif self.has_access?(:journal_show_none)\n journals = []\n journals = WillPaginate::Collection.create(options[:page], options[:per_page]) do |pager|\n pager.replace(journals) # inject the result array into the paginated collection:\n end\n else # for login-user\n [] # or should it be the journal the login_user is connected to?\n end\n return journals\n end",
"def categories\n data['JobCategory'] || []\n end",
"def all_categories\n @mutex.synchronize do\n @categories.keys\n end\n end",
"def index\n @law_categories = LawCategory.all\n end",
"def all_categories\n\t\t@categories = Category.all\n\tend",
"def list\n @categories = current_user.categories.where locked: false\n end",
"def categories\n stories.map(&:category).delete_if {|c| c.nil? or c.global}.uniq\n end",
"def get_categories\n @categories = Category.all\n end",
"def categories\n return @categories\n end",
"def categories\n return @categories\n end",
"def categories\n return @categories\n end",
"def categories_list\n @categories = Category.all.collect { |p| [p.name, p.id] }\n end",
"def categories\n return @todo_container.keys\n end",
"def categories\n rpg_shop.handled_categories\n end",
"def all_categories(shortlist = false)\n\t\tall = shortlist ? GLOBAL_CATEGORIES[0..3] : GLOBAL_CATEGORIES\n\t\t#all << 'An extra category'\n\tend",
"def potential_categories\n if categories.length > 0\n Category.all(:conditions => \"id NOT IN (#{category_ids})\")\n else\n Category.all\n end\n end",
"def categories\n Category.categories_for_movie self\n end",
"def writeable_categories\n # {{{\n if !@writeable_categories then\n if is_admin? then\n @writeable_categories = Category.select { |c|\n c.order_by(:is_private)\n c.order_by(:category_name, :asc)\n }\n else\n parent_group_ids = []\n if respond_to?(:parent_groups) then\n parent_group_ids = parent_groups.map { |g| g.user_group_id }\n end\n if is_registered? then\n @writeable_categories = Category.select { |c| \n c.where((Category.public_writeable == 't') | \n (Category.registered_writeable == 't') | \n (Category.category_id.in(User_Category.select(User_Category.category_id) { |ucid|\n ucid.where((User_Category.user_group_id.in(parent_group_ids + [ user_group_id ])) &\n (User_Category.write_permission == 't'))\n }) \n ))\n c.order_by(:category_name, :asc)\n }.to_a\n else\n @writeable_categories = Category.select { |c| \n c.where((Category.public_writeable == 't') |\n (Category.category_id.in(User_Category.select(User_Category.category_id) { |ucid|\n ucid.where((User_Category.user_group_id.in(parent_group_ids + [ user_group_id ])) &\n (User_Category.write_permission == 't'))\n })\n ))\n c.order_by(:category_name, :asc)\n }.to_a\n end\n end\n end\n @writeable_categories\n end",
"def get_catagories_for_mission\r\n catagories = []\r\n\r\n unlock_missions << self.mission if self.mission\r\n unlock_missions.concat(Mission.find_all_with_tag(self.tag)) if self.tag\r\n \r\n return catagories\r\n end",
"def awarded_categories\n awards.map do |award|\n award.meal.category\n end\n end",
"def categories\n return @categories\n end",
"def categories\n @categories ||= wayfinder.decorated_vocabularies.sort_by(&:label)\n end",
"def administered_journals\n journal_query = Journal.all\n journal_query = yield(journal_query) if block_given?\n if site_admin?\n journal_query\n else\n roles = [:manage_users, :administer]\n filter_authorized_set(roles, journal_query)\n end\n end",
"def get_categories\n @cards.each do |card|\n if !@categories.include?(card.category)\n @categories << card.category\n end\n end\n @categories\n end",
"def index\n @cabals=[]\n if !current_user.cabals.nil?\n @cabals=current_user.cabals\n end\n end",
"def journals(options = {})\n page_opts = {:page => options.delete(:page) || 1, :per_page => options.delete(:per_page) || Journal.per_page}\n includes = options.delete(:include)\n puts \"journals options: #{options.inspect}\"\n center = options.delete :center\n center = nil if center && center.to_i == 0\n team = options.delete :team\n team = nil if team && team.to_i == 0\n column = options.delete(:column) || 'created_at'\n order = options.delete(:order) || 'desc'\n\n journals =\n if self.has_access?(:journal_show_all)\n Journal.in_center(center).for_group(team).where(options).includes(includes).order_by(column,order).paginate(page_opts)\n elsif self.has_access?(:journal_show_centeradm)\n # TODO: cache\n # cache_fetch(\"journals_groups_#{self.center_id}_paged_#{options[:page]}_#{options[:per_page]}\", :expires_in => 10.minutes) do\n Journal.in_center(self.center).for_group(team).includes(includes).order_by(column,order).paginate(page_opts)\n # end\n elsif self.has_access?(:journal_show_member)\n group_ids = self.group_ids #(options[:reload]) # get teams and center ids for this user\n if page_opts[:page].to_i < 4 # only cache first 5 pages\n # TODO: cache\n journals = # cache_fetch(\"journals_groups_#{group_ids.join(\"_\")}_paged_#{options[:page]}_#{options[:per_page]}\") do\n Journal.all_groups(group_ids).for_group(team).includes(includes).order_by(column,order).paginate(page_opts)\n # end\n else \n Journal.all_groups(group_ids).for_group(team).includes(includes).order_by(column,order).paginate(page_opts)\n end\n elsif self.login_user?\n entry = JournalEntry.find_by_user_id(self.id)\n [entry.journal]\n elsif self.has_access?(:journal_show_none)\n journals = []\n journals = WillPaginate::Collection.create(options[:page], options[:per_page]) do |pager|\n pager.replace(journals) # inject the result array into the paginated collection:\n end\n else # for login-user\n [] # or should it be the journal the login_user is connected to?\n end\n return journals\n end",
"def categories\n return [] if @feed.channel.categories.empty? && @feed.channel.dc_subjects.empty?\n [@feed.channel.categories, ((@feed.channel.dc_subjects.empty?) ? nil : @feed.channel.dc_subjects)].flatten.uniq.compact.collect{|c| c.content}.reject{|c| c == '' || c.match(/^\\s+$/)}\n end",
"def all_category_ids\n end",
"def categories_for(race)\n [ race.category ] + race.category.descendants\n end",
"def index\n @journals = Journal.all\n end",
"def index\n @journals = Journal.all\n end",
"def index\n @journals = Journal.all\n end",
"def all(params = {})\n handle_all_request(\"/categories\", :categories, params)\n end",
"def get_categories_list\n args = receive_should_validate?\n get('redtube.Categories.getCategoriesList', {}, [], args[:should_validate])\n end",
"def index\n @personality_categories = PersonalityCategory.all\n end",
"def index\n @room_categories = RoomCategory.all\n end",
"def index\n @categories = Category.all\n @categories.each do |category|\n authorize! :read, category\n end\n render json: @categories\n end",
"def index\n @category_to_categories = CategoryToCategory.all\n end",
"def categories\n taxonomies.all :conditions => { :classification => :category }\n end",
"def get_lookups\n\t @categories = Category.ordered \n\t\t@ownerships = Ownership.ordered\n end",
"def categories_items\n all_items = self.all_active_items\n categories_given_items(all_items)\n end",
"def categories_for_solution_search(category)\n [Sfcatnode.root] + category.children\n end",
"def core_category_candidates(category)\n candidates = []\n singularize_name_nouns(category.name, category.head).each do |phrase|\n candidates.concat(candidates_for_name(phrase, @category_filters))\n\n end\n candidate_set = create_candidate_set(category.name,candidates.uniq)\n end",
"def categories\n categories = []\n @deck.cards.map do |turn|\n categories << turn.category\n end\n categories.uniq!\n end",
"def categories\n return [] if @categories.blank?\n @categories.records.map {|c| c.display_name}\n end",
"def categories\n @categories = FinanceTransactionCategory.all(:conditions => {:deleted => false}, :order => 'name asc')\n @categories = @categories.select { |x| x.accessible? }\n @category_ids = @categories.map { |cat| cat.id if FinanceTransaction.find_by_category_id(cat.id).present? }.compact\n @multi_config = FinanceTransactionCategory.get_multi_configuration\n @fee_category_present = FinanceFeeCategory.first\n # @fixed_categories = @categories.reject { |c| !c.is_fixed }\n # @other_categories = @categories.reject { |c| c.is_fixed }\n end",
"def find_agenda_item_categories\n @categories = AgendaItemCategory.all(:order => 'name')\n end",
"def assign_categories_for_admin\n categories = Category.all\n @categories = []\n categories.each { |category| @categories << [category.name, category.id] }\n end",
"def make_item_list\n @data = @category ? $game_party.quests.list(@category) : []\n end",
"def categories\n nodes = @doc.xpath(\"atom:feed/atom:category\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomCategory.new(node) }\n end",
"def main_categories\n categories.to_a[0..3]\n end",
"def categories(args={})\n res = api_request('private.request.getCategories', 'GET')\n res = JSON.parse(res)['category'] rescue []\n\n unless args[:include_deleted] and args[:include_deleted] == true\n res.reject!{|k, v| v['fDeleted'] == '1'} rescue []\n end\n \n return res\n end",
"def categories()\n db = connect()\n db.execute('SELECT * FROM categories')\n end",
"def categories_as_basic_with_all(returned = [])\r\n returned << categories.map { |x| { id: x.id, name: x.name }}\r\n returned.insert(0, { id: 0, name: \"All Categories\" })\r\n\r\n returned.flatten(1)\r\n end",
"def categories\n categories = Array.new\n unless self.category.nil?\n categories << self.category\n categories += self.category.ancestors\n end # unless\n categories.reverse\n end",
"def index\n @all_categories = CateItem.all\n end",
"def index\n\t\tcreator_categories\n\tend",
"def crew\n crew_categories.map{ |category| parse_crew(category) }.flatten\n end",
"def index\n @categories = Category.roots\n end",
"def list_categories\n list_categories_button\n wait_for_ajax\n self.class.class_eval { include AddRemoveCategories }\n end",
"def index\n @admin_categories = Category.all\n end",
"def find_all_sidebar_submenu_category(category)\n if !category.children.empty?\n html_code = ''\n category.children.each do |sub_category|\n html_code += '<div class=\"col-sm-12 col-md-3\">\n <ul class=\"links list-unstyled\">'\n html_code += print_sidebar_submenu_category(sub_category)\n html_code += '</ul></div>'\n end\n end\n html_code += ''\n end",
"def meals_by_category(category)\n # API EXAMPLE: https://www.themealdb.com/api/json/v1/1/filter.php?c=Seafood\n content = api_call(\"filter.php?c=#{category}\")\n validate(content)\n content\n end",
"def index\n @categories = current_user.categories.filter_conditions(params[:name])\n end",
"def category_names\n self.categories.map do |category|\n category.name\n end\n end",
"def index\n @moment_categories = MomentCategory.all\n end",
"def category_index\n @name = params[:category]\n \n category = Category.where(name: @name)\n \n #get bookmarks\n if category.empty? || category == nil\n redirect_to :root\n else\n category = category[0]\n @results = []\n\n category.bookmarks.each do |b|\n user_url = \"/\" + b.user.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: b.user.name, user_url: user_url }\n @results.push(entry) \n end\n end\n \n #check to see if user is a subscriber\n if user_signed_in? && category.subscriber?(current_user)\n @is_subscriber = true\n else\n @is_subscriber = false\n end\n\n #check to see if user is moderator\n if user_signed_in? && category.moderator?(current_user)\n @is_moderator = true\n end\n \n end",
"def add_categories(collection)\n\tcategory = \"\"\n\tcollection[\"results\"][\"collection1\"].each do |article|\n\t\tif article[\"category\"] == \"\"\n article[\"category\"] = category\n else\n category = article[\"category\"]\n end\n\tend\nend",
"def category_info\n {\n categories: self.object.appointments.map{ |appt| \n appt.category\n }\n \n }\n end",
"def category\n catName = params[:title]\n @meals = Meal.where(\"category like ?\", catName)\n end",
"def category_sets(category)\n category.curriculum_category_sets.map do |category_set|\n complete[category][category_set] = category_set.courses & taken_courses\n\n get_incomplete_from_set(category, category_set)\n end\n end",
"def index\n @contractor_categories = ContractorCategory.all\n end",
"def categories_for(race)\n case race.name\n when \"Junior Men\", \"Junior Women\"\n [ Category.find_or_create_by(name: race.name) ]\n else\n super race\n end\n end",
"def index\n @categories = current_user.categories\n end",
"def index\n @ilance_categories = IlanceCategory.all\n end",
"def category_links(category)\n links = \"\"\n iterated_cat = category\n if iterated_cat.parent.nil?\n links = insert_category_link(links,iterated_cat)\n else \n i = 0\n while !iterated_cat.parent.nil? and iterated_cat != Sfcatnode.root\n links = insert_category_link(links,iterated_cat)\n iterated_cat = iterated_cat.parent\n i+= 1\n end\n end\n links.insert(0,\"#{link_to('All Solutions', :action => 'index')}\")\n end",
"def category_types\n @category_types.each\n end",
"def index\n\t\t@categories = Category.all\n\tend",
"def new_objects\n @gadget = Gadget.new\n \n @allCategories = Category.order(\"id asc\").all.map{|u| [u.name, u.id]}\n end",
"def getCategories(_, _, _)\n @db.categories\n end",
"def users\n category_users.uniq\n end",
"def categories\n self.button(:id=>\"entity_group_permissions\").click\n self.button(:text=>\"Categories\").click\n self.wait_until { self.text.include? \"Assign a category\" }\n self.class.class_eval { include AddRemoveCategories }\n end"
] |
[
"0.6265461",
"0.6119854",
"0.5893255",
"0.57891095",
"0.57691133",
"0.5765748",
"0.57305646",
"0.56753606",
"0.56537646",
"0.56356764",
"0.56098264",
"0.5582014",
"0.5564689",
"0.5553399",
"0.5544319",
"0.55430347",
"0.5523176",
"0.55040956",
"0.5494935",
"0.548374",
"0.5479125",
"0.54713756",
"0.5451134",
"0.54490376",
"0.5447817",
"0.5435393",
"0.54243976",
"0.5402982",
"0.5402982",
"0.5402982",
"0.53932613",
"0.539239",
"0.5389345",
"0.53683275",
"0.53633106",
"0.53342897",
"0.5328818",
"0.5326605",
"0.5324341",
"0.53207684",
"0.5305567",
"0.52834946",
"0.52677715",
"0.52406085",
"0.5238539",
"0.5225235",
"0.5215254",
"0.5202961",
"0.5198694",
"0.5198694",
"0.5198694",
"0.5196792",
"0.51867515",
"0.51841766",
"0.5178264",
"0.51700395",
"0.5165854",
"0.51619345",
"0.5146409",
"0.51431483",
"0.51419026",
"0.51393455",
"0.5130342",
"0.5120274",
"0.5091064",
"0.5090078",
"0.5089279",
"0.5088027",
"0.5084283",
"0.5083309",
"0.5075751",
"0.50743574",
"0.50701386",
"0.5068107",
"0.506509",
"0.5049233",
"0.5039653",
"0.50352967",
"0.5034323",
"0.50324816",
"0.5024457",
"0.502373",
"0.50224173",
"0.5021423",
"0.501953",
"0.5017814",
"0.501731",
"0.50127393",
"0.50105965",
"0.5009629",
"0.5007968",
"0.50066745",
"0.50059676",
"0.5003674",
"0.49994573",
"0.49990064",
"0.4998879",
"0.49949288",
"0.4993784",
"0.49930567",
"0.4991445"
] |
0.0
|
-1
|
Turns this transaction into a Hash that can be sent via soap to the provider
|
def to_hash
AchClient::ICheckGateway::CompanyInfo.build.to_hash.merge({
APIMethod: 'ProcessCheck',
Amount: amount,
RoutingNumber: routing_number.to_s,
AccountNumber: account_number.to_s,
AccountType: AchClient::ICheckGateway::AccountTypeTransformer
.serialize_to_provider_value(account_type),
EntryClassCode: sec_code,
TransactionType:
AchClient::ICheckGateway::TransactionTypeTransformer
.serialize_to_provider_value(transaction_type),
CompanyName: merchant_name,
Description: memo,
TransactionDate: effective_entry_date
})
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hash\n [additional_details, blockchain, fee_priority, network, recipients, total_transaction_amount, transaction_id, transaction_request_status, transaction_type, unit, wallet_id].hash\n end",
"def hash_transactions\n tx_ids = transactions.map do |tx|\n tx.id\n end\n Digest::SHA256.hexdigest(tx_ids.join(''))\n end",
"def hash(tx)\n Digest::SHA256.hexdigest(Digest::SHA256.hexdigest(tx))\nend",
"def hash\n [currency_code, memo, partial_auth, transaction_type, description, transaction_category_id, use_audit_log, merchant_category_code, card_id, transaction_category, cleanse_data, auth_type, mid, transaction_status_scope, location, merchant, amount, date, merchant_id].hash\n end",
"def hash\n [amount.hash, currency.hash].hash\n end",
"def hash\n [amount.hash, currency.hash].hash\n end",
"def hash\n [merchant_ref, transaction_type, original_transaction_type, original_transaction_id, amount, currency_code, customer, billing_address, device, loyalty, payment, merchant, order, user_defined].hash\n end",
"def to_hash\n @hash ||= hash_from_payload(to_payload)\n {\n 'hash' => @hash, 'ver' => @ver,\n 'vin_sz' => @in.size, 'vout_sz' => @out.size,\n 'lock_time' => @lock_time, 'size' => (@payload ||= to_payload).bytesize,\n 'in' => @in.map.with_index{|i,idx|\n t = { 'prev_out' => { 'hash' => hth(i.prev_out), 'n' => i.prev_out_index } }\n unless (idx == 0) && i.coinbase?\n t['scriptSig'] = Bitcoin::Script.new(i.script_sig).to_string\n t['sequence'] = i.sequence.unpack(\"I\")[0] unless i.sequence == \"\\xff\\xff\\xff\\xff\"\n else # coinbase tx\n t['coinbase'] = i.script_sig.unpack(\"H*\")[0]\n end\n t\n },\n 'out' => @out.map{|o|{\n 'value' => \"%.8f\" % (o.value / 100000000.0),\n 'scriptPubKey' => Bitcoin::Script.new(o.pk_script).to_string\n }}\n }\n end",
"def to_hash\n {\n amount: self.amount,\n address: self.to_node.address\n }\n end",
"def hash\n [store_id, client_locale, transaction_amount, transaction_type, order_id, billing, shipping, transaction_notification_url, expiration, authenticate_transaction, dynamic_merchant_name, invoice_number, purchase_order_number, hosted_payment_page_text, ip, revolving_options, installment_options, basket].hash\n end",
"def to_sha256\n Tapyrus.sha256(to_payload).bth\n end",
"def serialize(hash, salt)\n hash + salt\n end",
"def hash\r\n return to_s.hash\r\n end",
"def to_hash\n transactions_hash = []\n @transactions&.each { |t| transactions_hash << t.to_hash }\n { name: @name,\n currency: @currency,\n balance: @balance,\n nature: @nature,\n transactions: transactions_hash }\n end",
"def hash\n [cents.hash, currency.hash].hash\n end",
"def hash\n [cents.hash, currency.hash].hash\n end",
"def hash\n return to_s.hash\n end",
"def calculate_hash\n\t\toptions = {:firstname => firstname, :email => email, :phone => phone, :txnid => txnid, :surl => surl, :furl => furl, :productinfo => productinfo, :amount => amount}\n\t\tservice = PayuIndia::Helper.new(payment_gateway_key, payment_gateway_salt, options)\n\t\tself.hast = service.generate_checksum\n\tend",
"def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end",
"def hash\n to_s.hash\n end",
"def hash\n id.hash + 32 * bs_request.hash\n end",
"def hash\n [returned_balances, tags, transaction_type, token, ref_transaction, node, network, sub_network, mid, tid, stan, ca_name, ca_street, ca_zip, ca_city, ca_region, ca_country, function_code, reason_code, response_code, approval_number, display_message, date, transmission_date, local_transaction_date, capture_date, settlement_date, itc, irc, currency_code, amount, additional_amount, acquirer_fee, issuer_fee, rc, extrc, duration, cardholder, acting_cardholder, card, account, account2, mcc, network_reference_id, acquirer_reference_id, retrieval_reference_number, forwarding_inst_id, network_mid, request_amount, transaction_state, remote_host, response_amount, expiration_time, incoming_network_request_itc, digital_wallet_token, tranlog_attributes, payload, layer, transaction_name, originator, acquirer, gpaorder, gateway_log].hash\n end",
"def hash\n to_pem.hash\n end",
"def hash\n to_pem.hash\n end",
"def hash\n [comments, invoice_number, purchase_order_number, disbursement_trans_type, wallet_provider, receipts, additional_response_data].hash\n end",
"def original_hash\n @original_hash ||= Savon::SOAP::XML.to_hash to_xml\n end",
"def signature\n Digest::SHA256.hexdigest(@hash.to_json)\n end",
"def hash\n bytes.hash\n end",
"def merchanthash\n if version.to_i == 1 \n return HashGenerator::generate(merchant_hash_key, merchant_id, order_id);\n else\n return Digest::SHA512.hexdigest(\"#{merchant_hash_key},#{merchant_id},01,#{order_id},#{gross_amount}\")\n end\n end",
"def hash\n [mti, stan, transmission_time, acquiring_institution_id, network_reference_id, forwarding_institution_id, transaction_token].hash\n end",
"def to_hash() end",
"def sha\n result_hash['sha']\n end",
"def to_hash\n XMLUtils.to_hash xml\n end",
"def hexhash\n hash.to_s(16)\n end",
"def set_outgoing_hash\n \n \t\tdata = \tself.class.get_payumoney_key + \"|\" + self.id.to_s + \"|\" + self.amount.to_s + \"|\" + get_product_info + \"|\" + get_first_name + \"|\" + get_email + \"|||||\" + get_udf5 + \"||||||\" + self.class.get_payumoney_salt\n\n \t\tself.outgoing_hash = Digest::SHA512.hexdigest(data)\n \tend",
"def to_hash\n strip_content(xml.to_hash)\n end",
"def hash\n address.hash\n end",
"def transaction_for_hash(hash)\n raise \"Not Implemented\"\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def straighten_transaction(transaction, address: nil)\n # Get the block number this transaction was included into\n block_height = transaction['height']\n tid = transaction['txid']\n\n # Converting from Base64 to binary\n transaction = transaction['binary'].unpack('m0')[0]\n\n # Decoding\n transaction = BTC::Transaction.new(data: transaction)\n network = address.nil? ? nil : BTC::Address.parse(address).network\n\n outs = []\n total_amount = 0\n\n transaction.outputs.each do |out|\n amount = out.value\n receiving_address = out.script.standard_address(network: network)\n total_amount += amount if address.nil? || address == receiving_address.to_s\n outs << {amount: amount, receiving_address: receiving_address}\n end\n\n {\n tid: tid,\n total_amount: total_amount.to_i,\n confirmations: calculate_confirmations(block_height),\n block_height: block_height,\n outs: outs,\n meta: {\n fetched_via: self,\n },\n }\n end",
"def to_json\n {\n transactions: @transactions.map { |k, v| [k, v.to_h] }.to_h,\n transactions_hash: @transactions_hash,\n timestamp: @timestamp,\n allowed_miners: @allowed_miners,\n height: @height,\n previous_hash: @previous_hash,\n signed_by: @signed_by,\n signature: @signature\n }.to_json\n end",
"def hash\n to_s.hash\n end",
"def hash\n to_s.hash\n end",
"def combined_hash\n hashes = @contracts.map { |c| c.bth }.sort\n concatenated_hash = [payment_base.to_base58].concat(hashes).join\n Tapyrus.sha256(concatenated_hash)\n end",
"def hash\n [wallet_id, debtor_bic, debtor_iban, debitor_name, debitor_country, debitor_address_line, creditor_bic, creditor_iban, creditor_name, creditor_address_line, creditor_country, transaction_id, virtual_iban_id, settlement_date, settlement_amount, return_reason_code, virtual_iban_reference, remittance_information, transaction_end_to_end_id].hash\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def straighten_transaction(transaction, address: nil)\n\n # Get the block number this transaction was included into\n block_height = transaction['height']\n tid = transaction['txid']\n\n # Converting from Base64 to hex\n transaction = transaction['binary'].unpack(\"m0\").first.unpack(\"H*\").first\n\n # Decoding with bitcoin-cli\n begin\n transaction = JSON.parse(`bitcoin-cli decoderawtransaction #{transaction}`)\n rescue Errno::ENOENT => e\n if e.message == 'No such file or directory - bitcoin-cli'\n raise NoBitcoindInstalled\n else\n raise e\n end\n end\n\n outs = []\n total_amount = 0\n transaction['vout'].each do |out|\n out['value'] = out['value']*10**8\n total_amount += out['value'] if address.nil? || address == out['address']\n outs << { amount: out['value'], receiving_address: out['address'] }\n end\n\n {\n tid: tid,\n total_amount: total_amount,\n confirmations: calculate_confirmations(block_height),\n outs: outs\n }\n end",
"def to_hash\n @hash\n end",
"def hash\n [description, routing_number, account_number, account_type, signatory, metadata, id, signature_url, bank_name, verified, date_created, date_modified, deleted, object].hash\n end",
"def to_base58\n h = to_payload.bth\n hex = h + Bitcoin.calc_checksum(h)\n Base58.encode(hex)\n end",
"def to_base58\n h = to_payload.bth\n hex = h + Bitcoin.calc_checksum(h)\n Base58.encode(hex)\n end",
"def hash\n data.hash\n end",
"def hash\n [input_currency, payin_methods, metadata, sender, recipients, traits, state, input_amount, payin_reference, paid_amount, due_amount, created_at, expires_at, external_id, id, errors].hash\n end",
"def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend",
"def hash\n [article_number, name, quantity, unit_price, discount_percent, vat_percent, unit, temporary_reference, row_number, merchant_data].hash\n end",
"def balance_hash\n @money\n end",
"def to_h\n {\n data: data,\n nonce: nonce,\n time: time,\n hash: hash,\n index: index,\n prev_hash: prev_hash\n }\n end",
"def hash\n [to_d.hash, currency.hash].hash\n end",
"def hash\n @orig.hash\n end",
"def hash\n @orig.hash\n end",
"def hash\n @orig.hash\n end",
"def as_hash\n @hash\n end",
"def serialize\n Base64.encode64(Marshal.dump(self.to_hash)).chop\n end",
"def to_hash\n {\n 'address' => address,\n 'oa_address' => oa_address,\n 'script' => @script.to_payload.bth,\n 'script_type' => script_type,\n 'amount' => satoshi_to_coin(@value),\n 'asset_id' => @asset_id,\n 'asset_quantity' => @asset_quantity.to_s,\n 'asset_amount' => asset_amount.to_s,\n 'account' => @account,\n 'asset_definition_url' => @asset_definition_url,\n 'proof_of_authenticity' => proof_of_authenticity,\n 'output_type' => OpenAssets::Protocol::OutputType.output_type_label(@output_type)\n }\n end",
"def calculate_payload_hash\n\t\treturn Digest::SHA2.hexdigest( self.payload )\n\tend",
"def to_h\n @ledger.dup\n end",
"def address_to_hash address\n call_blockchain_api(\"addresstohash/#{address}\")\n end",
"def to_encrypted_string\n self.class.send(:encryptor).encrypt_and_sign to_hash\n end",
"def to_sha(hash)\n # converts a hash to a SHA256\n return Digest::SHA256.hexdigest(JSON.dump(hash))\nend",
"def to_h\n @hash\n end",
"def to_h\n @hash\n end",
"def hexdigest\n DigestUtils.pack_hexdigest(digest)\n end",
"def to_jaxb_json_hash\n _h = super\n _h['clientMessageId'] = clientMessageId.to_jaxb_json_hash unless clientMessageId.nil?\n _h['transferId'] = transferId.to_jaxb_json_hash unless transferId.nil?\n return _h\n end",
"def hash(ts)\n sig = [\n Rackspace::Email::Api.configuration.user_key,\n Rackspace::Email::Api.configuration.user_agent,\n ts,\n Rackspace::Email::Api.configuration.api_key\n ].join('')\n\n Base64.encode64(Digest::SHA1.digest(sig))\n end",
"def hash_hmac(data)\n digest = OpenSSL::Digest.new('sha1')\n OpenSSL::HMAC.hexdigest(digest, merchant_key , data)\n end",
"def to_hash()\n @data\n end",
"def hash\n \"#{self.class.name}-#{self.id}-#{@__metadata__.cas}-#{@__attributes__.hash}\".hash\n end",
"def hash\n [payment_amount, payer, invoice_information, payment_format, payment_currency, payee, payment_id, payment_description, debit_credit_indicator, payment_method, payment_date].hash\n end",
"def to_h\n { bcrypt_salt: bcrypt_salt.to_s,\n pbkdf2_salt: pbkdf2_salt,\n test_encryption: test_encryption }\n end",
"def transaction_id\n @data[:transaction_id]\n end",
"def transaction_total_price\n hash[\"TransactionTotalPrice\"]\n end",
"def to_hash\n @_hash_\n end",
"def get_tx(tx_hash)\n raise \"Not implemented\"\n end",
"def to_hash160\n Tapyrus.hash160(to_hex)\n end",
"def hash\n @data[:asin].to_s.hash\n end",
"def to_jaxb_json_hash\n _h = super\n _h['request'] = request.to_jaxb_json_hash unless request.nil?\n _h['amount'] = amount.to_jaxb_json_hash unless amount.nil?\n _h['clientAuthorizationId'] = clientAuthorizationId.to_jaxb_json_hash unless clientAuthorizationId.nil?\n _h['merchantProductId'] = merchantProductId.to_jaxb_json_hash unless merchantProductId.nil?\n _h['sessionTransactionToken'] = sessionTransactionToken.to_jaxb_json_hash unless sessionTransactionToken.nil?\n return _h\n end",
"def hash\n @hash.hash\n end",
"def to_hash\n @base_quantity_hash\n end",
"def hash\n self.to_f.hash\n end",
"def to_hash\n to_a.hash\n end",
"def hash\n # TODO: Produce a hash (using default hash method) of the credit card's\n # serialized contents.\n # Credit cards with identical information should produce the same hash.\n self.to_s.hash\nend",
"def to_h\n signed_data.merge(unsigned_data).merge(signature: @signature)\n end",
"def hash\n @hash\n end",
"def to_h\n {\n V: v.hex,\n A: p_a.hex,\n S: p_s.hex,\n T1: p_t1.hex,\n T2: p_t2.hex,\n tx: \"0x#{tx.hex}\",\n txbf: \"0x#{tx_bf.hex}\",\n e: \"0x#{e.hex}\",\n lx: {\n n: ORDER_HEX,\n elems: lx.map { |x| \"0x#{x.hex}\" }\n },\n rx: {\n n: ORDER_HEX,\n elems: rx.map { |x| \"0x#{x.hex}\" }\n },\n G: GENERATOR_G.hex,\n order: ORDER_HEX\n }\n end",
"def hash\n [uri, parameters, username, password, verify_mode].hash\n end",
"def hash\n { hash: @hash, hashType: @hash_type }\n end",
"def transaction(tx_hash)\n call :get, \"/tx/#{tx_hash}\"\n end",
"def to_hash\n {\n type: self.class.name,\n secret: secret,\n salt: salt,\n iterations: iterations,\n hash_function: hash_function.class.name\n }\n end"
] |
[
"0.70527416",
"0.69201714",
"0.68898565",
"0.6725102",
"0.6654561",
"0.6654561",
"0.66157824",
"0.66122144",
"0.6568209",
"0.6562143",
"0.64774346",
"0.64721733",
"0.64656335",
"0.6452008",
"0.64132833",
"0.64132833",
"0.6396862",
"0.637934",
"0.63736504",
"0.6348656",
"0.63340485",
"0.6334048",
"0.63269746",
"0.63269746",
"0.63049114",
"0.62991023",
"0.62955856",
"0.62929726",
"0.6261081",
"0.62487507",
"0.6240821",
"0.62373286",
"0.6222065",
"0.62059975",
"0.619676",
"0.6175528",
"0.6172318",
"0.6157175",
"0.615352",
"0.615352",
"0.615352",
"0.61462855",
"0.6144398",
"0.6106452",
"0.6106452",
"0.60725075",
"0.60695153",
"0.6068061",
"0.6068061",
"0.6057181",
"0.60565233",
"0.6055296",
"0.59928876",
"0.59928876",
"0.5967909",
"0.5950624",
"0.595032",
"0.59432036",
"0.5926626",
"0.5924209",
"0.5920707",
"0.59093004",
"0.59093004",
"0.59093004",
"0.5908799",
"0.59056485",
"0.58865684",
"0.5876143",
"0.58743155",
"0.5863041",
"0.5861443",
"0.58476615",
"0.58443266",
"0.58443266",
"0.58420557",
"0.5836652",
"0.58347607",
"0.5819732",
"0.5807746",
"0.58037186",
"0.58031213",
"0.580081",
"0.57960796",
"0.5793173",
"0.57931674",
"0.5787702",
"0.5785584",
"0.5782015",
"0.57775044",
"0.57737005",
"0.57697624",
"0.5760827",
"0.5755468",
"0.5754927",
"0.5754594",
"0.5753561",
"0.57459337",
"0.5740791",
"0.57397854",
"0.5738968",
"0.57357025"
] |
0.0
|
-1
|
GET /challenges GET /challenges.xml
|
def index
@challenges = Challenge.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @challenges }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n @challenges = Challenge.all params[:filters], params[:page]\n end",
"def index\n\t\tif params[:tag]\n\t\t\t@challenges = Challenge.tagged_with(params[:tag])\n\t\telse\n\t\t\t@challenges = Challenge.all\n\t\tend\n\tend",
"def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n @team_challenges = TeamChallenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @team_challenges }\n end\n end",
"def index\n @user_challenges = UserChallenge.all\n end",
"def for_connection(id)\n id.require!(as: :id)\n api(:get, \"/connections/#{id}/challenges\")\n .fetch('challenges')\n .cast(Challenge)\n end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @challenge }\n end\n end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge }\n end\n end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def challenges\n @limit = get_limit\n @offset = get_offset(params)\n if !params[:keyword].nil?\n @results_count = Challenge.count(:conditions => [ \"name like :kw or description like :kw\", { :kw => \"%\" + params[:keyword].to_s + \"%\" }])\n @challenges = Challenge.find(:all,\n :conditions => [ \"name like :kw or description like :kw\", { :kw => \"%\" + params[:keyword].to_s + \"%\" }],\n :limit => @limit,\n :offset => @offset)\n end\n @results_pages = @results_count.fdiv(@limit)\n respond_to do |format|\n format.html { render \"manage/challenges/index\" }\n format.xml { render :xml => @challenges }\n end\n end",
"def show\n @challenge = Challenge.find(params[:id])\n add_breadcrumb @challenge.title, @challenge\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge }\n end\n end",
"def show\n @challenge_id = params['id']\n # get challenge detail\n @challenge = Challenges.show_challenge(@challenge_id)\n\n #get all feeds associated with this challenge.\n @feeds = ChallengeFeeds.challenge_feeds(dbdc_client, @challenge_id)\n end",
"def index\n @challenge = Challenge.find(params[:challenge_id])\n @resources = @challenge.resources\n if params[:index]\n render :all\n else\n render :index\n end\n end",
"def show\n @entry = Entry.find(params[:id])\n @challenge = @challenge || @entry.challenge\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def challenges; end",
"def show\n @team_challenge = TeamChallenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team_challenge }\n end\n end",
"def index\n @compares = @chapter.compares\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compares }\n end\n end",
"def index\n @weekly_challenges = WeeklyChallenge.all\n end",
"def index\n @contests = Contest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contests }\n end\n end",
"def index\n @labs = @course.labs.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @labs }\n end\n end",
"def new\n @challenge = Challenge.new\n @charities = Charity.find(:all, :order => :name)\n @sponsors = Sponsor.find(:all, :order => :name)\n @activities = Activity.find(:all, :order => :name)\n @tags = Tag.find(:all, :order => :name)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def show\n challenge_id = params[:challenge_id]\n @challenge = Challenge.find(challenge_id)\n end",
"def mychallenges\n\t\tputs \"------------------\"\n\t\t# puts session[:users]\n\t\tputs current_user\n\t\t#puts current_user.id\n\t\tputs \"@@@@@@@@@@@@@@@@@@\"\n\n\t\t@challenges = Challenge.all(:limit => 10, :conditions => {:user_id => current_user.id})\n\tend",
"def show\n @competition = Competition.includes(:challenges).find(params[:id])\n end",
"def show\n @concert = Concert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @concert }\n end\n end",
"def index\n @users = User.where(:listed => 1)\n if current_closed_challenge.present?\n @entries = Entry.where(:challenge_id => current_closed_challenge.id).limit(3)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Entry.all }\n end\n else\n respond_to do |format|\n format.html { render \"challenges/about\" }\n format.json { render json: Entry.all }\n end\n end\n end",
"def index\n @achievements = Achievement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @achievements }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def index\n @matches = @contest.matches\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @matches }\n end\n end",
"def team_challenge_list\n @team_challenges = TeamChallenge.find_by_user(current_user.id)\n end",
"def show\n \n if request.xhr? \n id = params[:ch_id]\n @challenge = Challenge.find(id)\n request.format = :json\n else \n @challenge = Challenge.find(params[:id])\n end\n \n respond_to do |format|\n format.html { render :action => \"index\" }# show.html.erb\n format.xml { render :xml => @challenge }\n format.json { render :layout => false,\n :json =>@challenge.to_json}\n end\n end",
"def index\n @challenge_instances = ChallengeInstance.all\n end",
"def index\n @challenge_instances = ChallengeInstance.all\n end",
"def show\n @player_challenge = PlayerChallenge.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @player_challenge }\n end\n end",
"def show\n if !params[:id].to_s.match(/^\\d+$/) then\n @challenge = Challenge.find_by_seo_name_and_enabled(params[:id], true)\n else\n @challenge = Challenge.find_by_id_and_enabled(params[:id], true)\n end\n if !@challenge.nil? then\n if !session[:user_id].nil? && session[:user_id] != \"\" then\n @user = User.find(session[:user_id])\n @user_activities = UserActivity.find_all_by_user_id_and_challenge(@user.id, @challenge)\n end\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @challenge }\n end\n else\n flash[:error_message] = \"This challenge is not active.\"\n respond_to do |format|\n format.html { render \"errors/index\" }\n format.xml { render :xml => flash[:error_message] }\n end\n end\n end",
"def challenge\n skip_authorization\n render(json: { message: \"Ruby on Rails Challenge 20200810\" }, status: 200)\n end",
"def get\n perform_request(api_url(\"champion\"))[\"champions\"].map {|c| Champion.new(c)}\n end",
"def find\n challenge = Challenge.find(@oauth_token, params[:challenge_id].strip, \n params[:admin] ||= false)\n error! :not_found unless challenge\n error! :not_found if challenge['status'].downcase == 'hidden'\n expose challenge\n end",
"def index\n @certs = Cert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @certs }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def index\n @challenges = Challenge.all.order('difficulty ASC')\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @challenge_types = ChallengeType.all\n end",
"def show\n @lab = @course.labs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @lab }\n end\n end",
"def getdifficulty\n request :getdifficulty\n end",
"def participants\n expose Challenge.participants(@oauth_token, params[:challenge_id].strip)\n end",
"def scorecards\n expose Challenge.scorecards(@oauth_token, params[:challenge_id].strip)\n end",
"def getdifficulty\n @api.request 'getdifficulty'\n end",
"def show\n @concerts = Concert.find(params[:id])\n end",
"def show\n # Find the challenge in database to see if it exsits.\n @challenge = Challenge.find(params[:id])\n\n if @challenge\n # Restructure challenge and return as JSON.\n @challenge = restructure_challenge(@challenge)\n render json: {challenge: @challenge}\n else\n # Return JSON with error message.\n error = \"Challenge with that id does not exsits\"\n render json: {error: error}\n end\n end",
"def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n end",
"def index\n authenticate_admin!\n \n @candies = Candy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @candies }\n end\n end",
"def index\n @contests = Contest.find(:all, :order => 'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contests }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def credit\n handle_response(get(\"/credit.json\"))\n end",
"def show\n @youth_problem = YouthProblem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @youth_problem }\n end\n end",
"def get_channnel_xml( url )\n path = url.sub(/http:\\/\\/gdata\\.youtube\\.com/,'')\n xml = \"\"\n\n Net::HTTP.version_1_2\n Net::HTTP.start(\"#{@url}\", \"#{@port}\") do |http|\n response = http.get(\"/#{path}\")\n xml = response.body\n end\n\n return xml\n end",
"def show\n @user = User.find_by_username(params[:id])\n\n @entries = Entry.where(:user_id => @user.id).sort_by { |entry| -entry.score }\n\n @challenges = Challenge.where(:user_id => @user.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def index\n @contests = Contest.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end",
"def new\n @challenge = Challenge.new\n add_breadcrumb 'new', @challenge\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def challenge_detail\n @challenge = Challenge.find(params[:foo])\n end",
"def index\n @contests = Contest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end",
"def index\n @group = @authorized_group\n @candidates = @group.candidates\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @candidates }\n end\n end",
"def get_campaign_challenges_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CampaignsApi.get_campaign_challenges ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling CampaignsApi.get_campaign_challenges\"\n end\n # resource path\n local_var_path = \"/campaigns/{id}/challenges\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'filter_start_date'] = opts[:'filter_start_date'] if !opts[:'filter_start_date'].nil?\n query_params[:'filter_end_date'] = opts[:'filter_end_date'] if !opts[:'filter_end_date'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourceChallengeResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CampaignsApi#get_campaign_challenges\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @contest }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @contest }\n end\n end",
"def show\n @achievement = Achievement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @achievement }\n end\n end",
"def show\n @course_degree = CourseDegree.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @course_degree }\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @courses }\n end\n end",
"def index\n @compares = current_user.compares\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compares }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end",
"def index\n @issues = @account.issues.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @issues }\n end\n end",
"def show\n puts \"##################user id is #{@user.id}\"\n @owned_challenges = Challenge.where(owner_id: params[:id])\n @activities = Activity.where(user_id: @user.id)\n puts \"##################activities is #{@activities}\"\n end",
"def index\n @challenges = Challenge.all\n @users = User.all\n if params[:search]\n @challenges = Challenge.search(params[:search]).order(\"score DESC\")\n else\n @challenges = Challenge.all.order(\"created_at DESC\")\n end\n end",
"def show\n @court = Court.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @court }\n end\n end",
"def get_challenge\n result = @client.call(\"LJ.XMLRPC.getchallenge\")\n challenge = result[\"challenge\"]\n response = MD5.md5(challenge + @password).to_s\n\n @paramhash[\"auth_challenge\"] = challenge\n @paramhash[\"auth_response\"] = response\n end",
"def create\n @challenge = Challenge.new(params[:challenge])\n\n respond_to do |format|\n if @challenge.save\n flash[:notice] = 'Challenge was successfully created.'\n format.html { redirect_to(@challenge) }\n format.xml { render :xml => @challenge, :status => :created, :location => @challenge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end",
"def index\n @lookup_cohorts = LookupCohort.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_cohorts }\n end\n end",
"def challenge\n @challenge = decode_challenge\n respond\n end",
"def index\n @guides = Guide.all\n #@guide = Guide.find(params[:guide]) rescue nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @guides }\n end\n end",
"def index\n @cases = Case.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cases }\n end\n end",
"def show\n @condolence = Condolence.find(params[:id])\n @orbituarysite = current_user.orbituarysites.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @condolence }\n end\n end",
"def index\r\n @cuentum = Cuentum.find(params[:cuentum_id])\r\n @credits = @cuentum.credits\r\n \r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @credits}\r\n end\r\n end",
"def index\n @achievements = Achievement.all\n respond_with @achievements\n end"
] |
[
"0.6803577",
"0.6728107",
"0.67091334",
"0.6674856",
"0.6674856",
"0.6674856",
"0.6674856",
"0.6667852",
"0.6463627",
"0.6413808",
"0.63771206",
"0.6290307",
"0.6281759",
"0.6229143",
"0.6097002",
"0.6093464",
"0.60923636",
"0.6045768",
"0.5998104",
"0.58445114",
"0.5817884",
"0.5804877",
"0.5767132",
"0.5756662",
"0.57419926",
"0.5741092",
"0.57069665",
"0.56816983",
"0.56799746",
"0.56478816",
"0.56422085",
"0.5641032",
"0.5574283",
"0.55516434",
"0.55406815",
"0.55393517",
"0.5539306",
"0.5531047",
"0.54896444",
"0.54843724",
"0.54724383",
"0.54724383",
"0.54463285",
"0.54234016",
"0.54117423",
"0.5403977",
"0.5388253",
"0.5366624",
"0.5360347",
"0.5360347",
"0.53600013",
"0.5324713",
"0.5324713",
"0.5324713",
"0.5324713",
"0.5313046",
"0.52955186",
"0.52944046",
"0.52921426",
"0.528738",
"0.52873164",
"0.52858156",
"0.527731",
"0.52672666",
"0.5257546",
"0.5252243",
"0.5249418",
"0.5249418",
"0.52491045",
"0.5240412",
"0.5234764",
"0.5225289",
"0.52224517",
"0.5219832",
"0.5216719",
"0.5208905",
"0.5202873",
"0.51865906",
"0.5185928",
"0.5185928",
"0.51778436",
"0.51751655",
"0.5168512",
"0.51656103",
"0.51625556",
"0.5161803",
"0.51607853",
"0.5160153",
"0.5156224",
"0.51543915",
"0.51500463",
"0.5147261",
"0.51472116",
"0.5127022",
"0.51212007",
"0.5112274",
"0.5110657",
"0.5109106",
"0.5108887",
"0.5108224"
] |
0.7461396
|
0
|
GET /challenges/1 GET /challenges/1.xml
|
def show
if request.xhr?
id = params[:ch_id]
@challenge = Challenge.find(id)
request.format = :json
else
@challenge = Challenge.find(params[:id])
end
respond_to do |format|
format.html { render :action => "index" }# show.html.erb
format.xml { render :xml => @challenge }
format.json { render :layout => false,
:json =>@challenge.to_json}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @challenges }\n end\n end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def index\n @challenges = Challenge.all params[:filters], params[:page]\n end",
"def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n\t\tif params[:tag]\n\t\t\t@challenges = Challenge.tagged_with(params[:tag])\n\t\telse\n\t\t\t@challenges = Challenge.all\n\t\tend\n\tend",
"def index\n @team_challenges = TeamChallenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @team_challenges }\n end\n end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @challenge }\n end\n end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge }\n end\n end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge }\n end\n end",
"def index\n @user_challenges = UserChallenge.all\n end",
"def index\n @contests = Contest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contests }\n end\n end",
"def show\n @entry = Entry.find(params[:id])\n @challenge = @challenge || @entry.challenge\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def index\n @compares = @chapter.compares\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compares }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def index\n @challenge = Challenge.find(params[:challenge_id])\n @resources = @challenge.resources\n if params[:index]\n render :all\n else\n render :index\n end\n end",
"def for_connection(id)\n id.require!(as: :id)\n api(:get, \"/connections/#{id}/challenges\")\n .fetch('challenges')\n .cast(Challenge)\n end",
"def show\n @challenge = Challenge.find(params[:id])\n add_breadcrumb @challenge.title, @challenge\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge }\n end\n end",
"def show\n @challenge_id = params['id']\n # get challenge detail\n @challenge = Challenges.show_challenge(@challenge_id)\n\n #get all feeds associated with this challenge.\n @feeds = ChallengeFeeds.challenge_feeds(dbdc_client, @challenge_id)\n end",
"def new\n @challenge = Challenge.new\n @charities = Charity.find(:all, :order => :name)\n @sponsors = Sponsor.find(:all, :order => :name)\n @activities = Activity.find(:all, :order => :name)\n @tags = Tag.find(:all, :order => :name)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def show\n @concert = Concert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @concert }\n end\n end",
"def challenges\n @limit = get_limit\n @offset = get_offset(params)\n if !params[:keyword].nil?\n @results_count = Challenge.count(:conditions => [ \"name like :kw or description like :kw\", { :kw => \"%\" + params[:keyword].to_s + \"%\" }])\n @challenges = Challenge.find(:all,\n :conditions => [ \"name like :kw or description like :kw\", { :kw => \"%\" + params[:keyword].to_s + \"%\" }],\n :limit => @limit,\n :offset => @offset)\n end\n @results_pages = @results_count.fdiv(@limit)\n respond_to do |format|\n format.html { render \"manage/challenges/index\" }\n format.xml { render :xml => @challenges }\n end\n end",
"def index\n @matches = @contest.matches\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @matches }\n end\n end",
"def index\n @labs = @course.labs.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @labs }\n end\n end",
"def show\n @team_challenge = TeamChallenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team_challenge }\n end\n end",
"def show\n challenge_id = params[:challenge_id]\n @challenge = Challenge.find(challenge_id)\n end",
"def show\n @youth_problem = YouthProblem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @youth_problem }\n end\n end",
"def index\n @achievements = Achievement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @achievements }\n end\n end",
"def index\n @weekly_challenges = WeeklyChallenge.all\n end",
"def show\n if !params[:id].to_s.match(/^\\d+$/) then\n @challenge = Challenge.find_by_seo_name_and_enabled(params[:id], true)\n else\n @challenge = Challenge.find_by_id_and_enabled(params[:id], true)\n end\n if !@challenge.nil? then\n if !session[:user_id].nil? && session[:user_id] != \"\" then\n @user = User.find(session[:user_id])\n @user_activities = UserActivity.find_all_by_user_id_and_challenge(@user.id, @challenge)\n end\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @challenge }\n end\n else\n flash[:error_message] = \"This challenge is not active.\"\n respond_to do |format|\n format.html { render \"errors/index\" }\n format.xml { render :xml => flash[:error_message] }\n end\n end\n end",
"def show\n @lab = @course.labs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @lab }\n end\n end",
"def show\n @competition = Competition.includes(:challenges).find(params[:id])\n end",
"def index\n @contests = Contest.find(:all, :order => 'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contests }\n end\n end",
"def index\n @certs = Cert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @certs }\n end\n end",
"def challenges; end",
"def index\n @users = User.where(:listed => 1)\n if current_closed_challenge.present?\n @entries = Entry.where(:challenge_id => current_closed_challenge.id).limit(3)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Entry.all }\n end\n else\n respond_to do |format|\n format.html { render \"challenges/about\" }\n format.json { render json: Entry.all }\n end\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def show\n #REQUIRES: existence of contest with :id\n #EFFECTS: allows rendering of one particular contest and its properties\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def show\n @court = Court.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @court }\n end\n end",
"def index\n @guides = Guide.all\n #@guide = Guide.find(params[:guide]) rescue nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @guides }\n end\n end",
"def index\n @lookup_cohorts = LookupCohort.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_cohorts }\n end\n end",
"def create\n @challenge = Challenge.new(params[:challenge])\n\n respond_to do |format|\n if @challenge.save\n flash[:notice] = 'Challenge was successfully created.'\n format.html { redirect_to(@challenge) }\n format.xml { render :xml => @challenge, :status => :created, :location => @challenge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def challenge_detail\n @challenge = Challenge.find(params[:foo])\n end",
"def mychallenges\n\t\tputs \"------------------\"\n\t\t# puts session[:users]\n\t\tputs current_user\n\t\t#puts current_user.id\n\t\tputs \"@@@@@@@@@@@@@@@@@@\"\n\n\t\t@challenges = Challenge.all(:limit => 10, :conditions => {:user_id => current_user.id})\n\tend",
"def show\n @complain = Complain.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @complain }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def index\n @issues = @account.issues.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @issues }\n end\n end",
"def show\n @player_challenge = PlayerChallenge.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @player_challenge }\n end\n end",
"def index\n @responses = @survey.responses.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @responses }\n end\n end",
"def show\n @achievement = Achievement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @achievement }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @contest }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @contest }\n end\n end",
"def index\n @reasons = Reason.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reasons }\n end\n end",
"def getdifficulty\n request :getdifficulty\n end",
"def index\n @challenge_instances = ChallengeInstance.all\n end",
"def index\n @challenge_instances = ChallengeInstance.all\n end",
"def get_channnel_xml( url )\n path = url.sub(/http:\\/\\/gdata\\.youtube\\.com/,'')\n xml = \"\"\n\n Net::HTTP.version_1_2\n Net::HTTP.start(\"#{@url}\", \"#{@port}\") do |http|\n response = http.get(\"/#{path}\")\n xml = response.body\n end\n\n return xml\n end",
"def show\n @course_degree = CourseDegree.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @course_degree }\n end\n end",
"def show\n # Find the challenge in database to see if it exsits.\n @challenge = Challenge.find(params[:id])\n\n if @challenge\n # Restructure challenge and return as JSON.\n @challenge = restructure_challenge(@challenge)\n render json: {challenge: @challenge}\n else\n # Return JSON with error message.\n error = \"Challenge with that id does not exsits\"\n render json: {error: error}\n end\n end",
"def show\n @concerts = Concert.find(params[:id])\n end",
"def ask\n @view = VIEWS[:ask]\n @contributions = Contribution.where(url: '')\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @contributions }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end",
"def index\n @group = @authorized_group\n @candidates = @group.candidates\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @candidates }\n end\n end",
"def show\n @question = Question.find(params[:id])\n @course = @question.course\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @question }\n end\n end",
"def show\n @vocab = Vocab.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @vocab }\n end\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @courses }\n end\n end",
"def show\n @defect = Defect.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @defect }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end",
"def show\n @announcer = Announcer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @announcer }\n end\n end",
"def new\n @challenge = Challenge.new\n add_breadcrumb 'new', @challenge\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def find\n challenge = Challenge.find(@oauth_token, params[:challenge_id].strip, \n params[:admin] ||= false)\n error! :not_found unless challenge\n error! :not_found if challenge['status'].downcase == 'hidden'\n expose challenge\n end",
"def show\n @decision = Decision.find(params[:id])\n\t@project = Project.find(params[:project_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @decision }\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def challenge\n skip_authorization\n render(json: { message: \"Ruby on Rails Challenge 20200810\" }, status: 200)\n end",
"def show\n @research = Research.find(params[:id])\n @page_title = \"Hello Congress research request: \" + @research.name\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end",
"def index\n @contests = Contest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end",
"def index\n @contests = Contest.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end",
"def index\n @cases = Case.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cases }\n end\n end",
"def index\n @challenges = Challenge.all.order('difficulty ASC')\n end",
"def show\n @course = Course.find(params[:course_id])\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def index\r\n @cuentum = Cuentum.find(params[:cuentum_id])\r\n @credits = @cuentum.credits\r\n \r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @credits}\r\n end\r\n end",
"def index\n authenticate_admin!\n \n @candies = Candy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @candies }\n end\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def show\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quest }\n end\n end",
"def show\n @lookup_cohort = LookupCohort.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_cohort }\n end\n end"
] |
[
"0.7383117",
"0.6794552",
"0.6505099",
"0.6436051",
"0.6373914",
"0.6373914",
"0.6373914",
"0.6373914",
"0.63658637",
"0.6233001",
"0.6081488",
"0.60770935",
"0.60567075",
"0.6035317",
"0.5991589",
"0.5967523",
"0.5966801",
"0.59262055",
"0.5905739",
"0.5901013",
"0.5893256",
"0.5861625",
"0.5856184",
"0.5850835",
"0.5786346",
"0.57793",
"0.57578254",
"0.5744406",
"0.5731705",
"0.57220304",
"0.5688472",
"0.5632901",
"0.5621185",
"0.5597507",
"0.5579393",
"0.55696857",
"0.5563591",
"0.55236346",
"0.5499101",
"0.54824996",
"0.5461223",
"0.545507",
"0.5450145",
"0.54334146",
"0.54334146",
"0.54334146",
"0.5398388",
"0.5385956",
"0.5385956",
"0.5373933",
"0.53621554",
"0.536194",
"0.535502",
"0.5351115",
"0.53469896",
"0.532559",
"0.5322032",
"0.5322032",
"0.5321813",
"0.53190255",
"0.5315958",
"0.53102714",
"0.5310241",
"0.5310241",
"0.5307263",
"0.52991396",
"0.5297423",
"0.5297423",
"0.5290492",
"0.52862006",
"0.52821726",
"0.5281906",
"0.5280344",
"0.5276634",
"0.52680975",
"0.52652466",
"0.52570236",
"0.52562034",
"0.52549195",
"0.52536786",
"0.5253102",
"0.5248878",
"0.5236732",
"0.5232999",
"0.5230934",
"0.522309",
"0.52212113",
"0.5220166",
"0.521707",
"0.5213063",
"0.52098227",
"0.52082074",
"0.52081984",
"0.5207299",
"0.5206888",
"0.5206888",
"0.5206888",
"0.5206888",
"0.51997435",
"0.5199561"
] |
0.5465374
|
40
|
GET /challenges/new GET /challenges/new.xml
|
def new
@challenge = Challenge.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @challenge }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @challenge = Challenge.new\n @charities = Charity.find(:all, :order => :name)\n @sponsors = Sponsor.find(:all, :order => :name)\n @activities = Activity.find(:all, :order => :name)\n @tags = Tag.find(:all, :order => :name)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def new\n @challenge = Challenge.new\n add_breadcrumb 'new', @challenge\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def new\n @entry = current_user.entries.where(:challenge_id => @challenge.id).first || Entry.new\n\n if @challenge.is_closed?\n redirect_to :root\n return\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def new\n @conseq = Conseq.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @conseq }\n end\n end",
"def new\n @howto = Howto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @howto }\n end\n end",
"def new\n @threat = Threat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @threat }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hacker }\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @challenges }\n end\n end",
"def new\n @court = Court.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @court }\n end\n end",
"def new\n @quest = Quest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quest }\n end\n end",
"def new\n @youth_problem = YouthProblem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @youth_problem }\n end\n end",
"def new\n head :status => 405\n return\n \n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.xml { render :xml => @participant }\n end\n end",
"def new\n @goal = Mg::Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @goal }\n end\n end",
"def new\n @defect = Defect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @defect }\n end\n end",
"def new\n @team_challenge = TeamChallenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @team_challenge }\n end\n end",
"def new \n @how_to = HowTo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @how_to }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @contest }\n end\n end",
"def new\n @lookup_cohort = LookupCohort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_cohort }\n end\n end",
"def new\n @tournament = @resource_finder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tournament }\n end\n end",
"def new\n @vocab = Vocab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vocab }\n end\n end",
"def new\n @announcer = Announcer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @announcer }\n end\n end",
"def create\n @challenge = Challenge.new(params[:challenge])\n\n respond_to do |format|\n if @challenge.save\n flash[:notice] = 'Challenge was successfully created.'\n format.html { redirect_to(@challenge) }\n format.xml { render :xml => @challenge, :status => :created, :location => @challenge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest }\n end\n end",
"def new\n @title = \"Grade a Team Challenge\"\n @challenge_grade = ChallengeGrade.new\n @teams = Team.all\n @challenges = Challenge.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge_grade }\n end\n end",
"def new\n @guess = Guess.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @guess }\n end\n end",
"def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end",
"def new\n @goaltemplate = Goaltemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @goaltemplate }\n end\n end",
"def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def new\n @quest_template = QuestTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quest_template }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def new\n @counterparty = Counterparty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @counterparty }\n end\n end",
"def new\n @achievement = Achievement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @achievement }\n end\n end",
"def new\n @course = Course.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def new\n @ref = Ref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ref }\n end\n end",
"def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contribution }\n end\n end",
"def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contribution }\n end\n end",
"def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end",
"def new\n #EFFECTS: Allows rendering of a form for inputting information to create a new contest.\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def new\n @story = Story.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n @story = Story.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n @story = Story.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n @experience = Experience.new(:goal_id => params[:goal_id])\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @experience }\n end\n end",
"def new\n @scratch = Scratch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scratch }\n end\n end",
"def new\n add_breadcrumb \"nueva\", :new_contest_path\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest }\n end\n end",
"def new\n @cheque = Cheque.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cheque }\n end\n end",
"def new\n @issue = Issue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @issue }\n end\n end",
"def new\n @account = current_user.accounts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n format.json { render :json => @account }\n end\n end",
"def new\n @concour = Concour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concour }\n end\n end",
"def new\n @complain = Complain.new\n @code = \"GS-02-002-#{DateTime.now.strftime('%y%m%d%H%M%S')}\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @complain }\n end\n end",
"def new\n @college = College.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @college }\n end\n end",
"def new\n @hack_tag_follow = HackTagFollow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hack_tag_follow }\n end\n end",
"def new\n @convenio = Convenio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @convenio }\n end\n end",
"def new\n @resp = Response.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resp }\n end\n end",
"def new\n @lesson = Lesson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lesson }\n end\n end",
"def new\r\n @related_course = RelatedCourse.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @related_course }\r\n end\r\n end",
"def new\n @resource = Resource.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @encounter_reason = EncounterReason.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @encounter_reason }\n end\n end",
"def new\n @account = User::Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def new\n @exercice = Exercice.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercice }\n end\n end",
"def new\n @issued = Issued.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @issued }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @tweak = Tweak.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tweak }\n end\n end",
"def new\n @encounter_type = EncounterType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @encounter_type }\n end\n end",
"def new\n @people = People.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @people }\n end\n end",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @court }\n end\n end",
"def new\n @social_problem = SocialProblem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @social_problem }\n end\n end",
"def new\n @story = Story.new\n @categories = Category.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n @cancer = Cancer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cancer }\n end\n end",
"def new\n @citation = Citation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @citation }\n end\n end",
"def new\n @cv = Cv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cv }\n end\n end",
"def new\n @repo = Repo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repo }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ciclo }\n end\n end",
"def new\n @pat_project = Pat::Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pat_project }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def new\n @cohort = Cohort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cohort }\n end\n end",
"def new\n @guide = Guide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @guide }\n end\n end",
"def new\n @commitment = Commitment.new\n @title = \"New Commitment\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @commitment }\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n @answer = @question.answers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @answer }\n end\n end",
"def new\n @coach_template = CoachTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @coach_template }\n end\n end",
"def new\n @prompt = Prompt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prompt }\n end\n end",
"def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end",
"def new\n @team = Team.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end"
] |
[
"0.69985414",
"0.69382435",
"0.68544227",
"0.68544227",
"0.68544227",
"0.6798342",
"0.6798342",
"0.6664263",
"0.6553692",
"0.65018755",
"0.65003836",
"0.6500273",
"0.6492642",
"0.64552945",
"0.6454501",
"0.6451231",
"0.644716",
"0.64124626",
"0.6405961",
"0.6402187",
"0.6394896",
"0.6376109",
"0.6369301",
"0.63689506",
"0.636719",
"0.6365689",
"0.6364814",
"0.6353822",
"0.6353822",
"0.6351859",
"0.6298328",
"0.6295293",
"0.6295012",
"0.62859774",
"0.62859774",
"0.62859774",
"0.6285442",
"0.62764186",
"0.62706834",
"0.62706834",
"0.62706834",
"0.62706834",
"0.62706834",
"0.6269593",
"0.6257557",
"0.62487346",
"0.6236948",
"0.6225541",
"0.6225541",
"0.6225201",
"0.6222548",
"0.62085074",
"0.62085074",
"0.62085074",
"0.62049234",
"0.6204729",
"0.62040627",
"0.6203357",
"0.62030715",
"0.62002397",
"0.61995053",
"0.61983025",
"0.619827",
"0.6197518",
"0.6190946",
"0.61858916",
"0.61782604",
"0.617479",
"0.6172447",
"0.61649287",
"0.6162589",
"0.6155745",
"0.6154063",
"0.61505234",
"0.6150422",
"0.6150422",
"0.6142521",
"0.6140356",
"0.61388606",
"0.6138284",
"0.6136755",
"0.613618",
"0.6135714",
"0.61352885",
"0.6131404",
"0.6131254",
"0.6130076",
"0.612821",
"0.6127071",
"0.61269706",
"0.61269706",
"0.61265343",
"0.6125199",
"0.61237395",
"0.6121572",
"0.61215186",
"0.612144",
"0.6120484",
"0.61190444",
"0.6116429"
] |
0.7550485
|
0
|
POST /challenges POST /challenges.xml
|
def create
@challenge = Challenge.new(params[:challenge])
respond_to do |format|
if @challenge.save
flash[:notice] = 'Challenge was successfully created.'
format.html { redirect_to(@challenge) }
format.xml { render :xml => @challenge, :status => :created, :location => @challenge }
else
format.html { render :action => "new" }
format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @challenges }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def create\n @challenge = Challenge.new(params[:challenge])\n\n respond_to do |format|\n if @challenge.save\n format.html { redirect_to @challenge, notice: 'Challenge was successfully created.' }\n format.json { render json: @challenge, status: :created, location: @challenge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @challenge = Challenge.new(challenge_params)\n\n respond_to do |format|\n if @challenge.save\n format.html { redirect_to @challenge, notice: 'Challenge was successfully created.' }\n format.json { render :show, status: :created, location: @challenge }\n else\n format.html { render :new }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @challenge = Challenge.new(challenge_params)\n\n respond_to do |format|\n if @challenge.save\n format.html { redirect_to @challenge, notice: \"Challenge was successfully created.\" }\n format.json { render :show, status: :created, location: @challenge }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @challenge = Challenge.new(challenge_params)\n puts challenge_params\n respond_to do |format|\n if @challenge.save\n format.html { redirect_to @challenge, notice: 'Challenge was successfully created.' }\n format.json { render action: 'show', status: :created, location: @challenge }\n else\n format.html { render action: 'new' }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @challenge = Challenge.new(params[:challenge])\n \n respond_to do |format|\n if @challenge.save\n format.html { redirect_to @challenge.lead, notice: 'Challenge was successfully created.' }\n format.json { render json: @challenge, status: :created, location: @challenge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @challenge = Challenge.new(challenge_params)\n @challenge.user = current_user\n\n respond_to do |format|\n if @challenge.save\n format.html { redirect_to @challenge, notice: 'Challenge was successfully created.' }\n format.json { render :show, status: :created, location: @challenge }\n else\n format.html { render :new }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_challenge\n verify_session() or redirect_to action:'dashboard' #ApplicationHelper::UserInterface\n \n @user = User.find(challenge_params[:author_id])\n logger.debug \"challenge_params #{challenge_params.inspect}\"\n @user.challenges.create!(challenge_params)\n redirect_to action:'dashboard',controller:'page'\n \n end",
"def create\n @challenge = Challenge.new(challenge_params)\n\n respond_to do |format|\n if @challenge.save\n format.html { redirect_to [:admin, @challenge], notice: 'Challenge was successfully created.' }\n format.json { render json: @challenge, status: :created, location: @challenge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contest = Contest.new(params[:contest])\n @contest.user_id = current_user.id\n parse_and_create_teams(params[:teams]) if params[:teams]\n \n respond_to do |format|\n if @contest.save\n create_open_post\n flash[:notice] = 'Contest was successfully created.'\n format.html { redirect_to(contests_path) }\n format.xml { render :xml => @contest, :status => :created, :location => @contest }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def challenge_params\n params.require(:challenge).permit(:id, :name, :challenge_id, :solution)\n end",
"def create\n @response_challenge = ResponseChallenge.new(params[:response_challenge])\n @response_challenge.challenge_id = params[:challenge_id]\n @response_challenge.user_id = current_user.id\n\n respond_to do |format|\n if @response_challenge.save\n format.html { redirect_to @response_challenge.challenge, notice: 'Response challenge was successfully created.' }\n format.json { render json: @response_challenge, status: :created, location: @response_challenge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @response_challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n expose Challenge.create(@oauth_token, params[:data])\n end",
"def new\n @challenge = Challenge.new\n @charities = Charity.find(:all, :order => :name)\n @sponsors = Sponsor.find(:all, :order => :name)\n @activities = Activity.find(:all, :order => :name)\n @tags = Tag.find(:all, :order => :name)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def challenge_params\n params.require(:challenge).permit(:title, :description, :emp_id, :tag)\n end",
"def challenge_params\n params.require(:challenge).permit(:title, :text)\n end",
"def challenge_params\n params.require(:challenge).permit(:title, :description, :expires_at, :points)\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def create\n @user_challenge = UserChallenge.new(user_challenge_params)\n\n respond_to do |format|\n if @user_challenge.save\n format.html { redirect_to @user_challenge, notice: 'User challenge was successfully created.' }\n format.json { render :show, status: :created, location: @user_challenge }\n else\n format.html { render :new }\n format.json { render json: @user_challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @challenge = Challenge.find(params[:challenge_id])\n @resource = @challenge.resources.build(resource_params)\n respond_to do |format|\n if @resource.save\n format.html { redirect_to challenge_resources_path(@challenge.id), notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entry = Entry.new(params[:entry])\n @entry.user = current_user\n @entry.challenge = @challenge\n\n if @entry.challenge.is_closed?\n redirect_to :root\n return\n end\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to(@challenge, :notice => 'Entry was successfully created.') }\n format.xml { render :xml => @entry, :status => :created, :location => @entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def challenge_params\n params.require(:challenge).permit(:name, :score, :description)\n end",
"def challenge_params\n params.require(:challenge).permit(:name, :description, :challenge_type, :starts_at, :ends_at)\n end",
"def challenge_params\n params.require(:challenge).permit(:title, :status, :description, :numb_guest, :meal_category, :meal_area, :theme_choice)\n end",
"def create\n @challenge_type = ChallengeType.new(challenge_type_params)\n\n respond_to do |format|\n if @challenge_type.save\n format.html { redirect_to @challenge_type, notice: 'Challenge type was successfully created.' }\n format.json { render :show, status: :created, location: @challenge_type }\n else\n format.html { render :new }\n format.json { render json: @challenge_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def create\n @challenge_instance = ChallengeInstance.new(challenge_instance_params)\n\n respond_to do |format|\n if @challenge_instance.save\n format.html { redirect_to @challenge_instance, notice: 'Challenge instance was successfully created.' }\n format.json { render :show, status: :created, location: @challenge_instance }\n else\n format.html { render :new }\n format.json { render json: @challenge_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @challenge_instance = ChallengeInstance.new(challenge_instance_params)\n\n respond_to do |format|\n if @challenge_instance.save\n format.html { redirect_to @challenge_instance, notice: 'Challenge instance was successfully created.' }\n format.json { render :show, status: :created, location: @challenge_instance }\n else\n format.html { render :new }\n format.json { render json: @challenge_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def survey\n expose Survey.create(@oauth_token, params[:challenge_id].strip, \n params[:data])\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def create\n # TODO 既存 team を含めて保存する場合は認証に対応させる\n @concert = Concert.new(concert_savable_params)\n\n if @concert.save\n render :show, status: :created\n else\n render json: @concert.errors, status: :unprocessable_entity\n end\n end",
"def create\n timezone = \"%+03d:00\" % params[:timezone]\n params[:challenge][:start] += timezone\n params[:challenge][:end] += timezone\n\n group = Group.find(params[:group_id])\n @challenge = group.challenges.build(params[:challenge])\n @challenge.group.users.each do |user|\n Action.create( :challenge => @challenge, :user => user, :count => 0)\n end\n\n respond_to do |format|\n if @challenge.save\n format.html { redirect_to @challenge, notice: 'Challenge was successfully created.' }\n format.json { render json: @challenge, status: :created, location: @challenge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createChallenges\n for tab in Lecode_BattleChallenge::Challenges\n chall = Battle_Challenge.new\n chall.name = tab[0]\n chall.icon = tab[1]\n chall.description = tab[2]\n chall.gain = tab[3]\n chall.freq = tab[4]\n chall.success_onEnd = tab[5]\n chall.id = @challenges.size\n @challenges.push(chall)\n init_evaluation(chall.name)\n end\n \n end",
"def create\n @contest = Contest.new(params[:contest])\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to(@contest, :notice => 'Contest was successfully created.') }\n format.xml { render :xml => @contest, :status => :created, :location => @contest }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@challenge = Challenge.new(challenge_params)\n\t\t@challenge.score = 0;\n\n\t\tif @challenge.save\n\t\t\tredirect_to challenges_path\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\n\tend",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def create_challenge_resource\n return unless current_user.site_or_challenge_admin?\n\n challenge = Challenge.find_by!(id: unsafe_params[:challenge_id])\n unless challenge.editable_by?(@context)\n fail \"Challenge cannot be modified by current user.\"\n end\n\n name = unsafe_params[:name]\n fail \"File name needs to be a non-empty String\" unless name.is_a?(String) && name != \"\"\n\n description = unsafe_params[\"description\"]\n unless description.nil?\n fail \"File description needs to be a String\" unless description.is_a?(String)\n end\n\n project = CHALLENGE_BOT_PRIVATE_FILES_PROJECT\n dxid = DNAnexusAPI.new(CHALLENGE_BOT_TOKEN).call(\"file\", \"new\", \"name\": unsafe_params[:name], \"project\": CHALLENGE_BOT_PRIVATE_FILES_PROJECT)[\"id\"]\n challenge_bot = User.challenge_bot\n\n UserFile.transaction do\n file = UserFile.create!(\n dxid: dxid,\n project: project,\n name: name,\n state: \"open\",\n description: description,\n user_id: challenge_bot.id,\n parent: challenge_bot,\n scope: 'private'\n )\n\n ChallengeResource.create!(\n challenge_id: challenge.id,\n user_file_id: file.id,\n user_id: @context.user_id\n )\n\n render json: { id: file.uid }\n end\n end",
"def challenge_params\n params.require(:challenge).permit(:name, :category, :description, :coins, :duration, :participant_number, :failed_number, :deadline, :image, :video)\n end",
"def new\n @challenge = Challenge.new\n add_breadcrumb 'new', @challenge\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end",
"def create\n @contest = Contest.new(params[:contest])\n\n respond_to do |format|\n if @contest.save\n flash[:notice] = 'Contest was successfully created.'\n format.html { redirect_to(@contest) }\n format.xml { render :xml => @contest, :status => :created, :location => @contest }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def challenge\n skip_authorization\n render(json: { message: \"Ruby on Rails Challenge 20200810\" }, status: 200)\n end",
"def challenges; end",
"def show\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @challenge }\n end\n end",
"def new\n @team_challenge = TeamChallenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @team_challenge }\n end\n end",
"def index\n @team_challenges = TeamChallenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @team_challenges }\n end\n end",
"def index\n @user_challenges = UserChallenge.all\n end",
"def challenge_params\n params.require(:challenge).permit(\n :title, \n :number_of_day, \n :activity, \n :difficulty, \n :distance, \n :deadline, \n :elevation,\n :trick,\n :duration\n )\n \n\n end",
"def challenge_params\n params.require(:challenge).permit(:title, :start_date, :end_date)\n end",
"def challenge_params\n params.require(:challenge).permit(:name, :description, :start_date, :end_date, :challenge_img, :total_offer, :amount_raised, :sponsor_blurb, :charity_blurb, :enabled, :seo_name, :img_thumb_url, :logo_url)\n end",
"def index\n\t\tif params[:tag]\n\t\t\t@challenges = Challenge.tagged_with(params[:tag])\n\t\telse\n\t\t\t@challenges = Challenge.all\n\t\tend\n\tend",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end",
"def submit_answers(connection_id, answers)\n connection_id.require!(as: 'connection_id')\n answers.require!(as: 'answers')\n answers.each do |answer|\n answer.require!(:answer, :question)\n end\n\n params = { questions: answers.to_json }\n api(:put, \"/connections/#{connection_id}/challenges\", params)\n .fetch('challenges')\n .cast(Challenge)\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def create\n @challenge = Challenge.new(params[:challenge])\n if !params[:challenge][:challenge_img].nil? && params[:challenge][:challenge_img] != \"\" then\n uploaded_io = params[:challenge][:challenge_img]\n if uploaded_io != \"\" then\n upload_dir = image_upload_path + \"challenges/#{@challenge.id}/\"\n if !File.exists?(upload_dir) then\n Dir.mkdir(upload_dir)\n end\n File.open(upload_dir + uploaded_io.original_filename, 'w') do |file|\n file.write(uploaded_io.read)\n params[:challenge][:challenge_img] = \"/uploads/challenges/#{@challenge.id}/\" + File.basename( file.path )\n end\n end\n end\n respond_to do |format|\n if @challenge.save then\n flash[:notice] = 'Challenge was successfully created.'\n format.html { redirect_to(@challenge) }\n format.xml { render :xml => @challenge, :status => :created, :location => @challenge }\n else\n @charities = Charity.find(:all, :order => :name)\n @sponsors = Sponsor.find(:all, :order => :name)\n @activities = Activity.find(:all, :order => :name)\n @tags = Tag.find(:all, :order => :name)\n format.html { render :action => \"new\", :locals => { :charities => @charities,:sponsors => @sponsors, :activities => @activities, :tags => @tags } }\n format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def challenge_response_params\n params.require(:challenge_response).permit({:input => {}}, :asked_at, :completed_at, :challenge_id, :user_id, :course_id, :status)\n end",
"def index\n @challenges = Challenge.all params[:filters], params[:page]\n end",
"def create\n @contest = Contest.new(params[:contest])\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, notice: 'Contest was successfully created.' }\n format.json { render json: @contest, status: :created, location: @contest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contest = Contest.new(params[:contest])\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, notice: 'Contest was successfully created.' }\n format.json { render json: @contest, status: :created, location: @contest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contest = Contest.new(params[:contest])\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, notice: 'Contest was successfully created.' }\n format.json { render json: @contest, status: :created, location: @contest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n if @challenge.update_attributes(params[:challenge])\n flash[:notice] = 'Challenge was successfully updated.'\n format.html { redirect_to(@challenge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n if @challenge.update_attributes(params[:challenge])\n flash[:notice] = 'Challenge was successfully updated.'\n format.html { redirect_to(@challenge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_challenge\n @challenge = Challenge.find(params[:challenge_id])\n end",
"def challenge_response_params\n params.require(:challenge_response).permit({:input => {}}, :asked_at, :completed_at, :challenge_id, :user_id, :course_id, :status, :anonymous_user_id)\n end",
"def create\n respond_to do |format|\n if @ai_contest.update_attributes(permitted_params)\n format.html { redirect_to @ai_contest, notice: 'Ai contest was successfully created.' }\n format.json { render json: @ai_contest, status: :created, location: @ai_contest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ai_contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @challenge = Challenge.new\n #@challenge.build_contest unless @challenge.contest\n\n end",
"def challenge_params\n params.require(:challenge).permit(:title, :description, :stepOne, :stepTwo, :stepThree, :stepFour, :users)\n end",
"def new\n @challenge = Challenge.new\n end",
"def new\n @title = \"Grade a Team Challenge\"\n @challenge_grade = ChallengeGrade.new\n @teams = Team.all\n @challenges = Challenge.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge_grade }\n end\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def POST; end",
"def create\n @contest_entry = ContestEntry.new(params[:contest_entry])\n\n respond_to do |format|\n if @contest_entry.save\n format.html { redirect_to new_contest_entry_path, :notice => 'Contest was successfully entered.' }\n format.xml { render :xml => @contest_entry, :status => :created, :location => @contest_entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contest_entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contest = Contest.new(params[:contest])\n @contest.contractor_id = current_user.id\n \n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, :notice => 'Contest was successfully created.' }\n format.json { render :json => @contest, :status => :created, :location => @contest }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def user_challenge_params\n params.require(:user_challenge).permit(:user_id, :challenge_id)\n end",
"def for_connection(id)\n id.require!(as: :id)\n api(:get, \"/connections/#{id}/challenges\")\n .fetch('challenges')\n .cast(Challenge)\n end",
"def challenge_solution_params\n params.require(:challenge_solution).permit(:user_id, :integer, :name, :string, :challenge_id, :integer, :destription, :string)\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @contest }\n end\n end",
"def challenge\n verify_session() or redirect_to action:'dashboard'\n @rival = User.find params[:id]\n retreiveChallenges #UserHelper::ChallengeInterface\n @challenge = Challenge.new\n end",
"def create\n @weekly_challenge = WeeklyChallenge.new(weekly_challenge_params)\n\n if params[:weekly_challenge][:question_id] == \"\"\n @weekly_challenge.question_id = Question.power_link_sample_question\n end\n\n respond_to do |format|\n if @weekly_challenge.save\n format.html { redirect_to backoffice_weekly_challenge_path(@weekly_challenge), notice: 'Weekly challenge was successfully created.' }\n format.json { render :show, status: :created, location: backoffice_weekly_challenge_path(@weekly_challenge) }\n else\n format.html { render :new }\n format.json { render json: @weekly_challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n self.resource = new_resource\n \n respond_to do |format|\n if resource.save\n format.html do\n flash[:notice] = \"#{resource_name.humanize} was successfully created.\"\n redirect_to challenge_url(resource)\n end\n format.js\n format.xml { render :xml => resource, :status => :created, :location => resource_url }\n else\n format.html { render :action => \"new\" }\n format.js { render :action => \"new\" }\n format.xml { render :xml => resource.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6130845",
"0.6104952",
"0.599289",
"0.5959405",
"0.59540683",
"0.5828759",
"0.5825292",
"0.57907087",
"0.5732005",
"0.57133687",
"0.5711412",
"0.5680116",
"0.5673288",
"0.56070834",
"0.56000197",
"0.5578913",
"0.5567122",
"0.5557702",
"0.5557702",
"0.55560833",
"0.55448914",
"0.5541479",
"0.5530711",
"0.5530711",
"0.5530711",
"0.5530711",
"0.5512158",
"0.54839677",
"0.54284096",
"0.54167724",
"0.53936726",
"0.53879386",
"0.5379608",
"0.5365741",
"0.5353098",
"0.5353098",
"0.5333009",
"0.53314126",
"0.53314126",
"0.53139013",
"0.5306556",
"0.52937186",
"0.5285316",
"0.52848095",
"0.5280099",
"0.5280099",
"0.52758867",
"0.5267697",
"0.5256668",
"0.5251354",
"0.52438426",
"0.5221085",
"0.52025867",
"0.51887995",
"0.51882845",
"0.5186075",
"0.51728296",
"0.51709044",
"0.5164141",
"0.5132183",
"0.5126625",
"0.5126625",
"0.5126625",
"0.5119533",
"0.51098955",
"0.51098955",
"0.51098955",
"0.51098955",
"0.51098955",
"0.51098955",
"0.51098955",
"0.51098955",
"0.51098955",
"0.5108389",
"0.5084553",
"0.50680786",
"0.5055784",
"0.5055784",
"0.5055784",
"0.5053333",
"0.5053333",
"0.5045244",
"0.5022059",
"0.50184023",
"0.50081444",
"0.49779797",
"0.49693933",
"0.49576375",
"0.49391407",
"0.4923628",
"0.4921033",
"0.49085018",
"0.49076572",
"0.48878354",
"0.48720136",
"0.48666647",
"0.48665905",
"0.48634967",
"0.4863144",
"0.4857823"
] |
0.6457111
|
0
|
PUT /challenges/1 PUT /challenges/1.xml
|
def update
@challenge = Challenge.find(params[:id])
respond_to do |format|
if @challenge.update_attributes(params[:challenge])
flash[:notice] = 'Challenge was successfully updated.'
format.html { redirect_to(@challenge) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n expose Challenge.update(@oauth_token, params[:challenge_id].strip,\n params[:data])\n end",
"def update\n @challenge ||= Challenge.find(params[:id])\n\n respond_to do |format|\n if @challenge.update_attributes(params[:challenge])\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n if @challenge.update_attributes(params[:challenge])\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n if @challenge.update_attributes(params[:challenge])\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n respond_to do |format|\n if @challenge.update_attributes(challenge_params)\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n if @challenge.update_attributes(params[:challenge])\n format.html { redirect_to @challenge.lead, notice: 'Challenge was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update\n @team_challenge = TeamChallenge.find(params[:id])\n\n respond_to do |format|\n if @team_challenge.update_attributes(params[:team_challenge])\n format.html { redirect_to @team_challenge, :notice => 'Team challenge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @team_challenge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end",
"def update\n @response_challenge = ResponseChallenge.find(params[:id])\n\n respond_to do |format|\n if @response_challenge.update_attributes(params[:response_challenge])\n format.html { redirect_to @response_challenge, notice: 'Response challenge was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @response_challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @challenge = Challenge.find(params[:id])\n\n respond_to do |format|\n if @challenge.update(challenge_params)\n format.html { redirect_to [:admin, @challenge], notice: 'Challenge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @challenge = Challenge.find_by_id_and_enabled(params[:id], true)\n if !@challenge.nil? && @challenge.user.id.to_s == session[:user_id].to_s then\n if !params[:challenge][:challenge_img].nil? && params[:challenge][:challenge_img] != \"\" then\n uploaded_io = params[:challenge][:challenge_img]\n if uploaded_io != \"\" then\n upload_dir = image_upload_path + \"challenges/#{@challenge.id}/\"\n if !File.exists?(upload_dir) then\n Dir.mkdir(upload_dir)\n end\n File.open(upload_dir + uploaded_io.original_filename, 'w') do |file|\n file.write(uploaded_io.read)\n params[:challenge][:challenge_img] = \"/uploads/challenges/#{@challenge.id}/\" + File.basename( file.path )\n end\n end\n end\n respond_to do |format|\n if @challenge.update_attributes(params[:challenge]) then\n flash[:notice] = 'Challenge was successfully updated.'\n format.html { redirect_to(@challenge) }\n format.xml { head :ok }\n else\n @charities = Charity.find(:all, :order => :name)\n @sponsors = Sponsor.find(:all, :order => :name)\n @activities = Activity.find(:all, :order => :name)\n @tags = Tag.find(:all, :order => :name)\n format.html { render :action => \"edit\", :locals => { :charities => @charities, :sponsors => @sponsors, :activities => @activities, :tags => @tags } }\n format.xml { render :xml => @challenge.errors, :status => :unprocessable_entity }\n end\n end\n else\n flash[:error_message] = \"You cannot update this challenge.\"\n respond_to do |format|\n format.html { render \"errors/index\" }\n format.xml { render :xml => flash[:error_message] }\n end\n end\n end",
"def update\n respond_to do |format|\n if @challenge.update(challenge_params)\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { render :show, status: :ok, location: @challenge }\n else\n format.html { render :edit }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @challenge.update(challenge_params)\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { render :show, status: :ok, location: @challenge }\n else\n format.html { render :edit }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @challenge.update(challenge_params)\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { render :show, status: :ok, location: @challenge }\n else\n format.html { render :edit }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @challenge.update(challenge_params)\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { render :show, status: :ok, location: @challenge }\n else\n format.html { render :edit }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @challenge.update(challenge_params)\n format.html { redirect_to @challenge, notice: 'Challenge was successfully updated.' }\n format.json { render :show, status: :ok, location: @challenge }\n else\n format.html { render :edit }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def update\n respond_to do |format|\n if @challenge.update(challenge_params)\n format.html { redirect_to @challenge, notice: \"Challenge was successfully updated.\" }\n format.json { render :show, status: :ok, location: @challenge }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to(@contest, :notice => 'Contest was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n #REQUIRES: existence of contest with :id\n #MODIFIES: the database\n #EFFECTS: updates the database with info about contest with \"id provided by user via 'edit.'\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n flash[:notice] = 'Contest was successfully updated.'\n format.html { redirect_to(@contest) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n flash[:notice] = 'Contest was successfully updated.'\n format.html { redirect_to(contests_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n flash[:notice] = 'Contest was successfully updated.'\n format.html { redirect_to(@contest) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def update\n @entry = Entry.find(params[:id])\n\n if @entry.nil? or @entry.challenge.is_closed?\n redirect_to :root\n return\n end\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(@challenge, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def make_put_request\n options = {\n use_ssl: true,\n cert: OpenSSL::X509::Certificate.new(@certificate),\n key: OpenSSL::PKey::RSA.new(@key),\n ca_file: @uw_ca_file,\n verify_mode: OpenSSL::SSL::VERIFY_PEER\n }\n Net::HTTP.start(@uri.host, @uri.port, options) do |http|\n request = Net::HTTP::Put.new(@uri.request_uri)\n request.body = @request_text\n @response = http.request(request)\n end\n puts \"Response is: #{get_response_code}\"\n puts \"Body is: #{@response.body}\"\n @response.body\n end",
"def solveticket(assigneeid, ticketidxml)\n\n raise ArgumentError.new(\"no assignee is present\") if assigneeid.empty?\n raise ArgumentError.new(\"ticketid is present text provided\") if ticketidxml.empty?\n\n xml = createsolvedticketxml(assigneeid)\n\n begin\n resource = RestClient::Resource.new @hostname, @username, @password\n url = 'tickets/'+ ticketidxml\n httpresponse = resource[url].put xml.to_s, :content_type => 'application/xml', :accept => '*/*'\n processresponse(httpresponse) # call success handler\n rescue => e\n processerror(e) # call error handler\n end\n\n end",
"def update\n @contest = Contest.find_by(path: params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to contest_path(@contest.path)+'/upload' }\n #format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n #format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @defect = Defect.find(params[:id])\n\n respond_to do |format|\n if @defect.update_attributes(params[:defect])\n flash[:notice] = 'Defect was successfully updated.'\n format.html { redirect_to(@defect) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @defect.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @conseq = Conseq.find(params[:id])\n\n respond_to do |format|\n if @conseq.update_attributes(params[:conseq])\n format.html { redirect_to(@conseq, :notice => 'Conseq was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @conseq.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @concert = Concert.find(params[:id])\n\n respond_to do |format|\n if @concert.update_attributes(concert_params)\n format.html { redirect_to(@concert, :notice => 'Concert was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => 'edit' }\n format.xml { render :xml => @concert.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def update\n @cheque = Cheque.find(params[:id])\n\n respond_to do |format|\n if @cheque.update_attributes(params[:cheque])\n format.html { redirect_to(@cheque, :notice => 'Cheque was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cheque.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @challenges }\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, :notice => 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, options={})\n send_request 'put', path, options\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ai_contest = AiContest.find(params[:id])\n\n respond_to do |format|\n if @ai_contest.update_attributes(ai_contest_params)\n format.html { redirect_to @ai_contest, notice: 'Ai contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ai_contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def update\n\t\t@challenge = Challenge.find(params[:id])\n\n\t\tif @challenge.update(challenge_params)\n\t\t\tredirect_to challenges_path\n\t\telse\n\t\t\trender 'edit'\n\t\tend\n\tend",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def update\n if @challenge.update(challenge_params)\n redirect_to chapter_path(@challenge.chapter)\n else\n render 'edit'\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def update\n @clique = Clique.find(params[:id])\n\n respond_to do |format|\n if @clique.update_attributes(params[:clique])\n flash[:notice] = 'Clique was successfully updated.'\n format.html { redirect_to(@clique) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @clique.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @constraint = Constraint.find(params[:id])\n\n respond_to do |format|\n if @constraint.update_attributes(params[:constraint])\n format.html { redirect_to @constraint, notice: 'Constraint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @constraint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update\n block_non_user\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @caso.update_attributes(caso_params)\n format.html { redirect_to @caso, notice: 'Caso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def update\n @youth_problem = YouthProblem.find(params[:id])\n\n respond_to do |format|\n if @youth_problem.update_attributes(params[:youth_problem])\n format.html { redirect_to(@youth_problem, :notice => 'Youth problem was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @youth_problem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @cheque = Cheque.find(params[:id])\n\n respond_to do |format|\n if @cheque.update_attributes(params[:cheque])\n format.html { redirect_to @cheque, notice: 'Cheque was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cheque.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.json { render :json => 'Question updated OK' }\n format.xml { head :ok }\n else\n format.json { render :json => @question.errors }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @craque = Craque.find(params[:id])\n\n respond_to do |format|\n if @craque.update_attributes(params[:craque])\n format.html { redirect_to @craque, notice: 'Craque was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @craque.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @coin_set = CoinSet.find(params[:id])\n \n respond_to do |format|\n if @coin_set.update_attributes(params[:coin_set])\n # an update should be coming from the coin_set show page.\n format.html { redirect_to @coin_set, notice: 'Coin set was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @coin_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @exercicio = Exercicio.find(params[:id])\n\n respond_to do |format|\n if @exercicio.update_attributes(params[:exercicio])\n flash[:notice] = 'Exercicio was successfully updated.'\n format.html { redirect_to(@exercicio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @exercicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n contestID = params[:id]\n submissionID = params[:contestID]\n res = Contests.set_winner(contestID, submissionID)\n # email using mailjet\n contest = Contests.get_contest(contestID).first\n test = \"Congrats on winning the contest: #{contest[\"title\"]}, You have won $#{contest[\"price\"]}!\"\n system(\"curl -X POST --user \\\"7c80d03e683e8c7313d50629a9feafb7:434aaee16cb9e82e6ff117fc2716c2c7\\\" https://api.mailjet.com/v3/send/message -F from='kelvin.ma23@gmail.com' -F to=james.gibbons@gmail.com -F subject='Congrats on winning!' -F text='#{test}'\")\n redirect_to \"/contests/view/#{contestID}\"\n end",
"def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def update\n @cue = Cue.find(params[:id])\n\n respond_to do |format|\n if @cue.update_attributes(params[:cue])\n format.html { redirect_to @cue, notice: 'Cue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @howto = Howto.find(params[:id])\n\n respond_to do |format|\n if @howto.update_attributes(params[:howto])\n flash[:notice] = 'Howto was successfully updated.'\n format.html { redirect_to(@howto) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @howto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @constraint.update(constraint_params)\n format.html { redirect_to @constraint, notice: 'Constraint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @constraint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @condolence = Condolence.find(params[:id])\n\n respond_to do |format|\n if @condolence.update_attributes(params[:condolence])\n format.html { redirect_to @condolence, notice: 'Condolence was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @condolence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_challenge.update(user_challenge_params)\n format.html { redirect_to @user_challenge, notice: 'User challenge was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_challenge }\n else\n format.html { render :edit }\n format.json { render json: @user_challenge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @step = TaskrequestsStep.find(params[:taskrequests_step_id])\n @absence_request = @step.absence_requests.find(params[:id])\n\n respond_to do |format|\n if @absence_request.update_attributes(params[:absence_request])\n format.html { redirect_to(@absence_request, :notice => 'Absence request was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @absence_request.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def request_put(path)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"PUT\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Put.new(uri)\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend",
"def update\n @threat = Threat.find(params[:id])\n\n respond_to do |format|\n if @threat.update_attributes(params[:threat])\n format.html { redirect_to(@threat, :notice => 'Threat was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @threat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @cerc = Cerc.find(params[:id])\n\n if @cerc.update_attributes(params[:cerc])\n head :no_content\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end",
"def update\n @response = Response.find(params[:id])\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question = Question.find(params[:question_id])\n\n respond_to do |format|\n if @response.update_attributes(params[:response])\n format.html { redirect_to(@response, :notice => 'Response was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @response.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @solution = Solution.find(params[:id])\n\n respond_to do |format|\n if @solution.update_attributes(params[:solution])\n format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @verb = Verb.find(params[:id])\n\n if @verb.update(verb_params)\n head :no_content\n else\n render json: @verb.errors, status: :unprocessable_entity\n end\n end",
"def update\n @encounter_enemy = EncounterEnemy.find(params[:id])\n\n respond_to do |format|\n if @encounter_enemy.update_attributes(params[:encounter_enemy])\n format.html { redirect_to(@encounter_enemy, :notice => 'Encounter enemy was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @encounter_enemy.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, options={}, format=format)\n request(:put, path, options, format)\n end",
"def update\n @exprience = Exprience.find(params[:id])\n\n respond_to do |format|\n if @exprience.update_attributes(params[:exprience])\n format.html { redirect_to @exprience, notice: 'Exprience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exprience.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n if @quest.update_attributes(params[:quest])\n format.html { redirect_to(@quest, :notice => 'Quest was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @helocagree = Helocagree.find(params[:id])\n\n respond_to do |format|\n if @helocagree.update_attributes(params[:helocagree])\n flash[:notice] = 'Helocagree was successfully updated.'\n format.html { redirect_to(@helocagree) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @helocagree.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_set\n req = c.set(\"/foo\", \"bar\", 123, &blk)\n\n assert_sent(req.tag, :verb => V::SET, :cas => 123, :path => \"/foo\", :value => \"bar\")\n assert_recv(reply(req.tag, :cas => 123))\n end",
"def put(path, opts = {})\n request(:put, path, opts).body\n end",
"def update\n @concour = Concour.find(params[:id])\n\n respond_to do |format|\n if @concour.update_attributes(params[:concour])\n format.html { redirect_to @concour, notice: 'Concour was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @solution = @idea.solutions.find(params[:id])\n\n if @solution.update_attributes(params[:solution])\n render json: { text: \"success\" }\n else\n render json: { text: \"fail\"}\n end\n end",
"def update\n generic_update(PlayerChallenge, :player_challenge)\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def set_challenge\n @challenge = Challenge.find(params[:id])\n end",
"def update\n @critical_question = CriticalQuestion.find(params[:id])\n\n respond_to do |format|\n if @critical_question.update_attributes(params[:critical_question])\n format.html { redirect_to @critical_question, notice: 'Critical question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_question.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.61307466",
"0.59746647",
"0.59345686",
"0.59345686",
"0.5857802",
"0.57398766",
"0.5711691",
"0.56959635",
"0.56398433",
"0.56285036",
"0.5594382",
"0.55895764",
"0.5561022",
"0.55583876",
"0.55583876",
"0.55583876",
"0.55583876",
"0.55583876",
"0.5556457",
"0.55464333",
"0.54911643",
"0.5485377",
"0.5482356",
"0.5474206",
"0.5471081",
"0.542686",
"0.5426769",
"0.54109436",
"0.53912616",
"0.53835595",
"0.53671575",
"0.5359851",
"0.53453404",
"0.53116405",
"0.5311527",
"0.52981836",
"0.529296",
"0.529201",
"0.52866846",
"0.52817416",
"0.52644694",
"0.52590114",
"0.52485627",
"0.5245381",
"0.5245381",
"0.52378166",
"0.5234559",
"0.5229461",
"0.520642",
"0.5202743",
"0.5202743",
"0.520098",
"0.52007276",
"0.52007276",
"0.5198176",
"0.51904565",
"0.51902974",
"0.5179599",
"0.51674616",
"0.51594436",
"0.5155824",
"0.5145401",
"0.5145401",
"0.5134289",
"0.513069",
"0.5124595",
"0.5117699",
"0.51051885",
"0.510417",
"0.51038384",
"0.5101615",
"0.5100739",
"0.50899136",
"0.50877595",
"0.50866634",
"0.5083555",
"0.5080515",
"0.5079371",
"0.50731325",
"0.50664216",
"0.50646013",
"0.50508904",
"0.50483745",
"0.50425786",
"0.5041914",
"0.5040598",
"0.5034599",
"0.503343",
"0.50239575",
"0.5022509",
"0.5018148",
"0.50150037",
"0.50132877",
"0.5008592",
"0.5006613",
"0.5005961",
"0.5004066",
"0.5004066",
"0.50026095"
] |
0.63591146
|
1
|
DELETE /challenges/1 DELETE /challenges/1.xml
|
def destroy
@challenge = Challenge.find(params[:id])
@challenge.destroy
respond_to do |format|
format.html { redirect_to(challenges_url) }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n #REQUIRES: existence of contest with :id\n #MODIFIES: the database\n #EFFECTS: deletes the information in the database of the contest with :id\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to(contests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @concert = Concert.find(params[:id])\n @concert.destroy\n\n respond_to do |format|\n format.html { redirect_to(concerts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to(contests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to(contests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to(contests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge ||= Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @response_challenge = ResponseChallenge.find(params[:id])\n @response_challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to response_challenges_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @conseq = Conseq.find(params[:id])\n @conseq.destroy\n\n respond_to do |format|\n format.html { redirect_to(conseqs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @concert = Concert.find(params[:id])\n @concert.destroy\n\n respond_to do |format|\n format.html { redirect_to(concerts_url, :notice=> 'Concert was deleted.') }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clique = Clique.find(params[:id])\n @clique.destroy\n\n respond_to do |format|\n format.html { redirect_to(cliques_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @certificado = Certificado.find(params[:id])\n @certificado.destroy\n\n respond_to do |format|\n format.html { redirect_to(certificados_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to challenges_url, notice: 'Challenge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to challenges_url, notice: 'Challenge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to challenges_url, notice: 'Challenge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find_by(path: params[:id])\n\n destroy_directory(@contest.path)\n destroy_problems(@contest)#with submits\n destroy_participants(@contest)\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n #format.json { head :no_content }\n end\n end",
"def destroy\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to challenges_url, notice: \"Challenge was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cheque = Cheque.find(params[:id])\n @cheque.destroy\n\n respond_to do |format|\n format.html { redirect_to(cheques_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @certidao = Certidao.find(params[:id])\n @certidao.destroy\n\n respond_to do |format|\n format.html { redirect_to(certidaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @verb.destroy\n\n head :no_content\n end",
"def destroy\n @team_challenge = TeamChallenge.find(params[:id])\n @team_challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to team_challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @defect = Defect.find(params[:id])\n @defect.destroy\n\n respond_to do |format|\n format.html { redirect_to(defects_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @absence_request = AbsenceRequest.find(params[:id])\n @absence_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(absence_requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @auto1h_fold_change = Auto1hFoldChange.find(params[:id])\n @auto1h_fold_change.destroy\n\n respond_to do |format|\n format.html { redirect_to(auto1h_fold_changes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to @challenge.lead, notice: 'Challenge was successfully destroyed.' }\n format.json { head :ok }\n end\n end",
"def destroy\n @convenio = Convenio.find(params[:id])\n @convenio.destroy\n\n respond_to do |format|\n format.html { redirect_to(convenios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exercicio = Exercicio.find(params[:id])\n @exercicio.destroy\n\n respond_to do |format|\n format.html { redirect_to(exercicios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @decision = Decision.find(params[:id])\n @decision.destroy\n\n respond_to do |format|\n format.html { redirect_to(decisions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exam_candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to(candidates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exam = Exam.find(params[:id])\n @exam.destroy\n\n respond_to do |format|\n format.html { redirect_to(exams_url) }\n format.xml { head :ok }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @correspondence = Correspondence.find(params[:id])\n @correspondence.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondences_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @complain = Complain.find(params[:id])\n @complain.destroy\n\n respond_to do |format|\n format.html { redirect_to(complains_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rehab = Rehab.find(params[:id])\n @rehab.destroy\n\n respond_to do |format|\n format.html { redirect_to(rehabs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reqinfo = Reqinfo.find(params[:id])\n @reqinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reqinfos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hacker = Hacker.find(params[:id])\n @hacker.destroy\n\n respond_to do |format|\n format.html { redirect_to(hackers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge.destroy\n render :index\n \n end",
"def destroy\n @encounter = Encounter.find(params[:id])\n @encounter.destroy\n\n respond_to do |format|\n format.html { redirect_to(encounters_url) }\n format.xml { head :ok }\n end\n end",
"def test_set3_04c_delete_principal()\n user = \"test_user\"\n @test_acl.create_principal(user)\n id = @test_acl.create_ace(user, \"allow\", \"SELECT\", \"test\", \"/db/temporary/testsource\")\n \n @test_acl.delete_principal(user)\n query = \"doc(\\\"#{@col_path}acl.xml\\\")//node()[@id=\\\"#{id}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end",
"def destroy\n @player_challenge = PlayerChallenge.find(params[:id])\n @player_challenge.destroy\n respond_to do |format|\n format.html { redirect_to player_challenges_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cattle_id = CattleId.find(params[:id])\n @cattle_id.destroy\n\n respond_to do |format|\n format.html { redirect_to(cattle_ids_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @helibasis = Helibase.find(params[:id])\n @helibasis.destroy\n\n respond_to do |format|\n format.html { redirect_to(helibases_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ref = Ref.find(params[:id])\n @ref.destroy\n\n respond_to do |format|\n format.html { redirect_to(refs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @quest = Quest.find(params[:id])\n @quest.destroy\n\n respond_to do |format|\n format.html { redirect_to(quests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @candy = Candy.find(params[:id])\n @candy.destroy\n\n respond_to do |format|\n format.html { redirect_to(candies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cadet = Cadet.find(params[:id])\n @cadet.destroy\n\n respond_to do |format|\n format.html { redirect_to cadets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coin_set = CoinSet.find(params[:id])\n @coin_set.destroy\n\n respond_to do |format|\n format.html { redirect_to coin_sets_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @haiku = Haiku.find(params[:id])\n @haiku.destroy\n\n respond_to { |format|\n format.html {\n\tredirect_to haikus_url\n }\n format.xml {\n\thead :ok\n }\n }\n end",
"def destroy\n @chamados = Chamado.find(params[:id])\n @chamados.destroy\n respond_to do |format|\n format.html { redirect_to(chamados_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ca = Ca.find(params[:id])\n @ca.destroy\n\n respond_to do |format|\n format.html { redirect_to cas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @my_exercise = MyExercise.find(params[:id])\n @my_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to(my_exercises_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n block_non_user\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @yml_file = Cmtool::YmlFile.find(params[:id])\n @yml_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(cmtool.yml_files_url, notice: I18n.t('cmtool.action.destroy.successful', model: Cmtool::YmlFile.model_name.human)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recommand = Recommand.find(params[:id])\n @recommand.destroy\n\n respond_to do |format|\n format.html { redirect_to(recommands_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url, :notice => 'Contest was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @encounter_enemy = EncounterEnemy.find(params[:id])\n @encounter_enemy.destroy\n\n respond_to do |format|\n format.html { redirect_to(encounter_enemies_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @req_breakdown = ReqBreakdown.find(params[:id])\n @req_breakdown.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_req_breakdowns_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n remove_user_participation @challenge.id\n Activity.create(user_id: current_user.id, challenge_id: @challenge.id, relation:\"Deleted\")\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to challenges_url, notice: 'Challenge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @accordion = Accordion.find(params[:id])\n @accordion.destroy\n\n respond_to do |format|\n format.html { redirect_to(accordions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @howto = Howto.find(params[:id])\n @howto.destroy\n\n respond_to do |format|\n format.html { redirect_to(howtos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hetero1h_fold_change = Hetero1hFoldChange.find(params[:id])\n @hetero1h_fold_change.destroy\n\n respond_to do |format|\n format.html { redirect_to(hetero1h_fold_changes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @achievement = Achievement.find(params[:id])\n @achievement.destroy\n\n respond_to do |format|\n format.html { redirect_to(achievements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hr_attendence = Hr::Attendence.find(params[:id])\n @hr_attendence.destroy\n\n respond_to do |format|\n format.html { redirect_to(hr_attendences_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @threat = Threat.find(params[:id])\n @threat.destroy\n\n respond_to do |format|\n format.html { redirect_to(threats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @solution = PeerReviewSolution.find(params[:id])\n @solution.destroy\n\n respond_to do |format|\n format.html { redirect_to(solutions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @chirp = Chirp.find(params[:id])\n @chirp.destroy\n\n respond_to do |format|\n format.html { redirect_to(chirps_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reclamo = Reclamo.find(params[:id])\n @reclamo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cuitcheque = Cuitcheque.find(params[:id])\n @cuitcheque.destroy\n respond_to do |format|\n format.html { redirect_to(cuitcheques_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def destroy\n @criterion = Criterion.find(params[:id])\n @criterion.destroy\n\n respond_to do |format|\n format.html { redirect_to(subject_url(@criterion.subject)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ca.destroy\n respond_to do |format|\n format.html { redirect_to cas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contratacion = Contratacion.find(params[:id])\n @contratacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(contratacions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @confection.destroy\n respond_to do |format|\n format.html { redirect_to confections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @correspondenciasclase = Correspondenciasclase.find(params[:id])\n @correspondenciasclase.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondenciasclases_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @vocab = Vocab.find(params[:id])\n @vocab.destroy\n\n respond_to do |format|\n format.html { redirect_to(vocabs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @weekly_challenge.destroy\n respond_to do |format|\n format.html { redirect_to weekly_challenges_url, notice: 'Weekly challenge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def destroy\n @court = Court.find(params[:id])\n @court.destroy\n respond_to do |format|\n format.html { redirect_to(courts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end",
"def destroy\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to user_path(current_user.id), notice: \"Dommage, ton challenge n'est pas validé. tu pourras toujours un recréer un !!\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chore = Chore.find(params[:id])\n @chore.destroy\n\n respond_to do |format|\n format.html { redirect_to(chores_path, :notice => 'Chore deleted.') }\n format.xml { head :ok }\n end\n end"
] |
[
"0.6849034",
"0.67672354",
"0.67376816",
"0.67376816",
"0.67376816",
"0.67259276",
"0.67171764",
"0.6706058",
"0.6705198",
"0.6659304",
"0.664068",
"0.66222394",
"0.66201735",
"0.6579831",
"0.6557695",
"0.64986295",
"0.6492962",
"0.64544207",
"0.64317",
"0.64219475",
"0.64219475",
"0.64219475",
"0.64193344",
"0.64183414",
"0.63852423",
"0.63747805",
"0.6360495",
"0.63538533",
"0.63485056",
"0.634574",
"0.633728",
"0.6336446",
"0.63326573",
"0.63201153",
"0.63040125",
"0.62968296",
"0.6288833",
"0.6284973",
"0.62841696",
"0.6271123",
"0.62567353",
"0.62566173",
"0.62566173",
"0.62566173",
"0.62566173",
"0.624776",
"0.62453413",
"0.6244642",
"0.6243572",
"0.6236414",
"0.62346035",
"0.6234494",
"0.6229438",
"0.6229379",
"0.62265766",
"0.6214264",
"0.6214153",
"0.6213932",
"0.6211844",
"0.6208922",
"0.62011486",
"0.6201056",
"0.6198281",
"0.61970747",
"0.6196918",
"0.6195357",
"0.6191785",
"0.6189996",
"0.61888176",
"0.6187444",
"0.61863494",
"0.6182336",
"0.618191",
"0.6180545",
"0.6178385",
"0.61715037",
"0.61703116",
"0.61666363",
"0.616549",
"0.61583525",
"0.61507446",
"0.61480135",
"0.61465",
"0.61451185",
"0.6143184",
"0.614184",
"0.6141383",
"0.6141125",
"0.61406267",
"0.61402994",
"0.6135497",
"0.61330765",
"0.613288",
"0.6129131",
"0.6129017",
"0.6118474",
"0.61168236",
"0.6115313",
"0.6114554"
] |
0.74575585
|
1
|
Fetch new IP Address from first_ip and index function
|
def fetch_ip_address(first_ip, i)
array = first_ip.split('.')
change = (array.first 3).push(array[-1].to_i + i)
new_ip = ""
for i in change
new_ip += "." + i.to_s
end
return new_ip[1..-1]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def next_assigned\n Ip.find(:first, :conditions => \n ['address_i > ? AND service = ? and network_id is not null', self.address_i, self.service], :order => 'address_i asc')\n end",
"def next_ip\n\t\t@ip_pos += 1\n\t\t@ip_pos = 0 if @ip_pos >= @arry_ips.length\n\tend",
"def index\n \n @ip_joins = @ipobject.saveIP(@virtualmachine.RemoteID,@virtualmachine.id)\n @ipaddresses = @virtualmachine.ipaddresses\n end",
"def get_ip(ip)\n\n #Recorremos todas las reservaciones del usuario\n Reservation.all.each do |reservation|\n #Si la ip de la reservacion es igual a la ip solicitante y tiene un asiento reservado\n # entonces le asigna una ip\n if reservation.ip == ip && (reservation.seat.reserved)\n #se le asigna una nueva ip\n ip = get_ip(add_number(ip))\n end\n end\n return ip\n end",
"def ip_first\n NetAddr::CIDR.create(cidr_obj.to_i(:network) + 2).ip\n end",
"def nth(index, options=nil)\n known_args = [:Objectify, :Short]\n objectify = false\n short = false\n\n # validate list\n raise ArgumentError, \"Integer expected for argument 'index' but \" +\n \"#{index.class} provided.\" if (!index.kind_of?(Integer) )\n\n # validate options\n if (options) \n raise ArgumentError, \"Hash expected for argument 'options' but #{options.class} provided.\" if (!options.kind_of?(Hash) )\n NetAddr.validate_args(options.keys,known_args)\n\n if( options.has_key?(:Short) && options[:Short] == true )\n short = true\n end\n\n if( options.has_key?(:Objectify) && options[:Objectify] == true )\n objectify = true\n end\n end\n\n my_ip = @network + index\n if ( (@hostmask | my_ip) == (@hostmask | @network) )\n\n if (!objectify)\n my_ip = NetAddr.ip_int_to_str(my_ip, @version)\n my_ip = NetAddr.shorten(my_ip) if (short && @version == 6)\n else\n my_ip = NetAddr.cidr_build(@version,my_ip)\n end\n\n else\n raise BoundaryError, \"Index of #{index} returns IP that is out of \" +\n \"bounds of CIDR network.\"\n end\n\n return(my_ip)\n end",
"def next_ip\n\t\treturn false if not valid?\n\t\tif (@curr_addr > @ranges[@curr_range][1])\n\t\t\tif (@curr_range >= @ranges.length - 1)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\t@curr_range += 1\n\t\t\t@curr_addr = @ranges[@curr_range][0]\n\t\tend\n\t\taddr = Rex::Socket.addr_itoa(@curr_addr, @ranges[@curr_range][2])\n\t\t@curr_addr += 1\n\t\treturn addr\n\tend",
"def public_ip_address\n public_ip_addresses.first\n end",
"def next_ip\n if (curr_ip_idx >= num_ips)\n return nil\n end\n\n if (curr_ip_idx > 0)\n self.curr_ip[3] = (curr_ip[3].to_i + 1) % 256\n self.curr_ip[2] = (curr_ip[2].to_i + 1) % 256 if (curr_ip[3] == 0)\n self.curr_ip[1] = (curr_ip[1].to_i + 1) % 256 if (curr_ip[2] == 0)\n self.curr_ip[0] = (curr_ip[0].to_i + 1) % 256 if (curr_ip[1] == 0)\n end\n\n self.curr_ip_idx += 1\n\n self.curr_ip.join('.')\n end",
"def address(public_ip)\n addresses(public_ip)[0]\n end",
"def private_ip_address\n private_ip_addresses.first\n end",
"def ip\n @ip ||= select { |type,value| type == :ip }.map do |(type,value)|\n IPAddr.new(value)\n end\n end",
"def next_assigned_or_reserved\n Ip.find(:first, :conditions => \n ['address_i > ? AND service = ? and (network_id is not null OR reserved_until is not null)', \n self.address_i, self.service], :order => 'address_i asc')\n end",
"def index\n @ip_adresses = IpAddress.all\n end",
"def ip_from_num(i)\n \"192.168.90.#{i+IP_OFFSET}\"\nend",
"def get_ip_address(id_unique)\r\n\tip_addr = $db.execute(\"SELECT ip_address FROM phone WHERE id_unique = ?\", id_unique)[0][0]\r\n\treturn ip_addr\t\r\nend",
"def ip_address_record(env)\n data_type = env[:machine].provider_config.private_only ? \"primaryBackendNetworkComponent\" : \"primaryNetworkComponent\"\n data_type = \"primaryBackendNetworkComponent\" if env[:machine].provider_config.force_private_ip\n mask = \"#{data_type}.primaryIpAddressRecord.id,#{data_type}.primaryIpAddressRecord.ipAddress\"\n record = sl_warden { env[:sl_machine].object_mask(\"mask[#{mask}]\").getObject }\n return {\n :address => record[data_type][\"primaryIpAddressRecord\"][\"ipAddress\"],\n :id => record[data_type][\"primaryIpAddressRecord\"][\"id\"]\n }\n end",
"def arp_src_ip= i; typecast \"arp_src_ip\", i; end",
"def ipaddr; end",
"def index\n @ip_names = IpName.all\n end",
"def get_node_ip(key)\n return @iplist[get_hash(key, @iplist.size)]\n end",
"def ip\n @ip ||= @node.search('IP/listEntry').map(&:inner_text)\n end",
"def ip; end",
"def ip; end",
"def locate\n @result ||= self.class.get(\n \"/\",\n :query => {:ip => @ip},\n :format => :xml\n )['HostipLookupResultSet']['gml:featureMember']\n end",
"def index\n @ip_lists = IpList.all\n end",
"def get_ipaddress(asset_tag=asset_tag, pool)\n @connection.ipaddress_allocate!(asset_tag, pool, count = 1)\n end",
"def set_ip_address\n @ip_address = IpAddress.find(params[:id])\n end",
"def first_page(ip)\n\t# query for ip list\n\tquery_url = BASE_DOMAIN + QUERY_VAR + ip\n\tdoc = open(query_url){|f| Hpricot(f)}\n\tcount = doc.search('//*[@id=\"count\"]').inner_text.gsub(' results','').to_i\n\t#pages = h.search('//*[@id=\"results_container\"]/div[2]/ul/li[2]/a')\n\tpagination = doc.search('//*[@id=\"results_container\"]/div[2]/ul/li/a')\n\treturn [doc,count,pagination]\nend",
"def ip_address; end",
"def ip_address; end",
"def ip_address; end",
"def ip_address; end",
"def ip_address; end",
"def ip_address; end",
"def getIpFromNum(ii)\n \"172.31.0.#{100+ii}\"\nend",
"def set_ip_adress\n @ip_adress = IpAddress.find(params[:id])\n end",
"def device_ipaddress=(_arg0); end",
"def device_ipaddress=(_arg0); end",
"def [](index)\n raise ArgumentError, \"Integer expected for argument 'index' but \" +\n \"#{index.class} provided.\" if (!index.kind_of?(Integer) )\n\n addr = @network + index\n if ( (@hostmask | addr) == (@hostmask | @network) )\n addr = NetAddr.cidr_build(@version, addr)\n else\n raise BoundaryError, \"Index of #{index} returns IP that is out of \" +\n \"bounds of CIDR network.\"\n end\n\n return(addr)\n end",
"def next_unused_elastic_ip\n if unused_elastic_ips.empty?\n nil\n else\n vputs(\"Found an unused elastic ip: #{unused_elastic_ips.first}\")\n unused_elastic_ips.first\n end\n end",
"def first\n IPAddr.new(@addr & @mask_addr, @family)\n end",
"def getMasterIp(num)\n return \"172.17.4.#{num+100}\"\nend",
"def nodeIP(num)\n return \"10.17.4.#{num+200}\"\nend",
"def arp_dest_ip= i; typecast \"arp_dest_ip\", i; end",
"def fetch_primary_ip_address\n capture(<<-GETADDR, :shell => \"bash\").chomp\n _if=\"$(netstat -nr | grep ^0\\.0\\.0\\.0 | awk '{print $8}')\";\n _ip=\"$(/sbin/ifconfig $_if | \\\n grep '^[[:space:]]*inet ' | awk '{print $2}' | \\\n awk -F':' '{print $2}')\";\n\n if [ -z \"$_ip\" -o \"$_ip\" == \"\" ] ; then\n echo \"\";\n return 10;\n else\n echo $_ip;\n fi\n GETADDR\nend",
"def ipaddr?; end",
"def ip\n self['ip'] = get_public_ip || get_ip\n end",
"def unused_ip args = {}\n # first check if we already have a record for this host\n # if we do, we can simply reuse the same ip address.\n if args[:mac] and r=has_mac?(args[:mac], :all) and valid_range(args).include?(r.ip)\n logger.debug \"Found an existing dhcp record #{r}, reusing...\"\n return r.ip\n end\n\n free_ips = valid_range(args) - records.collect{|r| r.ip}\n if free_ips.empty?\n logger.warn \"No free IPs at #{to_s}\"\n return nil\n else\n @index = 0\n begin\n # Read and lock the storage file\n stored_index = get_index_and_lock(\"foreman-proxy_#{network}_#{cidr}.tmp\")\n\n free_ips.rotate(stored_index).each do |ip|\n logger.debug \"Searching for free IP - pinging #{ip}\"\n if tcp_pingable?(ip) or icmp_pingable?(ip)\n logger.info \"Found a pingable IP(#{ip}) address which does not have a Proxy::DHCP record\"\n else\n logger.debug \"Found free IP #{ip} out of a total of #{free_ips.size} free IPs\"\n @index = free_ips.index(ip)+1\n return ip\n end\n end\n logger.warn \"No free IPs at #{to_s}\"\n rescue Exception => e\n logger.debug e.message\n ensure\n # ensure we unlock the storage file\n set_index_and_unlock @index\n end\n nil\n end\n end",
"def on_getaddr\n #addrs = @node.addrs.select{|a| a.time > Time.now.to_i - 10800 }.shuffle[0..250]\n #p \"<< addr (#{addrs.size})\"\n #send_data P::Addr.pkt(*addrs)\n end",
"def local_ip_2_host (ip)\n\t\tputs \"Reverse DNS lookup from the local host repository\" if @verbose\n\t\tip=ip.strip unless ip.nil?\n\t\tif @known_hosts.key?(ip)\n\t\t\treturn @known_hosts[ip]\n\t\telse\n\t\t\treturn nil\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\treturn nil\n\tend",
"def extract_ip(addrinfo)\n addrinfo[2]\n end",
"def ip_list\n super\n end",
"def ip\n @actions << :ip\n self.class.mocked_ip\n end",
"def ip; get_data_in_file :ip end",
"def getIp()\n return @ip\n\tend",
"def op\n sequence[ip]\n end",
"def GetIpFromId(id)\n \"192.168.0.#{id+1}\"\n end",
"def primary_institution_from_ip\n Institutions.with_ip(request.remote_ip).first unless request.nil?\n end",
"def get(ip)\n return @cache[ip] if @cache.key?(ip)\n url = format(URL_FORMAT, ip)\n response = Curl.get(url).body_str\n ipapi = SimpleGeolocator::IPAPIResponse.new(Oj.load(response))\n @cache[ip] = ipapi\n end",
"def ip\n super\n end",
"def add_forward_lookup(_ip, _hostname)\n end",
"def ip\n @data[\"ip\"]\n end",
"def associate_address(instance_id)\n new_ip = next_unused_elastic_ip\n vputs(\"Assigning #{new_ip} to the ec2 instance #{instance_id}\")\n ec2.associate_address(instance_id, new_ip)\n loop do\n if describe_instance(:instance_id => instance_id).public_ip == new_ip\n return new_ip\n end\n sleep 1\n end\n end",
"def peerip=(_arg0); end",
"def ip_address(env)\n ip_address_record(env)[:address]\n end",
"def GetIpFromId(id)\n #puts \"Error. GetIpFromId not defined\"\n #exit 1\n return @rstack.GetIpFromId(id)\n end",
"def ipn_endpoint=(_arg0); end",
"def current_ip(inter)\n net_info = `ifconfig`\n section_index = net_info.index(inter)\n line_index = net_info.index('inet', section_index)\n ip_address = net_info[line_index..-1].match(/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/)[0]\n return ip_address\nend",
"def get_iplist()\n puts 'Updating iplist'\n \n sock = TCPSocket.open($leader_ip, $port)\n sock.write(\"get_iplist\")\n @iplist = (sock.read).split(' ')\n sock.close\n end",
"def public_ip() ; info[:public_ip] ; end",
"def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end",
"def local_ip\n\nend",
"def ip_to_node ip\n #Get the lines from nta where node is with that IP\n node_ip_lines = $nodes_to_addrs.select{ |line| line =~ /#{ip}/ }\n\n if (node_ip_lines[0] == nil)\n puts \"ERROR: Could not find the IP = #{ip} in the nodes_to_addrs.txt file\"\n return nil\n end\n\n #Remove the IP and whitespace from string\n node_ip_lines[0].split[0...1].join(' ')\nend",
"def check_ip; end",
"def next_ip(options=nil)\n known_args = [:Bitstep, :Objectify, :Short]\n bitstep = 1\n objectify = false\n short = false\n\n if (options)\n if (!options.kind_of?(Hash))\n raise ArgumentError, \"Expected Hash, but \" +\n \"#{options.class} provided.\"\n end\n NetAddr.validate_args(options.keys,known_args)\n\n if( options.has_key?(:Bitstep) )\n bitstep = options[:Bitstep]\n end\n\n if( options.has_key?(:Short) && options[:Short] == true )\n short = true\n end\n\n if( options.has_key?(:Objectify) && options[:Objectify] == true )\n objectify = true\n end\n end\n\n next_ip = @network + @hostmask + bitstep\n\n if (next_ip > @all_f)\n raise BoundaryError, \"Returned IP is out of bounds for IPv#{@version}.\"\n end\n\n\n if (!objectify)\n next_ip = NetAddr.ip_int_to_str(next_ip, @version)\n next_ip = NetAddr.shorten(next_ip) if (short && @version == 6)\n else\n next_ip = NetAddr.cidr_build(@version,next_ip)\n end\n\n return(next_ip)\n end",
"def member_get_ip(pool_member)\n server_ip = begin\n if pool_member.attribute?('cloud')\n if node.attribute?('cloud') && (pool_member['cloud']['provider'] == node['cloud']['provider'])\n pool_member['cloud']['local_ipv4']\n else\n pool_member['cloud']['public_ipv4']\n end\n else\n pool_member['ipaddress']\n end\n end\n server_ip\nend",
"def ip(value)\n merge(bkip: value.to_s)\n end",
"def get_all(ip)\n\t\tself.v4 = ip.length == 4 && self.ip_version == 4\n\t\tipnum = ip.unpack(\"N\")[0] + 0\n\t\tmid = self.count/2\n\t\tcol_length = columns * 4\n\t\tlow = 0\n\t\thigh = count\n\t\treturn self.record = bsearch(low, high, ipnum, self.base_addr, col_length)\n\tend",
"def search(ip)\n ip_value = self.class.ip_to_int(ip)\n find_rec(ip_value)\n end",
"def set_ip_name\n @ip_name = IpName.find(params[:id])\n end",
"def read_host_ip\n ip = read_machine_ip\n base_ip = ip.split(\".\")\n base_ip[3] = \"1\"\n base_ip.join(\".\")\n end",
"def first_line\n line_from_ip(0)\n end",
"def getControlIP(x, y, domain = \"grid\") \n qs = <<CONTROL_QS\nSELECT nodes.control_ip\n FROM nodes \n LEFT JOIN locations ON nodes.location_id = locations.id \n LEFT JOIN testbeds ON locations.testbed_id = testbeds.id\nWHERE testbeds.node_domain='#{domain}' \n AND locations.x=#{x} \n AND locations.y=#{y};\nCONTROL_QS\n\n addr = nil\n runQuery(qs) { |ip|\n addr = ip\n }\n return addr\n end",
"def save_ip_addr\n self.ip_address = IPAddr.new(self.ip_address).to_i.to_s(16).rjust(8, \"0\")\n end",
"def ip\n self.IP\n end",
"def lookup(ip)\n uri = Addressable::URI.parse(\"https://ip-api.com/xml/#{ip}\")\n res = Net::HTTP.get_response(uri.normalize)\n MetaData.parse(res.body, single: true).freeze\n end",
"def remote_ip; end",
"def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end",
"def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end",
"def conn_ip(n_s, n_d)\n nodes_to_addrs2 = File.readlines(ARGV[0])\n #puts \"\\nn_s = \" + n_s + \" n_d = \" + n_d\n \n n_s_ip_lines = nodes_to_addrs2.select{ |line| line =~ /#{n_s}\\s/ }\n #puts \"\\nPRINT N_S LINES\"\n #puts n_s_ip_lines\n\n\n n_s_ip = []\n n_s_ip_lines.each {|line|\n n_s_ip.push line.split[1..2].join('\\t')\n }\n\n #puts \"\\nPRINTING N_S IPs\"\n #puts n_s_ip\n \n\n n_d_ip_lines = nodes_to_addrs2.select { |line| line =~ /#{n_d}\\s/ }\n #puts \"\\nPRINTING N_D LINES\"\n #puts n_d_ip_lines\n\n\n n_d_ip = []\n n_d_ip_lines.each {|line|\n n_d_ip.push line.split[1..2].join('\\t')\n }\n #puts \"\\nPRINTING N_D IPs\"\n #puts n_d_ip\n\n n_s_ip.each{ |s_ip| \n n_d_ip.each{ |d_ip|\n if ((destination_of_addr s_ip) == d_ip)\n #puts \"CONNECTION WITH \" + d_ip\n return d_ip\n end\n }\n }\nend",
"def query_ip\n @attributes[:query_ip]\n end",
"def regist_ip\n puts 'Registering IP address of this node'\n\n sock = TCPSocket.open($leader_ip)\n sock.write(\"regist\")\n ret_ip = sock.gets\n sock.close\n return ret_ip\n end",
"def set_first_rip\n @first_rip = FirstRip.find(params[:id])\n end",
"def get_ip\n session_gc\n session_create\n\n ip = @sessions.keys[Kernel.rand(@sessions.length)]\n @sessions[ip] += 1\n return ip\n end",
"def get_server_ip(boxes, hostname='')\n default_server_ip = nil\n boxes.each_with_index do |box, i|\n if not box['role'].nil? and box['role'] == 'server'\n ip = box['ip'] ? box['ip'] : \"#{$ip_prefix}.#{i+1}#{i+1}\"\n default_server_ip = ip if default_server_ip.nil?\n if hostname == \"#{box['name']}-%02d\" % i\n return ip\n end\n end\n end\n return default_server_ip\nend",
"def public_ip_of(server)\n server[:cloud][:public_ips].first rescue server[:ipaddress]\n end",
"def index\n @ipinfo=`echo 'aa'>/root/a/b.txt`\n @ls = L.all.order('id desc')\n end",
"def start_ip\n\t\taddr = read_attribute(:start_ip)\n\t\tIP.new([(read_attribute(:ip_v4))?\"v4\":\"v6\",addr]).to_s\n\tend",
"def full_host_record(ip:)\n load_cnames\n \n @forward_host_record ||= {} # Global, as we want to do name lookups.\n return_record = []\n unless( (host_records = @infoblox.get_host_by_ip(ip_address: ip)).nil? )\n host_records.each do |hosts|\n hosts.each do |hn|\n # Assign an empty record, if we haven't seen this host before\n @forward_host_record[hn] ||= { hostname: hn, ip: '', aliases: [], cnames: [] }\n \n # Record the IP. There may be multiple IPs with one hostname.\n @forward_host_record[hn][:ip] = ip\n \n # The hostname might have CNAMES point to it\n unless @reverse_cnames[hn].nil?\n @reverse_cnames[hn].each do |cn| \n @forward_host_record[hn][:cnames] << cn \n end\n end\n \n # The hostname may have alternate hostname A records, stored in IPAM as ALIASES\n @infoblox.get_alias(hostname: hn) do |a| \n short_alias = a.split('.',2)[0]\n @forward_host_record[hn][:aliases] << short_alias\n \n # The ALIASes might have CNAME records pointing to it\n unless @reverse_cnames[a].nil?\n # Record the ALIAS CNAMES against the parent hostname.\n @reverse_cnames[a].each do |cn| \n @forward_host_record[hn][:cnames] << cn \n end\n end\n end\n return_record << @forward_host_record[hn]\n \n # Add forward lookup entries for each ALIAS\n host_domain = hn.split('.',2)[1]\n @forward_host_record[hn][:aliases].each do |a|\n @forward_host_record[\"#{a}.#{host_domain}\"] = @forward_host_record[hn]\n end\n \n # Add forward lookup entries for each CNAME\n @forward_host_record[hn][:cnames].each do |cn|\n @forward_host_record[cn] = @forward_host_record[hn]\n end\n \n end\n end\n end\n return return_record\nend"
] |
[
"0.66371566",
"0.6596373",
"0.61871666",
"0.6172259",
"0.616404",
"0.6148115",
"0.6028361",
"0.6011428",
"0.59186774",
"0.5909313",
"0.58690965",
"0.58351237",
"0.5819356",
"0.58111376",
"0.5806595",
"0.57783914",
"0.57451355",
"0.57383895",
"0.57373255",
"0.571526",
"0.5698145",
"0.56908005",
"0.56896096",
"0.56896096",
"0.56676596",
"0.5667315",
"0.5646082",
"0.56412995",
"0.5634498",
"0.5613752",
"0.5613752",
"0.5613752",
"0.5613752",
"0.5613752",
"0.5613752",
"0.55969566",
"0.55909836",
"0.55902714",
"0.55902714",
"0.55901355",
"0.55857766",
"0.5551435",
"0.5542358",
"0.5539551",
"0.55133164",
"0.5508994",
"0.5501305",
"0.5499805",
"0.54950345",
"0.54892737",
"0.5487808",
"0.54626805",
"0.5452938",
"0.54421395",
"0.5439432",
"0.54392344",
"0.543576",
"0.5429341",
"0.5424964",
"0.54235756",
"0.54210186",
"0.54084104",
"0.5399288",
"0.53925014",
"0.53899044",
"0.53872246",
"0.53838766",
"0.5377364",
"0.5370628",
"0.5368434",
"0.5362882",
"0.5358398",
"0.5357809",
"0.5355539",
"0.5354679",
"0.5344749",
"0.5339927",
"0.5339213",
"0.5336832",
"0.53331447",
"0.5329824",
"0.53166676",
"0.53166276",
"0.5313811",
"0.53063",
"0.53047556",
"0.5298198",
"0.529702",
"0.5293311",
"0.5293311",
"0.5290134",
"0.5278719",
"0.5278194",
"0.5278156",
"0.5277654",
"0.5273749",
"0.5268547",
"0.526747",
"0.5267083",
"0.5266698"
] |
0.6818389
|
0
|
Public Methods callseq: Kconv.kconv(str, out_code, in_code = Kconv::AUTO) Convert str to out_code. out_code and in_code are given as constants of Kconv. Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want to decode them, use NKF.nkf.
|
def kconv(str, out_code, in_code = AUTO)
opt = '-'
case in_code
when ::NKF::JIS
opt << 'J'
when ::NKF::EUC
opt << 'E'
when ::NKF::SJIS
opt << 'S'
when ::NKF::UTF8
opt << 'W'
when ::NKF::UTF16
opt << 'W16'
end
case out_code
when ::NKF::JIS
opt << 'j'
when ::NKF::EUC
opt << 'e'
when ::NKF::SJIS
opt << 's'
when ::NKF::UTF8
opt << 'w'
when ::NKF::UTF16
opt << 'w16'
when ::NKF::NOCONV
return str
end
opt = '' if opt == '-'
::NKF::nkf(opt, str)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def toutf8; Kconv.toutf8(self) end",
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def unify_voiced_katakana!(src)\n halfwidth =\n Characters::HALFWIDTH_VOICED_KATAKANA +\n Characters::HALFWIDTH_SEMI_VOICED_KATAKANA\n fullwidth =\n Characters::VOICED_KATAKANA +\n Characters::SEMI_VOICED_KATAKANA\n halfwidth.zip(fullwidth).inject(src) do |str, (h, f)|\n str.gsub!(h, f) || str\n end\n end",
"def kcode() end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def iconv() end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def text_conv(outform, inform, intext)\n\treturn Iconv.iconv(outform, inform, intext).join\nend",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def toeuc(str)\n ::NKF::nkf('-em', str)\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def tojis; Kconv.tojis(self) end",
"def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def decode_word(text)\n return text unless text =~ /=\\?([^?]+)\\?(.)\\?([^?]*)\\?=/\n \n charset, method, encoded_string = $1, $2, $3\n \n # Strip out the RFC2231 language specification if there is one.\n charset = $1 if charset =~ /^([^\\*]+)\\*?(.*)$/\n \n # Quoted-printable in RFC2047 substitutes spaces with underscores.\n encoded_string.tr!('_', ' ') if method.downcase == 'q'\n \n encoded_string.decode_mime(method).iconv('utf-8', charset)\n end",
"def toutf16; Kconv.toutf16(self) end",
"def encode(to_encoding, from_encoding)\n\t\t\t\tif from_encoding == nil\n\t\t\t\t\tif @encoding == nil\n\t\t\t\t\t\tf_encoding = Kconv::AUTO\n\t\t\t\t\telse\n\t\t\t\t\t\tf_encoding = @encoding\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tf_encoding = get_kconv_encoding(from_encoding)\n\t\t\t\tend\n\n\t\t\t\tresult = Kconv::kconv(self, get_kconv_encoding(to_encoding), f_encoding)\n\t\t\t\t#result.set_encoding(to_encoding)\n\t\t\t\treturn result\n\t\t\tend",
"def convert_text!(text, error_handler)\n text = AnselToUnicode.new(error_handler, true).convert(text) if convert_marc8_to_utf8?\n\n # Turn Horizon's weird escaping into UTF8: <U+nnnn> where nnnn is a hex unicode\n # codepoint, turn it UTF8 for that codepoint\n if settings[\"horizon.destination_encoding\"] == \"UTF8\" &&\n (settings[\"horizon.codepoint_translate\"].to_s == \"true\" ||\n settings[\"horizon.character_reference_translate\"].to_s == \"true\")\n\n regexp = if settings[\"horizon.codepoint_translate\"].to_s == \"true\" && settings[\"horizon.character_reference_translate\"].to_s == \"true\"\n # unicode codepoint in either HTML char reference form OR\n # weird horizon form. \n /(?:\\<U\\+|&#x)([0-9A-Fa-f]{4})(?:\\>|;)/\n elsif settings[\"horizon.codepoint_translate\"].to_s == \"true\"\n # just weird horizon form\n /\\<U\\+([0-9A-Fa-f]{4})\\>/\n else # just character references\n /&#x([0-9A-Fa-f]{4});/\n end\n \n text.gsub!(regexp) do\n [$1.hex].pack(\"U\")\n end\n end\n\n # eliminate illegal control chars. All ASCII less than 0x20\n # _except_ for four legal ones (including MARC delimiters). \n # http://www.loc.gov/marc/specifications/specchargeneral.html#controlfunction\n # this is all bytes from 0x00 to 0x19 except for the allowed 1B, 1D, 1E, 1F. \n text.gsub!(/[\\x00-\\x1A\\x1C]/, '')\n\n return text\n end",
"def reencode_string(input); end",
"def kana2kana(str1)\n result = []\n str2 = Kana2rom::hira_to_kata(str1)\n str3 = Kana2rom::kata_to_hira(str1)\n result << str1\n result << str2 if str2.length > 0 and str1 !=str2\n result << str3 if str3.length > 0 and str2 !=str3 and str3 != str1\n return result\n end",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def toeuc; Kconv.toeuc(self) end",
"def convert(str)\n\t\t@result=convert_han(convert_words(str))\n\t\t# @result=convert_words(str)\n\t\t@result.gsub!(\" #%\",\"\")\n\t\t@result.gsub!(\"%# \",\"\")\n\t\t@result\n\tend",
"def translate_codepoints(str)\n str.gsub(/#x\\h+/) {|c| c[2..-1].scanf(\"%x\").first.chr(Encoding::UTF_8)}\n end",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def convert_string string\n return string unless @in_b or @in_em\n chars = if @in_b then\n string.chars.map do |char| \"#{char}\\b#{char}\" end\n elsif @in_em then\n string.chars.map do |char| \"_\\b#{char}\" end\n end\n\n chars.join\n end",
"def swapCJK(code_point)\n if code_point >= CJK_BASE\n return code_point - CJK_BASE if code_point < CJK_LIMIT\n return code_point + NON_CJK_OFFSET if code_point < CJK_COMPAT_USED_BASE\n return code_point - CJK_COMPAT_USED_BASE + (CJK_LIMIT - CJK_BASE) if code_point < CJK_COMPAT_USED_LIMIT\n return code_point + NON_CJK_OFFSET if code_point < CJK_B_BASE\n return code_point if code_point < CJK_B_LIMIT # non-BMP-CJK\n return code_point + NON_CJK_OFFSET if code_point < CJK_C_BASE\n return code_point if code_point < CJK_C_LIMIT # non-BMP-CJK\n return code_point + NON_CJK_OFFSET if code_point < CJK_D_BASE\n return code_point if code_point < CJK_D_LIMIT # non-BMP-CJK\n\n return code_point + NON_CJK_OFFSET # non-CJK\n end\n\n return code_point + NON_CJK_OFFSET if code_point < CJK_A_BASE\n return code_point - CJK_A_BASE + (CJK_LIMIT - CJK_BASE) + (CJK_COMPAT_USED_LIMIT - CJK_COMPAT_USED_BASE) if code_point < CJK_A_LIMIT\n\n code_point + NON_CJK_OFFSET # non-CJK\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def special2csa(str)\n {\n '中断' => 'CHUDAN',\n '投了' => 'TORYO',\n '持将棋' => 'JISHOGI',\n '千日手' => 'SENNICHITE',\n '詰み' => 'TSUMI',\n '不詰' => 'FUZUMI',\n '切れ負け' => 'TIME_UP',\n '反則勝ち' => 'ILLEGAL_ACTION', # 直前の手が反則(先頭に+か-で反則した側の情報を含める必要が有る)\n '反則負け' => 'ILLEGAL_MOVE' # ここで手番側が反則,反則の内容はコメントで表現\n }[str] || (raise ParseError)\n end",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def kern(string)\n kerned = [[]]\n last_byte = nil\n\n string.each_byte do |byte|\n k = last_byte && @kern_pair_table[[last_byte, byte]]\n if k\n kerned << -k << [byte]\n else\n kerned.last << byte\n end\n last_byte = byte\n end\n\n kerned.map do |e|\n e = e.is_a?(Array) ? e.pack('C*') : e\n if e.respond_to?(:force_encoding)\n e.force_encoding(::Encoding::Windows_1252)\n else\n e\n end\n end\n end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def encode(text)\n # FIXME: embed RTL text convertion\n return format_string_to_pdf(text) unless cmap\n coded_array = text.chars.map do |c|\n if cmap[c]\n cmap[c]\n else\n warn \"CombinePDF ERROR: couldn't encode string - characters not supported by the chosen font.\"\n ''\n end\n end\n coded_array.unshift '<'\n coded_array.push '>'\n coded_array.join\n end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def kan2n2(s)\n case s.length\n when 1\n '〇一二三四五六七八九十'.index(s)\n when 2\n '〇一二三四五六七八九十'.index(s[1]) + 10\n else\n raise '21以上の数値に対応していません'\n end\n end",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def width(str, cjk = false)\n raise NotImplementedError\n end",
"def codepoint\n unless $KCODE =~ /^u/i\n raise ArgumentError, \"unsupported encoding (#{$KCODE})\"\n end\n unless jlength == 1\n raise RangeError, \"string must be exactly one character long\"\n end\n \n\t case self.length\n \twhen 1\n \t UCSCodepoint.new(self[0])\n \twhen 2\n \t UCSCodepoint.new(\n \t ((self[0] & 0x1f) << 6) +\n \t (self[1] & 0x3f)\n \t )\n \twhen 3\n \t UCSCodepoint.new(\n \t ((self[0] & 0x0f) << 12) +\n \t ((self[1] & 0x3f) << 6) +\n \t (self[2] & 0x3f)\n \t )\n \twhen 4\n \t UCSCodepoint.new(\n \t ((self[0] & 0x07) << 18) +\n \t ((self[1] & 0x3f) << 12) +\n \t ((self[2] & 0x3f) << 6) +\n \t (self[3] & 0x3f)\n \t )\n \tend\n end",
"def to_kilogram(**options) = convert_to('kilogram', **options)",
"def canonize str\n\n case support(\"CASEMAPPING\", \"rfc1459\").downcase\n\n when \"ascii\"\n str.upcase\n\n when \"rfc1459\", nil\n str.upcase.tr(\"|{}^\", \"\\\\\\\\[]~\")\n\n when \"strict-rfc1459\"\n str.upcase.tr(\"|{}\", \"\\\\\\\\[]\")\n\n else\n str.upcase.tr(\"|{}^\", \"\\\\\\\\[]~\")\n\n end\n\n end",
"def encode(input_string)\n return input_string.tr(\"a-z\", \"n-za-m\")\nend",
"def nfc\n @input = @input.unicode_normalize(:nfc)\n end",
"def decode(text); end",
"def quote_zenkaku(str)\n if str.mbchar? >= 0\n \"「\" + str + \"」\"\n else\n \"'\" + str + \"'\"\n end\n end",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def kern(text)\n text.gsub(/(T)(o)|(W)(a)/, '<span class=\"kern\">\\1\\3</span>\\2\\4').html_safe\n end",
"def tosjis; Kconv.tosjis(self) end",
"def decoder(string)\n string.gsub(/(WUB)+/, ' ').strip\nend",
"def codepoint(str)\n return str.gsub(/\\\\u[\\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }\n end",
"def simple_encode(input, key_map)\n \n # NEVER trust input to be valid. Always double check it.\n if !input\n return nil\n end\n \n if !key_map\n return input\n end\n \n encoded_string = ''\n \n input.chars.each do |character|\n if key_map[character]\n encoded_string += key_map[character]\n else\n encoded_string += character\n end\n end\n \n encoded_string\nend",
"def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend",
"def return_in_latin(input)\n input.tr('αβεηικμνορτχυζ'.upcase, 'abehikmnoptxyz'.upcase) \n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def north_korean_cipher(coded_message)\n\tinput = coded_message.downcase.split(\"\") # Check out this method in IRB to see how it works! Also refer to the ruby docs.\n\tdecoded_sentence = []\n\tcipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n\t\t\t\t\t\t\"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n\t\t\t\t\t\t\"g\" => \"c\", \n\t\t\t\t\t\t\"h\" => \"d\", \n\t\t\t\t\t\t\"i\" => \"e\", \n\t\t\t\t\t\t\"j\" => \"f\",\n\t\t\t\t\t\t\"k\" => \"g\",\n\t\t\t\t\t\t\"l\" => \"h\",\n\t\t\t\t\t\t\"m\" => \"i\",\n\t\t\t\t\t\t\"n\" => \"j\",\n\t\t\t\t\t\t\"o\" => \"k\",\n\t\t\t\t\t\t\"p\" => \"l\",\n\t\t\t\t\t\t\"q\" => \"m\",\n\t\t\t\t\t\t\"r\" => \"n\",\n\t\t\t\t\t\t\"s\" => \"o\",\n\t\t\t\t\t\t\"t\" => \"p\",\n\t\t\t\t\t\t\"u\" => \"q\",\n\t\t\t\t\t\t\"v\" => \"r\",\n\t\t\t\t\t\t\"w\" => \"s\",\n\t\t\t\t\t\t\"x\" => \"t\",\n\t\t\t\t\t\t\"y\" => \"u\",\n\t\t\t\t\t\t\"z\" => \"v\",\n\t\t\t\t\t\t\"a\" => \"w\",\n\t\t\t\t\t\t\"b\" => \"x\",\n\t\t\t\t\t\t\"c\" => \"y\",\n\t\t\t\t\t\t\"d\" => \"z\"}\n\t\n# This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n# the best data structure for this problem? What are the pros and cons of hashes?\n# \n# We automated this task with our own method that shifts letters automatically. It even allows you to\n# specify the amount the letters need to be shifted. This will output our needed hash, without having to\n# manually write every key/value pair.\n\n\tinput.each do |x| # iterate through each letter in the coded message (input is an array of all letters in order)\n\t\tfound_match = false # If found_match is set to true, the block code \"if not found_match\" will NEVER be executed\n\t\t\t\t\t\t\t\t\t\t\t\t # so the unmapped letter will not be added back to the decoded message\n\t\tcipher.each_key do |y| # iterate through each key in the hash table\n\t\t\tif x == y # compare the current letter in the coded message to the key in the hash table. If they are equals,\n\t\t\t\t\t\t\t\t # meaning the decoded letter is found, add the mapped value to the decoded message\n\t\t\t\tputs \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n\t\t\t\tdecoded_sentence << cipher[y]\n\t\t\t\tfound_match = true\n\t\t\t\tbreak # Once the decoded letter is found, break out of the loop and go for the next letter in the input message\n\t\t\telsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" # If any of these symbols is\n\t\t\t\t# found in the coded message, it is equivalent to a space. These are all OR statements, so if any are found to\n\t\t\t\t# be true, it will run the block of code.\n\t\t\t\tdecoded_sentence << \" \"\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\telsif (0..9).to_a.include?(x) # This puts all the numbers from 0 to 9 into an array and check if that array contains x\n\t\t\t\tdecoded_sentence << x\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\tend \n\t\tend\n\t\tif not found_match # If some character not covered by any of the if statments is found in the coded message\n\t\t# that character is put into the decoded message\n\t\t\tdecoded_sentence << x\n\t\tend\n\tend\n\tdecoded_sentence = decoded_sentence.join(\"\")\n \n\tif decoded_sentence.match(/\\d+/) #Checks the decoded message for any numbers \n\t\tdecoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } # Replaces those numbers with a number divided by 100, because\n\t\t# he has been known to exaggerate about the amount of stuff he has\n\tend \n\treturn decoded_sentence # return the decoded message \nend",
"def convert (str)\r\n# REFERENCE : Using logic from this source https://stackoverflow.com/questions/13498688/pig-latin-method-translation\r\n alpha = ('a'..'z').to_a\r\n vowels = %w[a e i o u]\r\n consonants = alpha - vowels\r\n lstr = str.downcase\r\n if vowels.include?(lstr[0])\r\n str + 'way'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1]) && consonants.include?(lstr[2])\r\n str[3..-1] + str[0..2] + 'ay'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1])\r\n str[2..-1] + str[0..1] + 'ay'\r\n elsif consonants.include?(lstr[0])\r\n str[1..-1] + str[0] + 'ay'\r\n else\r\n str # return unchanged\r\n end\r\nend",
"def convert(string)\n\t# Adding space to handle words that end in a unicode character\n\tstring += \" \"\n\n\tword = \"\"\n\tunicode = false\n\tuni_string = \"\"\n\n\t# puts \"Starting each char...\"\n\tstring.each_char do |char|\n\t\t\n\t\t# puts \"char: #{char}\"\n\n\t\tif char != \"\\\\\" and !unicode\n\t\t\t# puts \"Adding #{char} to word\"\n\t\t\tword += convert_char(char)\n\n\t\telsif char == \"\\\\\"\n\t\t\t# puts \"Starting unicode string\"\n\t\t\tuni_string = \"\\\\\"\n\t\t\tunicode = true\n\n\t\telsif char != \" \" and unicode\n\t\t\t# puts \"Putting #{char} in unicode string: #{uni_string}\"\n\t\t\tuni_string += char\n\n\t\telsif unicode and char == \" \"\n\t\t\t# puts \"Found end of unicode string: #{uni_string}\"\n\t\t\tword += convert_char(uni_string)\n\t\t\tuni_string = \"\"\n\t\t\tunicode = false\n\t\telse\n\t\t\tputs \"Not sure what to do with #{char}\"\n\t\tend\n\tend\n\n\t# Strip to remove extra spaces\n\treturn word.strip\n\nend",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def widen_char(c)\n c += 65248 if c.between? 33, 126 # character w/ fullwidth equivalent\n c.chr Encoding::UTF_8\nend",
"def decode_char(input)\n # check first *char*\n input.mark\n first = input.next\n if first.nil?\n input.reset\n return nil\n end\n # if it isnt an encoded string return nil\n unless first == \"\\'\"\n input.reset\n return nil\n end\n # if second isnt an encoded marker return nil\n second = input.next\n unless second == \"\\'\"\n input.reset\n return nil\n end\n return \"\\'\"\n end",
"def morse_encode(str)\n hash={}\n \n hash[\"a\"]=\"._ \"\n hash[\"b\"]=\"_... \"\n hash[\"c\"]=\"_._. \"\n hash[\"d\"]=\"_.. \"\n hash[\"e\"]=\". \"\n hash[\"f\"]=\".._. \"\n hash[\"g\"]=\"__. \"\n hash[\"h\"]=\".... \"\n hash[\"i\"]=\".. \"\n hash[\"j\"]=\".___ \"\n hash[\"k\"]=\"_._ \"\n hash[\"l\"]=\"._.. \"\n hash[\"m\"]=\"__ \"\n hash[\"n\"]=\"_. \"\n hash[\"o\"]=\"___ \"\n hash[\"p\"]=\".__. \"\n hash[\"q\"]=\"__._ \"\n hash[\"r\"]=\"._. \"\n hash[\"s\"]=\"... \"\n hash[\"t\"]=\"_ \"\n hash[\"u\"]=\".._ \"\n hash[\"v\"]=\"..._ \"\n hash[\"w\"]=\".__ \"\n hash[\"x\"]=\"_.._ \"\n hash[\"y\"]=\"_.__ \"\n hash[\"z\"]=\"__.. \"\n \n hash[\" \"]=\" \"\n \n hash[\"A\"]=\"._ \"\n hash[\"B\"]=\"_... \"\n hash[\"C\"]=\"_._. \"\n hash[\"D\"]=\"_.. \"\n hash[\"E\"]=\". \"\n hash[\"F\"]=\".._. \"\n hash[\"G\"]=\"__. \"\n hash[\"H\"]=\".... \"\n hash[\"I\"]=\".. \"\n hash[\"J\"]=\".___ \"\n hash[\"K\"]=\"_._ \"\n hash[\"L\"]=\"._.. \"\n hash[\"M\"]=\"__ \"\n hash[\"N\"]=\"_. \"\n hash[\"O\"]=\"___ \"\n hash[\"P\"]=\".__. \"\n hash[\"Q\"]=\"__._ \"\n hash[\"R\"]=\"._. \"\n hash[\"S\"]=\"... \"\n hash[\"T\"]=\"_ \"\n hash[\"U\"]=\".._ \"\n hash[\"V\"]=\"..._ \"\n hash[\"W\"]=\".__ \"\n hash[\"X\"]=\"_.._ \"\n hash[\"Y\"]=\"_.__ \"\n hash[\"Z\"]=\"__.. \"\n \n output=\"\"\n f=0\n while f<str.length\n output+=hash[str[f]]\n f+=1\n end\n \n \n return output\n \n \nend",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def encode_char(immune, input)\n input\n end",
"def encode(str)\n\tswap_raw = \"GA-DE-RY-PO-LU-KI\".reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.split(\"-\")\n\tencoder = Hash.new\n\tswap_raw.each { |pair| encoder[pair[0]] = pair[1] }\n\tencoded_string = \"\"\n\tputs encoder\n\tfor char in str.split(\"\")\n\t\tif encoder.key?(char) #correct?\n\t\t\tencoded_string += encoder[char]\n\t\telse\n\t\t\tencoded_string += char\n\t\tend\n\tend\n\treturn encoded_string\nend",
"def ansi_to_bbcode(string); end",
"def decode_string(str)\n\nend",
"def encode_text(text, options = {})\n [[0, options[:kerning] ? kern(text) : text]]\n end",
"def convert(string)\n pp request.mode\n # RFC1350: any combination of upper\n # and lower case, such as \"NETASCII\", NetAscii\", etc.\n return string unless request.mode.casecmp(\"netascii\").eql?(0)\n string.gsub(/\\r\\n/,\"\\n\")\n end",
"def mb_charify(text)\n if RUBY_VERSION >= '1.9'\n text.dup\n elsif text.respond_to?(:mb_chars)\n text.frozen? ? text.dup.mb_chars : text.mb_chars\n else\n raise \"StringUtils: No unicode support for strings\"\n end\n end",
"def monospace(str)\n _raw str.gsub(/`([^`]*)`/, '<code>\\1</code>')\n end",
"def downcode(encoding)\n return self.encode(encoding, :invalid => :replace, :undef => :replace, :replace => '')\n end",
"def decode_char(input)\n\n input.mark\n first = input.next\n if first.nil?\n input.reset\n return nil\n end\n # check to see if we are dealing with an encoded char\n if first!= \"\\\\\"\n input.reset\n return nil\n end\n second = input.next\n if second.nil?\n input.reset\n return nil\n end\n\n #Check octal codes\n return 0x08.chr if second == \"b\"\n return 0x09.chr if second == \"t\"\n return 0x0a.chr if second == \"n\"\n return 0x0b.chr if second == \"v\"\n return 0x0c.chr if second == \"f\"\n return 0x0d.chr if second == \"r\"\n return 0x22.chr if second == \"\\\"\"\n return 0x27.chr if second == \"\\'\"\n return 0x5c.chr if second == \"\\\\\"\n if second.downcase == \"x\" # Hex encoded value\n temp = ''\n for i in 0..1 do\n c = input.next_hex\n temp << c unless c.nil?\n if c.nil?\n input.reset\n return nil\n end\n end\n i = temp.hex\n begin\n return i.chr(Encoding::UTF_8) if i >= START_CODE_POINT and i <= END_CODE_POINT\n rescue Exception => e\n input.reset\n return nil\n end\n elsif second.downcase == \"u\" # Unicode encoded value\n temp = ''\n for i in 0..3 do\n c = input.next_hex\n temp << c unless c.nil?\n if c.nil?\n input.reset\n return nil\n end\n end\n i = temp.hex\n begin\n return i.chr(Encoding::UTF_8) if i >= START_CODE_POINT and i <= END_CODE_POINT\n rescue Exception => e\n input.reset\n return nil\n end\n elsif input.octal?(second) # Octal encoded value\n temp = second\n c = input.next\n unless input.octal?(c)\n input.push(c)\n else\n temp << c\n c = input.next\n unless input.octal?(c)\n input.push(c)\n else\n temp << c\n end\n end\n # build a number\n i = temp.to_i(8)\n begin\n return i.chr(Encoding::UTF_8) if i >= START_CODE_POINT and i <= END_CODE_POINT\n rescue Exception => e\n input.reset\n return nil\n end\n end\n second\n end",
"def preprocess_text(text)\n\n # Warn user if text exceeds max_length.\n if text.length > @max_length\n text = text[0..@max_length]\n warn(\"WARNING:: string cut length > #{@max_length}:\\n\")\n warn('text:: '+text)\n end\n\n text = @encoder.clean(text)\n text = remove_diacritics(text)\n\n # correct expected length for vectors with 0's\n @encoder.input_to_sequence(text)\n end",
"def to_kanji(dd)\n d1, d2 = dd.length == 1 ? ['0', dd[0]-48] : [dd[0]-48, dd[1]-48]\n case d1 when 0 then ''\n when 1 then 'JUU'\n else to_kanji_single(d1.to_i) ;end \\\n + to_kanji_single(d2.to_s)\nend",
"def kana?\n codepoint.kana?\n end",
"def formatted_text\n formatted = chapter_text.gsub(/\\u00a0/, ' ').gsub(/[\\u2018\\u2019]/, '\\'').gsub(/[\\u201c\\u201d]/, '\"').gsub('…','...')\n fix_letter = formatted.gsub('ö', 'o').gsub('
', ' ')\n line_spaced = fix_letter#.gsub(\"\\n\",\"<br>\")\n encoded = line_spaced.encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :replace => \"?\")\n return encoded\n end",
"def preprocess(input)\n input = input.to_s.encode('UTF-8',\n :invalid => :replace,\n :undef => :replace)\n\n input.gsub!(/(?:\\r\\n|[\\r\\f])/, \"\\n\")\n input.gsub!(\"\\u0000\", \"\\ufffd\")\n input\n end",
"def preprocess(input)\n input = input.to_s.encode('UTF-8',\n :invalid => :replace,\n :undef => :replace)\n\n input.gsub!(/(?:\\r\\n|[\\r\\f])/, \"\\n\")\n input.gsub!(\"\\u0000\", \"\\ufffd\")\n input\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def iconv\n @iconv ||= Iconv.new(vk_charset, 'UTF-8')\n end",
"def kind2csa(kind)\n if kind[0] == '成'\n {\n '香' => 'NY',\n '桂' => 'NK',\n '銀' => 'NG'\n }[kind[1]]\n else\n {\n '歩' => 'FU',\n '香' => 'KY',\n '桂' => 'KE',\n '銀' => 'GI',\n '金' => 'KI',\n '角' => 'KA',\n '飛' => 'HI',\n '玉' => 'OU',\n '王' => 'OU',\n 'と' => 'TO',\n '杏' => 'NY',\n '圭' => 'NK',\n '全' => 'NG',\n '馬' => 'UM',\n '竜' => 'RY',\n '龍' => 'RY'\n }[kind]\n end\n end",
"def decode_char(input)\n input\n end",
"def return_in_greek(input)\n input.tr('abehikmnoptxyz'.upcase, 'αβεηικμνορτχυζ'.upcase)\n end",
"def unicode_text(pdf, str, options={})\n pdf.text(e(\"\\xfe\\xff#{str}\", :encoding => 'UTF-16BE'), options) # start Unicode UTF-16BE encoding\n end",
"def convert_encoding(content); end",
"def do_adhoc(str)\n str.gsub!(/^\\\\cleardoublepage$/, \"\")\n str.gsub!(/^\\\\plainifnotempty$/, \"\")\n str.gsub!(/^\\\\small$/, \"\")\n str.gsub!(/^\\\\normalsize$/, \"\")\n str.gsub!(/^\\\\centering$/, \"\")\n\n # URL\n str.gsub!(/\\\\verb\\|(.+?)\\|/) do |m|\n s = $1\n if s =~ URI.regexp\n s\n else\n m\n end\n end\n\n text_pairs = {\n %! \\\\vspace*{-0.1\\\\Cvs}! => \"\",\n %!$10^{12} = 1 \\\\mathrm{TB}$! => %!@<raw>#{LBRACE}|html|10<sup>12</sup>#{RBRACE}=1TB!,\n %!$\\\\exists, \\\\forall$! => %!@<raw>#{LBRACE}|html|∃, ∀#{RBRACE}!,\n %!$\\\\lnot,\\\\land,\\\\lor$! => %!@<raw>#{LBRACE}|html|¬,∧,∨#{RBRACE}!,\n %!$>$! => %!@<raw>#{LBRACE}|html|>#{RBRACE}!,\n %!$<$! => %!@<raw>#{LBRACE}|html|<#{RBRACE}!,\n %!B$^+$! => %!@<raw>#{LBRACE}|html|B<sup>+</sup>#{RBRACE}!,\n %!\\\\paragraph{Step 4.} \\\\ ! => %!\\\\paragraph{Step 4.}!,\n %!\\\\verb|http://s2k-ftp.cs.berkeley.edu/ingres/|! => %!http://s2k-ftp.cs.berkeley.edu/ingres/!,\n %!\\\\verb|pc<code.size()|! => %!@<tt>#{LBRACE}pc<code.size()#{RBRACE}!,\n %!\\\\verb|c|! => %!@<tt>#{LBRACE}c#{RBRACE}!,\n %!\\\\verb|m|! => %!@<tt>#{LBRACE}m#{RBRACE}!,\n %!\\\\verb|z|! => %!@<tt>#{LBRACE}z#{RBRACE}!,\n %!$n$! => %!n!,\n %!$\\\\mathrm{O}(1)$! => %!O(1)!,\n %!$\\\\mathrm{O}(n)$! => %!O(n)!,\n %!$\\\\beta$! => %!@<raw>#{LBRACE}|html|β#{RBRACE}!,\n %!$t$! => %!t!,\n %![$^{11}$C]! => %!@<raw>#{LBRACE}|html|[<sup>11</sup>C]#{RBRACE}!,\n }\n\n text_pairs.each do |k,v|\n regex = Regexp.compile(Regexp.quote(k))\n str.gsub!(regex, v)\n end\n\n str.gsub!(/^\\s*\\\\begin\\{lstlisting\\}\\n((?:.|\\n)*?)\\n\\s*\\\\end\\{lstlisting\\}\\n/) do |m|\n \"//emlist{\\n\" + $1 + \"\\n//}\\n\"\n end\n\n str.gsub!(/^\\s*\\\\begin\\{quote\\}\\n((?:.|\\n)*?)\\n\\s*\\\\end\\{quote\\}\\n/) do |m|\n \"//quote{\\n\" + $1 + \"\\n//}\\n\"\n end\n\n str.gsub!(/^\\s*\\\\(begin|end)\\{(minipage|center|figure)\\}.*$/, \"\")\n\n img_refs = Hash.new\n str.gsub!(/^\\s*\\\\includegraphics(?:\\[.*?\\])?\\{(.+?)\\}[\\s\\n]*\\\\caption\\{(.+?)\\}[\\s\\n]*\\\\label\\{(.+?)\\}/) do |m|\n imgfile = $1.strip\n caps = $2.strip\n label = $3.strip\n if imgfile =~ /\\.eps\\Z/\n imgfile = File.basename(imgfile, \".eps\")\n img_refs[label.strip] = imgfile\n \"\\n//image[#{imgfile}][#{caps}]{\\n//}\\n\"\n elsif imgfile =~ /\\.pdf\\Z/\n imgfile = File.basename(imgfile, \".pdf\")\n img_refs[label.strip] = imgfile\n \"\\n//image[#{imgfile}][#{caps}]{\\n//}\\n\"\n else\n m\n end\n end\n\n str.gsub!(/^\\s*\\\\includegraphics(?:\\[.*?\\])?\\{(.+?)\\}[\\s\\n]*\\\\caption\\{(.+?)\\}/) do |m|\n imgfile = File.basename($1.strip)\n caps = $2.strip\n imgfile.gsub!(/\\.\\w+\\Z/, \"\")\n \"\\n//image[#{imgfile}][#{caps}]{\\n//}\\n\"\n end\n\n str.gsub!(/図\\s*\\\\ref\\{([^\\}]*)\\}/) do |m|\n \"@<img>#{LBRACE}#{img_refs[$1.strip] || $1.strip}#{RBRACE}\"\n end\n\n str.gsub!(/^\\s*\\\\begin\\{enumerate\\}((?:.|\\n)*)\\s*\\\\end\\{enumerate\\}/) do |m|\n block = $1\n idx = 0\n if block =~ /\\\\begin/\n block\n else\n items = block.strip.split(/\\\\item\\s*/).select{|s| s.size > 0}\n items_str = \"\\n\"\n items.each do |item|\n items_str += \" \" + (idx += 1).to_s + \". \" + item.gsub(/\\n\\s*/,\"\").strip + \"\\n\"\n end\n items_str\n end\n end\n\n str.gsub!(/^\\s*\\\\begin\\{itemize\\}((?:.|\\n)*)\\s*\\\\end\\{itemize\\}/) do |m|\n block = $1\n if block =~ /\\\\begin/\n block\n else\n items = block.strip.split(/\\\\item\\s*/).select{|s| s.size > 0}\n items_str = \"\\n\"\n items.each do |item|\n items_str += \" * \" + item.gsub(/\\n\\s*/,\"\").strip + \"\\n\"\n end\n items_str\n end\n end\n\n # brainfuck\n str.gsub!(/\\\\verb\\|([-+><,\\.\\[\\] ]+)\\|/) do |m|\n %!@<tt>#{LBRACE}#{$1}#{RBRACE}!\n end\n\n # file url in hoge.tex\n str.gsub!(/\\{\\\\scriptsize((?:.|\\n)+?)\\}/) do |m|\n s = $~[1].strip\n if s.strip =~ URI.regexp && s == $~[0]\n s\n else\n m\n end\n end\n\n str\nend",
"def decode(input=nil, codes=nil, output=nil)\n\tcodes.default = false # set value that is returned if value is not found in hash\n\ttext = input.read # converts file to String - won't work otherwise for me\n\tc = text[0]\n\ti = 1 # counter for string\n\twhile(i < text.length)\n\t\tuntil(codes[c] != false or i > 100)\n\t\t\tc += text[i]\n\t\t\ti += 1\n\t\tend\n\t\tif(codes[c] != false)\n\t\t\toutput.write(codes[c])\n\t\t\tc = \"\"\n\t\tend\n\t\t# at this point, a match has been found\n\t\t#puts codes[c] == false\n\tend\nend",
"def from_native_charset(s, code, ignore_encoding_error = T.unsafe(nil), log = T.unsafe(nil)); end",
"def escape_string(str)\n replacement = {\n ':)' => \"\\n\", ':>' => \"\\t\", ':o' => \"\\a\", ':\"' => '\"', '::' => ':'\n }\n str\n .gsub(/:[\\)>o\":]/, replacement)\n .gsub(/:\\(([0-9a-fA-F]+)\\)/) do |match|\n $1.to_i(16).chr(Encoding::UTF_8)\n end\n .gsub(/:\\[(.+?)\\]/) do |match|\n code = Unicode::DATA[$1]\n if code\n code.chr(Encoding::UTF_8)\n else\n $stderr.puts(\"Unknown Unicode normative name: #{$1}\")\n match\n end\n end\n end",
"def convertCodeToString(code, codeTable)\n string = \"\"\n code.split(\" \").each do |i|\n string += codeTable.key(i).to_s #This will return the key corresponding to the value split out of the code which represents one character\n end\n return string\nend",
"def kramdown_conversion_method_name\n :to_kramdown_repositext\n end"
] |
[
"0.6672627",
"0.6035137",
"0.60225886",
"0.58952147",
"0.58342874",
"0.583078",
"0.5820545",
"0.5608768",
"0.5592635",
"0.5587364",
"0.5504262",
"0.5501117",
"0.54515433",
"0.54430974",
"0.5441092",
"0.53811884",
"0.5379602",
"0.53480047",
"0.53326887",
"0.53311425",
"0.5326553",
"0.5319701",
"0.53077203",
"0.52681196",
"0.5196003",
"0.51361275",
"0.5120512",
"0.5099878",
"0.50860775",
"0.5075657",
"0.5069649",
"0.5032152",
"0.5007146",
"0.5001168",
"0.49676386",
"0.49442565",
"0.49086103",
"0.4905454",
"0.49032456",
"0.4890508",
"0.48752347",
"0.4866783",
"0.48653987",
"0.48560742",
"0.4834939",
"0.48269182",
"0.48217013",
"0.47895715",
"0.47735864",
"0.47662452",
"0.47567463",
"0.47372508",
"0.47344074",
"0.4730886",
"0.47290063",
"0.4717143",
"0.47150898",
"0.47116375",
"0.47111076",
"0.47006884",
"0.46998304",
"0.46977958",
"0.46906108",
"0.46863613",
"0.4680899",
"0.46755636",
"0.46743587",
"0.46613282",
"0.4658139",
"0.4650396",
"0.46478847",
"0.4644017",
"0.4642806",
"0.46366432",
"0.46269864",
"0.46255255",
"0.4623565",
"0.46084663",
"0.46011972",
"0.4599818",
"0.459483",
"0.45852208",
"0.45831814",
"0.45784548",
"0.4574398",
"0.45738834",
"0.45738834",
"0.45704162",
"0.45667216",
"0.45639917",
"0.45637777",
"0.45620838",
"0.4561245",
"0.45427468",
"0.45224586",
"0.45129848",
"0.45092624",
"0.45085406",
"0.45081186",
"0.45018533"
] |
0.81049734
|
0
|
Encode to callseq: Kconv.tojis(str) > string Convert str to ISO2022JP Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('jxm0', str).
|
def tojis(str)
::NKF::nkf('-jm', str)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tojis; Kconv.tojis(self) end",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def tosjis; Kconv.tosjis(self) end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def reencode_string(input); end",
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def encode(string); end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def toutf8; Kconv.toutf8(self) end",
"def tosjis(str)\n ::NKF::nkf('-sm', str)\n end",
"def encode(str)\n\tswap_raw = \"GA-DE-RY-PO-LU-KI\".reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.split(\"-\")\n\tencoder = Hash.new\n\tswap_raw.each { |pair| encoder[pair[0]] = pair[1] }\n\tencoded_string = \"\"\n\tputs encoder\n\tfor char in str.split(\"\")\n\t\tif encoder.key?(char) #correct?\n\t\t\tencoded_string += encoder[char]\n\t\telse\n\t\t\tencoded_string += char\n\t\tend\n\tend\n\treturn encoded_string\nend",
"def issjis(str)\n RegexpShiftjis.match( str )\n end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def issjis;\tKconv.issjis(self) end",
"def encode_string s\n s.downcase.split(//).inject(\"\") do |code,char|\n code + encode_char(char)\n end\n end",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def encode(str)\n bitstring = str.each_byte.map { |chr| ENCODE_TABLE[chr] }.join\n bitstring << '1' * ((8 - bitstring.size) % 8)\n [bitstring].pack('B*')\n end",
"def encode_string; end",
"def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end",
"def kana2kana(str1)\n result = []\n str2 = Kana2rom::hira_to_kata(str1)\n str3 = Kana2rom::kata_to_hira(str1)\n result << str1\n result << str2 if str2.length > 0 and str1 !=str2\n result << str3 if str3.length > 0 and str2 !=str3 and str3 != str1\n return result\n end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def encode(immune, input)\n return nil if input.nil?\n encoded_string = ''\n encoded_string.encode!(Encoding::UTF_8)\n input.encode(Encoding::UTF_8).chars do |c|\n encoded_string << encode_char(immune,c)\n end\n encoded_string\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def encode_string_ex; end",
"def encode(str, transliterate: false, replace_char: nil, truncate: false)\n return if str.nil?\n\n replace_char = canonicalize_replace_char(replace_char)\n\n processed_str = str.unpack('U*').map do |char|\n utf8_char = char.chr(Encoding::UTF_8)\n\n compatible_char = compatible_char_for(char)\n transformed_char = transformed_char_for(char) if transliterate\n gsm_char_for(compatible_char || transformed_char || utf8_char, replace_char)\n end.join\n\n truncate ? truncate_into_single_segment(processed_str) : processed_str\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def unicode_filter_encode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_encode(str) : str\n end",
"def encode(text); end",
"def encode(text); end",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def encode(string)\n string.unpack('B*')[0].tr('01', \" \\n\")\n end",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def simple_encode(input, key_map)\n \n # NEVER trust input to be valid. Always double check it.\n if !input\n return nil\n end\n \n if !key_map\n return input\n end\n \n encoded_string = ''\n \n input.chars.each do |character|\n if key_map[character]\n encoded_string += key_map[character]\n else\n encoded_string += character\n end\n end\n \n encoded_string\nend",
"def encode(text)\n # FIXME: embed RTL text convertion\n return format_string_to_pdf(text) unless cmap\n coded_array = text.chars.map do |c|\n if cmap[c]\n cmap[c]\n else\n warn \"CombinePDF ERROR: couldn't encode string - characters not supported by the chosen font.\"\n ''\n end\n end\n coded_array.unshift '<'\n coded_array.push '>'\n coded_array.join\n end",
"def to_kanji(dd)\n d1, d2 = dd.length == 1 ? ['0', dd[0]-48] : [dd[0]-48, dd[1]-48]\n case d1 when 0 then ''\n when 1 then 'JUU'\n else to_kanji_single(d1.to_i) ;end \\\n + to_kanji_single(d2.to_s)\nend",
"def quote_zenkaku(str)\n if str.mbchar? >= 0\n \"「\" + str + \"」\"\n else\n \"'\" + str + \"'\"\n end\n end",
"def encode(s)\n return s if s.nil?\n return s if s.valid_encoding?\n if s.force_encoding(\"iso-8859-1\").valid_encoding?\n return s.encode('utf-8', 'iso-8859-1')\n end\n s\n end",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def iconv() end",
"def _encode_string(string)\n return string unless string.kind_of? String\n string.encode(\"UTF-8\", :undef => :replace, :invalid => :replace, :replace => \"?\")\n end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend",
"def sjis_to_jis(sjis)\n hi = (sjis >> 8) & 0xff\n lo = sjis & 0xff\n return lo if hi == 0\n hi -= (hi<=0x9f) ? 0x71 : 0xb1\n hi = hi * 2 + 1\n lo -= (lo > 0x7f) ? 1 : 0\n hi += (lo >= 0x9e) ? 1 : 0\n lo -= (lo >= 0x9e) ? 0x7d : 0x1f\n return hi << 8 | lo\nend",
"def encode(string, symbols = WHITESPACE)\n bits_per_symbol = (Math.log(symbols.length) / Math.log(2)).floor\n result = ''\n reg = %r{#{'.?' * bits_per_symbol}}\n string.unpack('B*')[0].scan(reg) do | bits |\n result << symbols[bits.to_i(2)]\n end\n result\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def translate_codepoints(str)\n str.gsub(/#x\\h+/) {|c| c[2..-1].scanf(\"%x\").first.chr(Encoding::UTF_8)}\n end",
"def encode_char(immune, input)\n input\n end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def encode_string(str)\n str = str.to_s.encode('UTF-8')\n\n # Force to binary, when assembling the packet\n str.force_encoding('ASCII-8BIT')\n encode_short(str.bytesize) + str\n end",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def encode(input_string)\n return input_string.tr(\"a-z\", \"n-za-m\")\nend",
"def toeuc(str)\n ::NKF::nkf('-em', str)\n end",
"def encode_string(str)\n str.chars.map(&:ord)\n end",
"def special2csa(str)\n {\n '中断' => 'CHUDAN',\n '投了' => 'TORYO',\n '持将棋' => 'JISHOGI',\n '千日手' => 'SENNICHITE',\n '詰み' => 'TSUMI',\n '不詰' => 'FUZUMI',\n '切れ負け' => 'TIME_UP',\n '反則勝ち' => 'ILLEGAL_ACTION', # 直前の手が反則(先頭に+か-で反則した側の情報を含める必要が有る)\n '反則負け' => 'ILLEGAL_MOVE' # ここで手番側が反則,反則の内容はコメントで表現\n }[str] || (raise ParseError)\n end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def encode(string)\n string.split(' ').map do |word|\n word.chars.map { |char| MORSE[char] }.join('|')\n end.join(' ')\nend",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def to_utf8!; replace(to_utf8); end",
"def codepoint\n unless $KCODE =~ /^u/i\n raise ArgumentError, \"unsupported encoding (#{$KCODE})\"\n end\n unless jlength == 1\n raise RangeError, \"string must be exactly one character long\"\n end\n \n\t case self.length\n \twhen 1\n \t UCSCodepoint.new(self[0])\n \twhen 2\n \t UCSCodepoint.new(\n \t ((self[0] & 0x1f) << 6) +\n \t (self[1] & 0x3f)\n \t )\n \twhen 3\n \t UCSCodepoint.new(\n \t ((self[0] & 0x0f) << 12) +\n \t ((self[1] & 0x3f) << 6) +\n \t (self[2] & 0x3f)\n \t )\n \twhen 4\n \t UCSCodepoint.new(\n \t ((self[0] & 0x07) << 18) +\n \t ((self[1] & 0x3f) << 12) +\n \t ((self[2] & 0x3f) << 6) +\n \t (self[3] & 0x3f)\n \t )\n \tend\n end",
"def encode_for_excel(s)\n s.encode(default_encoding, invalid: :replace, undef: :replace)\n end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def additional_encoding(s)\n encoding_hash = {\":\" => \"%3A\", \"+\" => \"%2B\"}\n encoding_hash.each_pair do |k, v|\n s.gsub!(k, v)\n end\n s\n end",
"def unify_voiced_katakana!(src)\n halfwidth =\n Characters::HALFWIDTH_VOICED_KATAKANA +\n Characters::HALFWIDTH_SEMI_VOICED_KATAKANA\n fullwidth =\n Characters::VOICED_KATAKANA +\n Characters::SEMI_VOICED_KATAKANA\n halfwidth.zip(fullwidth).inject(src) do |str, (h, f)|\n str.gsub!(h, f) || str\n end\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def to_arabic(string_with_kansuji, type = nil)\n Parser.to_arabic(string_with_kansuji, type)\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode(string)\n @@counter += 1\n string.split(' ').map do |word|\n word.chars.map { |char| MORSE[char] }.join(@separator)\n end.join(' ')\n end",
"def encode(input)\n return '' if input.nil?\n input.to_s.encode(Encoding::UTF_8)\n rescue Encoding::UndefinedConversionError\n input.dup.force_encoding(Encoding::UTF_8)\n end",
"def string_encoder\n return string if string.valid_encoding?\n str = string\n Encoding.list.each do |e|\n begin\n str.force_encoding(e.name)\n tmp_string = str.encode('UTF-8')\n return tmp_string if tmp_string.valid_encoding?\n rescue\n Rails.logger.debug { \"Rescue -> #{e.name}\" } if defined?(::Rails)\n end\n end\n\n impossible_encoding\n\n string\n end",
"def to_utf7(s)\n return force_encoding(force_encoding(s, 'UTF-8').gsub(/(&)|([^\\x20-\\x7e]+)/u) {\n if $1\n \"&-\"\n else\n base64 = [$&.unpack(\"U*\").pack(\"n*\")].pack(\"m\")\n \"&\" + base64.delete(\"=\\n\").tr(\"/\", \",\") + \"-\"\n end\n }, \"ASCII-8BIT\")\n end",
"def to_arabic(string_with_kansuji, type = nil)\n string_with_kansuji.gsub(kansuji_regxep) do |matched|\n case type\n when :mixed_arabic\n Kansuji.to_kansuji(to_i(matched), :mixed_arabic)\n else\n to_i(matched).to_s\n end\n end\n end",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def kcode() end",
"def convert (str)\r\n# REFERENCE : Using logic from this source https://stackoverflow.com/questions/13498688/pig-latin-method-translation\r\n alpha = ('a'..'z').to_a\r\n vowels = %w[a e i o u]\r\n consonants = alpha - vowels\r\n lstr = str.downcase\r\n if vowels.include?(lstr[0])\r\n str + 'way'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1]) && consonants.include?(lstr[2])\r\n str[3..-1] + str[0..2] + 'ay'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1])\r\n str[2..-1] + str[0..1] + 'ay'\r\n elsif consonants.include?(lstr[0])\r\n str[1..-1] + str[0] + 'ay'\r\n else\r\n str # return unchanged\r\n end\r\nend",
"def encode(message, key)\n message.codepoints.zip(key.to_s.chars.map(&:to_i).cycle).map { |x, v| x + v - 96}\nend",
"def energetic_encoding(sentence, hash)\n chars = sentence.split(\"\")\n new_sent = chars. map do |char|\n if hash.has_key?(char)\n hash[char]\n elsif char == \" \"\n \" \"\n else\n \"?\"\n end\n end \n new_sent.join(\"\")\nend",
"def from_native_charset(s, code, ignore_encoding_error = T.unsafe(nil), log = T.unsafe(nil)); end",
"def base64(text, charset=\"iso-2022-jp\", convert=true)\n if convert\n if charset == \"iso-2022-jp\"\n text = NKF.nkf('-j -m0', text)\n end\n end\n text = [text].pack('m').delete(\"\\r\\n\")\n \"=?#{charset}?B?#{text}?=\"\n end",
"def encode(str)\n str.downcase.chars.map { |c| str.downcase.count(c) > 1 ? ')' : '(' }.join\nend"
] |
[
"0.708227",
"0.6755341",
"0.66166526",
"0.6570429",
"0.64216846",
"0.63408977",
"0.6247393",
"0.615389",
"0.61476034",
"0.60412407",
"0.6033712",
"0.60058874",
"0.5984637",
"0.5964849",
"0.59043354",
"0.5874124",
"0.5853941",
"0.5785717",
"0.5740667",
"0.57272464",
"0.57184446",
"0.5689489",
"0.56890404",
"0.56814957",
"0.56686926",
"0.5662402",
"0.56575114",
"0.5656261",
"0.56511545",
"0.56186485",
"0.55916363",
"0.5572548",
"0.5563999",
"0.5560386",
"0.55471873",
"0.5540545",
"0.5469751",
"0.5469122",
"0.5456963",
"0.5456963",
"0.5451957",
"0.54418886",
"0.5435954",
"0.5432637",
"0.5430656",
"0.5412661",
"0.5402854",
"0.53989816",
"0.5395646",
"0.53934234",
"0.5377289",
"0.53762114",
"0.5370416",
"0.53692746",
"0.53594446",
"0.5346182",
"0.5345213",
"0.5339588",
"0.53239775",
"0.53163344",
"0.52942276",
"0.52849495",
"0.52847475",
"0.52613896",
"0.52583504",
"0.52401793",
"0.5236881",
"0.52332026",
"0.52281266",
"0.5219715",
"0.52189666",
"0.52145237",
"0.5195207",
"0.51892084",
"0.51845914",
"0.51767033",
"0.5174597",
"0.5172378",
"0.5163727",
"0.51551354",
"0.5142961",
"0.51319486",
"0.5129124",
"0.51211625",
"0.5109891",
"0.5109891",
"0.509894",
"0.50940883",
"0.5080009",
"0.50781953",
"0.50696874",
"0.5065667",
"0.5038042",
"0.50375783",
"0.5031412",
"0.50288534",
"0.50238794",
"0.5021189",
"0.5020517",
"0.502013"
] |
0.76257074
|
0
|
callseq: Kconv.toeuc(str) > string Convert str to EUCJP Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('exm0', str).
|
def toeuc(str)
::NKF::nkf('-em', str)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def toeuc; Kconv.toeuc(self) end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def toutf8; Kconv.toutf8(self) end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def to_ascii(string)\n require 'unidecode'\n\n begin\n #string.unpack(\"U*\").map{|c|c.chr}.join\n #Iconv.iconv(\"US-ASCII//TRANSLIT\", \"UTF-8\", string).first\n Unidecoder.decode(string).gsub(\"[?]\", \"\").gsub(/`/, \"'\").strip\n \n \n rescue => errmsg\n p errmsg\n string\n end\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def to_ascii(string)\n\t\tstring.unpack(\"U*\").map do |c| \n\t\t\tc.chr if c < 128\n\t\tend.join\n\tend",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def iconv() end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def test_to_norm_usascii\n result = ::UTF8Proc.normalize(@asciistr)\n assert_equal @asciistr, result\n assert_equal result.encoding, Encoding::US_ASCII unless jruby?\n refute_same @asciistr, result\n end",
"def convert (str)\r\n# REFERENCE : Using logic from this source https://stackoverflow.com/questions/13498688/pig-latin-method-translation\r\n alpha = ('a'..'z').to_a\r\n vowels = %w[a e i o u]\r\n consonants = alpha - vowels\r\n lstr = str.downcase\r\n if vowels.include?(lstr[0])\r\n str + 'way'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1]) && consonants.include?(lstr[2])\r\n str[3..-1] + str[0..2] + 'ay'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1])\r\n str[2..-1] + str[0..1] + 'ay'\r\n elsif consonants.include?(lstr[0])\r\n str[1..-1] + str[0] + 'ay'\r\n else\r\n str # return unchanged\r\n end\r\nend",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def iseuc(str)\n RegexpEucjp.match( str )\n end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def convert_string string\n return string unless @in_b or @in_em\n chars = if @in_b then\n string.chars.map do |char| \"#{char}\\b#{char}\" end\n elsif @in_em then\n string.chars.map do |char| \"_\\b#{char}\" end\n end\n\n chars.join\n end",
"def return_in_latin(input)\n input.tr('αβεηικμνορτχυζ'.upcase, 'abehikmnoptxyz'.upcase) \n end",
"def аватар text\n Data.emoji(text, exact: false, number: 0, lang: :ru)\n end",
"def get_unicode_of(character)\n character.unpack('U*').first.to_s(16).rjust(4, '0').upcase\nend",
"def tuc(arg)\n h = Hash.[](\".\"=>\"་\", \"/\"=>\"།\", \";\"=>\"༔\", \"\"=>\"\",\n \"ka\"=>\"ཀ\", \"kha\"=>\"ཁ\", \"ga\"=>\"ག\", \"nga\"=>\"ང\",\n \"ca\"=>\"ཅ\", \"cha\"=>\"ཆ\", \"ja\"=>\"ཇ\", \"nya\"=>\"ཉ\",\n \"ta\"=>\"ཏ\", \"tha\"=>\"ཐ\", \"da\"=>\"ད\", \"na\"=>\"ན\",\n \"pa\"=>\"པ\", \"pha\"=>\"ཕ\", \"ba\"=>\"བ\", \"ma\"=>\"མ\",\n \"tsa\"=>\"ཙ\", \"tsha\"=>\"ཚ\", \"dza\"=>\"ཛ\", \"wa\"=>\"ཝ\",\n \"zha\"=>\"ཞ\", \"za\"=>\"ཟ\", \"'a\"=>\"འ\", \"ya\"=>\"ཡ\",\n \"ra\"=>\"ར\", \"la\"=>\"ལ\", \"sha\"=>\"ཤ\", \"sa\"=>\"ས\",\n \"ha\"=>\"ཧ\", \"a\"=>\"ཨ\",\n # numbers !!! better include number_generator\n \"0\"=>\"༠\", \"1\"=>\"༡\", \"2\"=>\"༢\", \"3\"=>\"༣\",\n \"4\"=>\"༤\", \"5\"=>\"༥\", \"6\"=>\"༦\", \"7\"=>\"༧\",\n \"8\"=>\"༨\", \"9\"=>\"༩\",\n # vowel signs\n \".e\"=>\"ེ\", \".i\"=>\"ི\", \".o\"=>\"ོ\", \".u\"=>\"ུ\",\n # double vowel signs\n \"E\" => \"ཻ\", \"O\" => \"ཽ\",\n # subscribed characters\n \"x_ka\"=>\"ྐ\", \"x_kha\"=>\"ྑ\", \"x_ga\"=>\"ྒ\", \"x_nga\"=>\"ྔ\",\n \"x_ca\"=>\"ྕ\", \"x_cha\"=>\"ྖ\", \"x_ja\"=>\"ྗ\", \"x_nya\"=>\"ྙ\",\n \"x_ta\"=>\"ྟ\", \"x_tha\"=>\"ྐ\", \"x_da\"=>\"ྡ\", \"x_na\"=>\"ྣ\",\n \"x_pa\"=>\"ྤ\", \"x_pha\"=>\"ྥ\", \"x_ba\"=>\"ྦ\", \"x_ma\"=>\"ྨ\",\n \"x_tsa\"=>\"ྩ\", \"x_tsha\"=>\"ྪ\", \"x_dza\"=>\"ྫ\", \"x_wa\"=>\"ྭ\",\n \"x_zha\"=>\"ྮ\", \"x_za\"=>\"ྯ\", \"x_'a\"=>\"ཱ\", \"x_ya\"=>\"ྱ\",\n \"x_ra\"=>\"ྲ\", \"x_la\"=>\"ླ\", \"x_sha\"=>\"ྴ\", \"x_sa\"=>\"ྶ\",\n \"x_ha\"=>\"ྷ\", \"x_a\"=>\"ྸ\",\n # superscribed character\n \"ra_x\"=>\"ར\",\n # revered letters\n \"Ta\"=>\"ཊ\", \"Tha\" => \"ཋ\", \"Da\" => \"ཌ\", \"Na\" => \"ཎ\",\n \"Sha\" => \"ཥ\")\n\n result = h[arg]\n if result != nil\n erg = result\n else\n erg = \"\"\n end\n return erg\n end",
"def codepoint\n unless $KCODE =~ /^u/i\n raise ArgumentError, \"unsupported encoding (#{$KCODE})\"\n end\n unless jlength == 1\n raise RangeError, \"string must be exactly one character long\"\n end\n \n\t case self.length\n \twhen 1\n \t UCSCodepoint.new(self[0])\n \twhen 2\n \t UCSCodepoint.new(\n \t ((self[0] & 0x1f) << 6) +\n \t (self[1] & 0x3f)\n \t )\n \twhen 3\n \t UCSCodepoint.new(\n \t ((self[0] & 0x0f) << 12) +\n \t ((self[1] & 0x3f) << 6) +\n \t (self[2] & 0x3f)\n \t )\n \twhen 4\n \t UCSCodepoint.new(\n \t ((self[0] & 0x07) << 18) +\n \t ((self[1] & 0x3f) << 12) +\n \t ((self[2] & 0x3f) << 6) +\n \t (self[3] & 0x3f)\n \t )\n \tend\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def replace_invalid_characters(str)\n utf8_string = SUPPORTED_ENCODINGS.include?(str.encoding)\n return str if utf8_string && str.valid_encoding?\n\n temp_str = str.dup\n temp_str.encode!(TEMP_ENCODING, **ENCODING_OPTIONS) if utf8_string\n temp_str.encode!('utf-8', **ENCODING_OPTIONS)\n end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def to_ascii!; replace(to_ascii); end",
"def caesar_decode(string,offset)\n caesar_encode(string,offset*-1)\n# alphabet = [*('a'..'z')] \n# string.split(\"\").collect do |character| \n# if character == character.upcase && alphabet.include?(character.downcase) \n# diff = ((alphabet.index(character.downcase))+offset)%26 \n# character = alphabet[((alphabet.index(character.downcase))-offset)%26].upcase \n# elsif\n# character == character.downcase && alphabet.include?(character.downcase) \n# diff = ((alphabet.index(character.downcase))+offset)%26 \n# character= alphabet[((alphabet.index(character.downcase))-offset)%26].downcase \n# else\n# character \n# end \n# end.join (\"\") \nend",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def normalize string\r\n begin\r\n string.dup.force_encoding('UTF-8')\r\n rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e\r\n # @todo Improve error handling\r\n Solargraph::Logging.logger.warn \"Normalize error: #{e.message}\"\r\n string\r\n end\r\n end",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def emoji; end",
"def convert_text!(text, error_handler)\n text = AnselToUnicode.new(error_handler, true).convert(text) if convert_marc8_to_utf8?\n\n # Turn Horizon's weird escaping into UTF8: <U+nnnn> where nnnn is a hex unicode\n # codepoint, turn it UTF8 for that codepoint\n if settings[\"horizon.destination_encoding\"] == \"UTF8\" &&\n (settings[\"horizon.codepoint_translate\"].to_s == \"true\" ||\n settings[\"horizon.character_reference_translate\"].to_s == \"true\")\n\n regexp = if settings[\"horizon.codepoint_translate\"].to_s == \"true\" && settings[\"horizon.character_reference_translate\"].to_s == \"true\"\n # unicode codepoint in either HTML char reference form OR\n # weird horizon form. \n /(?:\\<U\\+|&#x)([0-9A-Fa-f]{4})(?:\\>|;)/\n elsif settings[\"horizon.codepoint_translate\"].to_s == \"true\"\n # just weird horizon form\n /\\<U\\+([0-9A-Fa-f]{4})\\>/\n else # just character references\n /&#x([0-9A-Fa-f]{4});/\n end\n \n text.gsub!(regexp) do\n [$1.hex].pack(\"U\")\n end\n end\n\n # eliminate illegal control chars. All ASCII less than 0x20\n # _except_ for four legal ones (including MARC delimiters). \n # http://www.loc.gov/marc/specifications/specchargeneral.html#controlfunction\n # this is all bytes from 0x00 to 0x19 except for the allowed 1B, 1D, 1E, 1F. \n text.gsub!(/[\\x00-\\x1A\\x1C]/, '')\n\n return text\n end",
"def unicode(str)\n\t\tRex::Text.to_unicode(str)\n\tend",
"def decoder(string)\n string.gsub(/(WUB)+/, ' ').strip\nend",
"def reencode_string(input); end",
"def convert(string)\n\t# Adding space to handle words that end in a unicode character\n\tstring += \" \"\n\n\tword = \"\"\n\tunicode = false\n\tuni_string = \"\"\n\n\t# puts \"Starting each char...\"\n\tstring.each_char do |char|\n\t\t\n\t\t# puts \"char: #{char}\"\n\n\t\tif char != \"\\\\\" and !unicode\n\t\t\t# puts \"Adding #{char} to word\"\n\t\t\tword += convert_char(char)\n\n\t\telsif char == \"\\\\\"\n\t\t\t# puts \"Starting unicode string\"\n\t\t\tuni_string = \"\\\\\"\n\t\t\tunicode = true\n\n\t\telsif char != \" \" and unicode\n\t\t\t# puts \"Putting #{char} in unicode string: #{uni_string}\"\n\t\t\tuni_string += char\n\n\t\telsif unicode and char == \" \"\n\t\t\t# puts \"Found end of unicode string: #{uni_string}\"\n\t\t\tword += convert_char(uni_string)\n\t\t\tuni_string = \"\"\n\t\t\tunicode = false\n\t\telse\n\t\t\tputs \"Not sure what to do with #{char}\"\n\t\tend\n\tend\n\n\t# Strip to remove extra spaces\n\treturn word.strip\n\nend",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def utf8safe(text)\n require 'iconv'\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n return ic.iconv(text + ' ')[0..-2]\nend",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def encode(input_string)\n return input_string.tr(\"a-z\", \"n-za-m\")\nend",
"def translate_codepoints(str)\n str.gsub(/#x\\h+/) {|c| c[2..-1].scanf(\"%x\").first.chr(Encoding::UTF_8)}\n end",
"def unify_voiced_katakana!(src)\n halfwidth =\n Characters::HALFWIDTH_VOICED_KATAKANA +\n Characters::HALFWIDTH_SEMI_VOICED_KATAKANA\n fullwidth =\n Characters::VOICED_KATAKANA +\n Characters::SEMI_VOICED_KATAKANA\n halfwidth.zip(fullwidth).inject(src) do |str, (h, f)|\n str.gsub!(h, f) || str\n end\n end",
"def special2csa(str)\n {\n '中断' => 'CHUDAN',\n '投了' => 'TORYO',\n '持将棋' => 'JISHOGI',\n '千日手' => 'SENNICHITE',\n '詰み' => 'TSUMI',\n '不詰' => 'FUZUMI',\n '切れ負け' => 'TIME_UP',\n '反則勝ち' => 'ILLEGAL_ACTION', # 直前の手が反則(先頭に+か-で反則した側の情報を含める必要が有る)\n '反則負け' => 'ILLEGAL_MOVE' # ここで手番側が反則,反則の内容はコメントで表現\n }[str] || (raise ParseError)\n end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def to_utf8!; replace(to_utf8); end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def to_arabic(string_with_kansuji, type = nil)\n Parser.to_arabic(string_with_kansuji, type)\n end",
"def decoder(message)\n translated = message\n translated.gsub!(/\\w/).each do |letter|\n if letter.ord + 13 < 122\n letter.gsub!(letter, (letter.ord + 13).chr)\n else\n letter.gsub!(letter, (letter.ord-13).chr)\n end\n end\nend",
"def convert_vowel_with_hash(character)\n\ttranslation_table = {\n\t\t\"a\" => \"e\",\n\t\t\"e\" => \"i\",\n\t\t\"i\" => \"o\",\n\t\t\"o\" => \"u\",\n\t\t\"u\" => \"a\",\n\t}\n\n\tif translation_table.has_key?(character)\n\t\treturn translation_table[character]\n\telse\n\t\treturn character\n\tend\nend",
"def unencrypt_str(s)\r\n new_str = ''\r\n i_key = -1\r\n s.each_byte do |c|\r\n if i_key < EN_KEY_LEN - 1\r\n i_key += 1\r\n else\r\n i_key = 0\r\n end\r\n\r\n if EN_STR.index(c.chr).nil?\r\n new_str << c.chr\r\n next\r\n end\r\n\r\n i_from_str = EN_STR.index(c.chr) - EN_STR.index(EN_KEY[i_key])\r\n i_from_str = i_from_str + EN_STR_LEN if i_from_str < 0\r\n new_str << EN_STR[i_from_str]\r\n end\r\n return new_str\r\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def encode(immune, input)\n return nil if input.nil?\n encoded_string = ''\n encoded_string.encode!(Encoding::UTF_8)\n input.encode(Encoding::UTF_8).chars do |c|\n encoded_string << encode_char(immune,c)\n end\n encoded_string\n end",
"def to_ascii\n input.gsub(/[^\\x00-\\x7f]/u, &method(:decode)).strip\n end",
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def unicode_filter_encode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_encode(str) : str\n end",
"def unicode_text(pdf, str, options={})\n pdf.text(e(\"\\xfe\\xff#{str}\", :encoding => 'UTF-16BE'), options) # start Unicode UTF-16BE encoding\n end",
"def codepoint(str)\n return str.gsub(/\\\\u[\\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }\n end",
"def decode(string)\n if string.class != String\n return \"Input is not a string\"\n else\n string_array = string.downcase.split('')\n alphabet_array = \"abcdefghijklmnopqrstuvwxyz\".split('')\n new_string = \"\"\n string_array.map! do |x|\n letter_index = alphabet_array.index(x)\n if x =~ /[A-Za-z]/\n alphabet_array[-letter_index-1]\n else\n x\n end\n end\n final_string = string_array.join('')\n end\n if final_string =~ /\\s/\n final_string_array = final_string.split('? ')\n final_string_array.map! do |x|\n x.capitalize\n end\n final_string_array.join('? ')\n else\n final_string\n end\nend",
"def latinize_up(x)\n\tletters = ('A'..'Z').to_a\n\tvowels = %w[A E I O U]\n\tconsonants = letters - vowels\n\tlower_case_letters = ('a'..'z').to_a\n\tlower_case_vowels = %w[a e i o u]\n\tlower_case_consonants = lower_case_letters - lower_case_vowels\n\t\n\tif vowels.include?(x[0..0])\n\t\t(x.downcase + 'ay').capitalize\n\telsif x[0..2] == 'Squ'\n\t\t(x[3..-1].downcase + 'squay').capitalize\n\telsif x[0..1] == 'Qu'\n\t\t(x[2..-1].downcase + 'quay').capitalize\n elsif consonants.include?(x[0..0]) && lower_case_consonants.include?(x[1..1]) && lower_case_consonants.include?(x[2..2])\n\t\t(x[3..-1].downcase + x[0..2] + 'ay').capitalize\n\telsif consonants.include?(x[0..0]) && lower_case_consonants.include?(x[1..1]) \n\t\t(x[2..-1].downcase + x[0..1] + 'ay').capitalize\n\telse consonants.include?(x[0])\n\t\t(x[1..-1].downcase + x[0..0] + 'ay').capitalize\n\tend\n\n\nend",
"def tojis; Kconv.tojis(self) end",
"def he_decode(text); self.class.he_decode text; end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def number_encoding(str)\n result = ''\n str.downcase.each_char do |char|\n if char =~ /[a-z]/\n result << (char.ord - 96).to_s\n else\n result << char\n end\n end\n result\nend",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def disemvowel(string)\n\nend",
"def to_unicode(string)\n SimpleIDN.to_unicode(string)\n end",
"def to_arabic(string_with_kansuji, type = nil)\n string_with_kansuji.gsub(kansuji_regxep) do |matched|\n case type\n when :mixed_arabic\n Kansuji.to_kansuji(to_i(matched), :mixed_arabic)\n else\n to_i(matched).to_s\n end\n end\n end",
"def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend",
"def uC\n NWRFCLib::Cutf16le_to_utf8.iconv(self).strip\n end",
"def transcode target_charset, orig_charset, text\n ## normalize some charset names as we see them in email\n source_charset = case orig_charset\n when /UTF[-_ ]?8/i; \"utf-8\"\n when /(iso[-_ ])?latin[-_ ]?1$/i; \"ISO-8859-1\"\n when /iso[-_ ]?8859[-_ ]?15/i; 'ISO-8859-15'\n when /unicode[-_ ]1[-_ ]1[-_ ]utf[-_]7/i; \"utf-7\"\n when /^euc$/i; 'EUC-JP' # XXX try them all?\n when /^(x-unknown|unknown[-_ ]?8bit|ascii[-_ ]?7[-_ ]?bit)$/i; 'ASCII'\n else orig_charset\n end\n\n if in_ruby19_hell?\n ret = begin\n text.dup.encode(target_charset)\n rescue EncodingError, ArgumentError => e\n nil\n end\n\n (ret && ret.valid_encoding?) ? ret : force_to_ascii(text).force_encoding(target_charset)\n else\n begin\n Iconv.iconv(\"#{target_charset}//TRANSLIT//IGNORE\", source_charset, text + \" \").join[0 .. -2] # work around iconv bug with last two characters\n rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::InvalidCharacter, Iconv::IllegalSequence => e\n #$stderr.puts \"WARNING couldn't transcode text from #{source_charset} to #{target_charset} (#{text[0 ... 20].inspect}...): got #{e.class}: #{e.message}\"\n text = force_to_ascii text\n Iconv.iconv(\"#{target_charset}//TRANSLIT//IGNORE\", \"utf-8\", text + \" \").join[0 .. -2]\n end\n end\n end",
"def intl_char_norm(value)\n if value.include?(\"ʻ\")\n # This character is often found in Romanized versions of Korean names and\n # titles (e.g. \"Sŏngtʻanje : Pak Tʻae-wŏn chʻangjakjip\") but US users tend\n # to enter a single tick (') instead.\n return value.gsub(\"ʻ\", \"'\")\n end\n value\nend",
"def encode(str)\n\tswap_raw = \"GA-DE-RY-PO-LU-KI\".reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.split(\"-\")\n\tencoder = Hash.new\n\tswap_raw.each { |pair| encoder[pair[0]] = pair[1] }\n\tencoded_string = \"\"\n\tputs encoder\n\tfor char in str.split(\"\")\n\t\tif encoder.key?(char) #correct?\n\t\t\tencoded_string += encoder[char]\n\t\telse\n\t\t\tencoded_string += char\n\t\tend\n\tend\n\treturn encoded_string\nend",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def reverse_vowels(s)\n\tcs = s.bytes\n\ti = 0\n\tj = cs.size-1\n\tdict = ['A','E','I','O','U','a','e','i','o','u'].flat_map {|x| x.bytes}\n\twhile i<j do\n\t\twhile i<j and not (dict.include? cs[i]) do\n\t\t\ti += 1\n\t\tend\n\t\twhile i<j and not (dict.include? cs[j]) do\n\t\t\tj -=1\n\t\tend\n\t\tif i<j then\n\t\t\tswap(cs, i, j)\n\t\t\ti += 1\n\t\t\tj -= 1\n\t\tend\n\tend\n\tcs.map {|x| x.chr}.join\nend",
"def unicode_normalize!(form = :nfc)\n require 'unicode_normalize/normalize.rb' unless defined? UnicodeNormalize\n # String.send(:define_method, :unicode_normalize!, ->(form = :nfc) { replace(unicode_normalize(form)) } )\n replace(unicode_normalize(form))\n end",
"def return_in_greek(input)\n input.tr('abehikmnoptxyz'.upcase, 'αβεηικμνορτχυζ'.upcase)\n end"
] |
[
"0.62796515",
"0.62690276",
"0.62589365",
"0.6027342",
"0.5979895",
"0.5930107",
"0.5883229",
"0.5879415",
"0.5860001",
"0.58266497",
"0.57717115",
"0.57717115",
"0.5756651",
"0.5754821",
"0.57196504",
"0.5695234",
"0.567629",
"0.56717855",
"0.5644566",
"0.56382644",
"0.5599181",
"0.5583159",
"0.5567176",
"0.5564376",
"0.5536656",
"0.5534947",
"0.5528662",
"0.55149084",
"0.5507387",
"0.5504321",
"0.5474387",
"0.5452637",
"0.5448354",
"0.54423994",
"0.54218584",
"0.5407613",
"0.53983814",
"0.53941107",
"0.53522664",
"0.53508323",
"0.53289074",
"0.53183544",
"0.5316407",
"0.53083545",
"0.53079337",
"0.530602",
"0.5296946",
"0.5287753",
"0.5286433",
"0.5284101",
"0.52759683",
"0.52754384",
"0.5260517",
"0.52545357",
"0.52534765",
"0.5253303",
"0.5252003",
"0.5234039",
"0.5217323",
"0.5209237",
"0.52030575",
"0.5182993",
"0.51697356",
"0.5165587",
"0.51596445",
"0.5159182",
"0.515373",
"0.5145982",
"0.5145538",
"0.51439524",
"0.51214784",
"0.51199",
"0.511771",
"0.51174015",
"0.51151866",
"0.5110849",
"0.5109905",
"0.51036197",
"0.5094846",
"0.5091868",
"0.5077909",
"0.50710565",
"0.50706667",
"0.5069405",
"0.50671226",
"0.5054644",
"0.50467235",
"0.5044517",
"0.50442845",
"0.50438565",
"0.5038921",
"0.503412",
"0.5022625",
"0.5013045",
"0.5010832",
"0.5003152",
"0.49988726",
"0.4990772",
"0.49898416",
"0.4978063"
] |
0.6082589
|
3
|
callseq: Kconv.tosjis(str) > string Convert str to Shift_JIS Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('sxm0', str).
|
def tosjis(str)
::NKF::nkf('-sm', str)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def tosjis; Kconv.tosjis(self) end",
"def tojis; Kconv.tojis(self) end",
"def sjis_to_jis(sjis)\n hi = (sjis >> 8) & 0xff\n lo = sjis & 0xff\n return lo if hi == 0\n hi -= (hi<=0x9f) ? 0x71 : 0xb1\n hi = hi * 2 + 1\n lo -= (lo > 0x7f) ? 1 : 0\n hi += (lo >= 0x9e) ? 1 : 0\n lo -= (lo >= 0x9e) ? 0x7d : 0x1f\n return hi << 8 | lo\nend",
"def issjis(str)\n RegexpShiftjis.match( str )\n end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def issjis;\tKconv.issjis(self) end",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def kana2kana(str1)\n result = []\n str2 = Kana2rom::hira_to_kata(str1)\n str3 = Kana2rom::kata_to_hira(str1)\n result << str1\n result << str2 if str2.length > 0 and str1 !=str2\n result << str3 if str3.length > 0 and str2 !=str3 and str3 != str1\n return result\n end",
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def kan2n2(s)\n case s.length\n when 1\n '〇一二三四五六七八九十'.index(s)\n when 2\n '〇一二三四五六七八九十'.index(s[1]) + 10\n else\n raise '21以上の数値に対応していません'\n end\n end",
"def toutf8; Kconv.toutf8(self) end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def unify_voiced_katakana!(src)\n halfwidth =\n Characters::HALFWIDTH_VOICED_KATAKANA +\n Characters::HALFWIDTH_SEMI_VOICED_KATAKANA\n fullwidth =\n Characters::VOICED_KATAKANA +\n Characters::SEMI_VOICED_KATAKANA\n halfwidth.zip(fullwidth).inject(src) do |str, (h, f)|\n str.gsub!(h, f) || str\n end\n end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def reencode_string(input); end",
"def encode_for_excel(s)\n s.encode(default_encoding, invalid: :replace, undef: :replace)\n end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def to_kanji(dd)\n d1, d2 = dd.length == 1 ? ['0', dd[0]-48] : [dd[0]-48, dd[1]-48]\n case d1 when 0 then ''\n when 1 then 'JUU'\n else to_kanji_single(d1.to_i) ;end \\\n + to_kanji_single(d2.to_s)\nend",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def iconv() end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend",
"def processString(s=@orig_string) \n # All LaTeX Macron codes begin with an '=' token. Scan for that using a \n # RegEx. The value is set to firstSlash. \n \n firstSlash = s =~ /(\\\\=.*?\\})/\n return s if $1.nil?\n \n testChar = $1\n \n # In the event that the first character is macron-bearing follow this \n # case. \n if firstSlash == 0\n return processChar(testChar).to_s +\n processString(s[firstSlash+testChar.length..s.length])\n end\n \n # In the more general case, we take the original string up to the first\n # macron-beginning-slash. We return that + running processChar on the\n # remainder of the string, that is return part_ok +\n # processString(the_rest).\n \n return s[0..firstSlash-1] + processChar(testChar).to_s +\n processString(s[firstSlash+testChar.length..s.length])\n end",
"def konverze s1\n s2 = String.new(s1)\n if WINDOWS == true and KONVERZE == true\n replace(s1,s2,\"\\xec\",\"\\xd8\") # e s hackem\n replace(s1,s2,\"\\xe8\",\"\\x9f\") # c s hackem\n replace(s1,s2,\"\\xf8\",\"\\xfd\") # r s hackem\n\n replace(s1,s2,\"\\xcc\",\"\\xb7\") # E s hackem\n replace(s1,s2,\"\\xc8\",\"\\xac\") # C s hackem\n replace(s1,s2,\"\\xd8\",\"\\xfc\") # R s hackem\n\n replace(s1,s2,\"\\xef\",\"\\xd4\") # d s hackem\n replace(s1,s2,\"\\xf2\",\"\\xe5\") # n s hackem\n replace(s1,s2,\"\\x9d\",\"\\x9c\") # t s hackem\n\n replace(s1,s2,\"\\xcf\",\"\\xd2\") # D s hackem\n replace(s1,s2,\"\\xd2\",\"\\xd5\") # N s hackem\n replace(s1,s2,\"\\x8d\",\"\\x9b\") # T s hackem\n\n replace(s1,s2,\"\\x9e\",\"\\xa7\") # z s hackem\n replace(s1,s2,\"\\x9a\",\"\\xe7\") # s s hackem\n\n replace(s1,s2,\"\\x8e\",\"\\xa6\") # Z s hackem\n replace(s1,s2,\"\\x8a\",\"\\xe6\") # S s hackem\n\n replace(s1,s2,\"\\xe1\",\"\\xa0\") # a s carkou\n replace(s1,s2,\"\\xe9\",\"\\x82\") # e s carkou\n replace(s1,s2,\"\\xed\",\"\\xa1\") # i s carkou\n replace(s1,s2,\"\\xf3\",\"\\xa2\") # o s carkou\n replace(s1,s2,\"\\xfa\",\"\\xa3\") # u s carkou\n replace(s1,s2,\"\\xfd\",\"\\xec\") # y s carkou\n replace(s1,s2,\"\\xf9\",\"\\x85\") # u s krouzkem\n\n replace(s1,s2,\"\\xc1\",\"\\xb5\") # A s carkou\n replace(s1,s2,\"\\xc9\",\"\\x90\") # E s carkou\n replace(s1,s2,\"\\xcd\",\"\\xd6\") # I s carkou\n replace(s1,s2,\"\\xd3\",\"\\xe0\") # O s carkou\n replace(s1,s2,\"\\xda\",\"\\xe9\") # U s carkou\n replace(s1,s2,\"\\xdd\",\"\\xed\") # Y s carkou\n replace(s1,s2,\"\\xd9\",\"\\xde\") # U s kroužkem\n end\n return s2\nend",
"def special2csa(str)\n {\n '中断' => 'CHUDAN',\n '投了' => 'TORYO',\n '持将棋' => 'JISHOGI',\n '千日手' => 'SENNICHITE',\n '詰み' => 'TSUMI',\n '不詰' => 'FUZUMI',\n '切れ負け' => 'TIME_UP',\n '反則勝ち' => 'ILLEGAL_ACTION', # 直前の手が反則(先頭に+か-で反則した側の情報を含める必要が有る)\n '反則負け' => 'ILLEGAL_MOVE' # ここで手番側が反則,反則の内容はコメントで表現\n }[str] || (raise ParseError)\n end",
"def weirdFixString(str)\n idx = str.index(\"\\000\\000\")\n idx.nil? ? str : str[0..idx]\n end",
"def wide_string(str)\n # if given a nil string, assume caller wants to pass a nil pointer to win32\n return nil if str.nil?\n\n str.encode('UTF-16LE')\n end",
"def width(str, cjk = false)\n raise NotImplementedError\n end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def compress_str(str)\n compress = str.gsub(/(.)\\1*/).to_a\n hash = Hash.new(0)\n arr = []\n compress.each do |len|\n if len.length < 2\n arr << len\n else\n arr << len.length\n arr << len\n end\n end\n\n new_arr = arr.map {|a| a.to_s}\n\n new_arr.each_with_index do |compact, i|\n if compact.length > 1\n compact.each_char do |char|\n new_arr[i] = char\n end\n end\n end\n\nreturn new_arr.join(\"\")\n\nend",
"def encode(str)\n\tswap_raw = \"GA-DE-RY-PO-LU-KI\".reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.split(\"-\")\n\tencoder = Hash.new\n\tswap_raw.each { |pair| encoder[pair[0]] = pair[1] }\n\tencoded_string = \"\"\n\tputs encoder\n\tfor char in str.split(\"\")\n\t\tif encoder.key?(char) #correct?\n\t\t\tencoded_string += encoder[char]\n\t\telse\n\t\t\tencoded_string += char\n\t\tend\n\tend\n\treturn encoded_string\nend",
"def encode_string s\n s.downcase.split(//).inject(\"\") do |code,char|\n code + encode_char(char)\n end\n end",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def from_native_charset(s, code, ignore_encoding_error = T.unsafe(nil), log = T.unsafe(nil)); end",
"def north_korean_cipher(coded_message)\n\tinput = coded_message.downcase.split(\"\") # Check out this method in IRB to see how it works! Also refer to the ruby docs.\n\tdecoded_sentence = []\n\tcipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n\t\t\t\t\t\t\"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n\t\t\t\t\t\t\"g\" => \"c\", \n\t\t\t\t\t\t\"h\" => \"d\", \n\t\t\t\t\t\t\"i\" => \"e\", \n\t\t\t\t\t\t\"j\" => \"f\",\n\t\t\t\t\t\t\"k\" => \"g\",\n\t\t\t\t\t\t\"l\" => \"h\",\n\t\t\t\t\t\t\"m\" => \"i\",\n\t\t\t\t\t\t\"n\" => \"j\",\n\t\t\t\t\t\t\"o\" => \"k\",\n\t\t\t\t\t\t\"p\" => \"l\",\n\t\t\t\t\t\t\"q\" => \"m\",\n\t\t\t\t\t\t\"r\" => \"n\",\n\t\t\t\t\t\t\"s\" => \"o\",\n\t\t\t\t\t\t\"t\" => \"p\",\n\t\t\t\t\t\t\"u\" => \"q\",\n\t\t\t\t\t\t\"v\" => \"r\",\n\t\t\t\t\t\t\"w\" => \"s\",\n\t\t\t\t\t\t\"x\" => \"t\",\n\t\t\t\t\t\t\"y\" => \"u\",\n\t\t\t\t\t\t\"z\" => \"v\",\n\t\t\t\t\t\t\"a\" => \"w\",\n\t\t\t\t\t\t\"b\" => \"x\",\n\t\t\t\t\t\t\"c\" => \"y\",\n\t\t\t\t\t\t\"d\" => \"z\"}\n\t\n# This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n# the best data structure for this problem? What are the pros and cons of hashes?\n# \n# We automated this task with our own method that shifts letters automatically. It even allows you to\n# specify the amount the letters need to be shifted. This will output our needed hash, without having to\n# manually write every key/value pair.\n\n\tinput.each do |x| # iterate through each letter in the coded message (input is an array of all letters in order)\n\t\tfound_match = false # If found_match is set to true, the block code \"if not found_match\" will NEVER be executed\n\t\t\t\t\t\t\t\t\t\t\t\t # so the unmapped letter will not be added back to the decoded message\n\t\tcipher.each_key do |y| # iterate through each key in the hash table\n\t\t\tif x == y # compare the current letter in the coded message to the key in the hash table. If they are equals,\n\t\t\t\t\t\t\t\t # meaning the decoded letter is found, add the mapped value to the decoded message\n\t\t\t\tputs \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n\t\t\t\tdecoded_sentence << cipher[y]\n\t\t\t\tfound_match = true\n\t\t\t\tbreak # Once the decoded letter is found, break out of the loop and go for the next letter in the input message\n\t\t\telsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" # If any of these symbols is\n\t\t\t\t# found in the coded message, it is equivalent to a space. These are all OR statements, so if any are found to\n\t\t\t\t# be true, it will run the block of code.\n\t\t\t\tdecoded_sentence << \" \"\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\telsif (0..9).to_a.include?(x) # This puts all the numbers from 0 to 9 into an array and check if that array contains x\n\t\t\t\tdecoded_sentence << x\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\tend \n\t\tend\n\t\tif not found_match # If some character not covered by any of the if statments is found in the coded message\n\t\t# that character is put into the decoded message\n\t\t\tdecoded_sentence << x\n\t\tend\n\tend\n\tdecoded_sentence = decoded_sentence.join(\"\")\n \n\tif decoded_sentence.match(/\\d+/) #Checks the decoded message for any numbers \n\t\tdecoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } # Replaces those numbers with a number divided by 100, because\n\t\t# he has been known to exaggerate about the amount of stuff he has\n\tend \n\treturn decoded_sentence # return the decoded message \nend",
"def decode(str)\n result = \"\"\n str.chars.each_with_index do |el, idx|\n if idx % 2 == 0\n key = str[idx + 1].to_i\n key.times do\n result += el\n end\n end\n end\n result\nend",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def to_utf8(s)\n return nil if s.nil?\n\n # Attempt to politely transcode the string.\n s.encode(\"UTF-8\").scrub\n rescue\n # If that doesn't work, then overwrite the existing encoding and\n # clobber any strange characters.\n s.force_encoding(\"UTF-8\").scrub\n end",
"def kern(string)\n kerned = [[]]\n last_byte = nil\n\n string.each_byte do |byte|\n k = last_byte && @kern_pair_table[[last_byte, byte]]\n if k\n kerned << -k << [byte]\n else\n kerned.last << byte\n end\n last_byte = byte\n end\n\n kerned.map do |e|\n e = e.is_a?(Array) ? e.pack('C*') : e\n if e.respond_to?(:force_encoding)\n e.force_encoding(::Encoding::Windows_1252)\n else\n e\n end\n end\n end",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def sterilize(str)\n str.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n str.gsub!(0x00.chr,'[NUL]')\n str.gsub!(0x01.chr,'[SOH]')\n str.gsub!(0x02.chr,'[STX]')\n str.gsub!(0x03.chr,'[ETX]')\n str.gsub!(0x04.chr,'[EOT]')\n str.gsub!(0x05.chr,'[ENQ]')\n str.gsub!(0x06.chr,'[ACK]')\n str.gsub!(0x07.chr,'[BEL]')\n # 0x08 is backspace\n # 0x09 is TAB\n # 0x10 is line feed\n str.gsub!(0x0B.chr,'[VT]')\n # 0x0c is form feed\n # 0x0d is carriage return\n str.gsub!(0x0E.chr,'[SO]')\n str.gsub!(0x0F.chr,'[SI]')\n str.gsub!(0x10.chr,'[DLE]')\n str.gsub!(0x11.chr,'[DC1]')\n str.gsub!(0x12.chr,'[DC2]')\n str.gsub!(0x13.chr,'[DC3]')\n str.gsub!(0x14.chr,'[DC4]')\n str.gsub!(0x15.chr,'[NAK]')\n str.gsub!(0x16.chr,'[SYN]')\n str.gsub!(0x17.chr,'[ETB]')\n str.gsub!(0x18.chr,'[CAN]')\n str.gsub!(0x19.chr,'[EM]')\n str.gsub!(0x1a.chr,'[SUB]')\n str.gsub!(0x1C.chr,'[FS]')\n str.gsub!(0x1D.chr,'[GS]')\n str.gsub!(0x1E.chr,'[RS]')\n str.gsub!(0x1F.chr,'[US]')\n str\n end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def codepoint\n unless $KCODE =~ /^u/i\n raise ArgumentError, \"unsupported encoding (#{$KCODE})\"\n end\n unless jlength == 1\n raise RangeError, \"string must be exactly one character long\"\n end\n \n\t case self.length\n \twhen 1\n \t UCSCodepoint.new(self[0])\n \twhen 2\n \t UCSCodepoint.new(\n \t ((self[0] & 0x1f) << 6) +\n \t (self[1] & 0x3f)\n \t )\n \twhen 3\n \t UCSCodepoint.new(\n \t ((self[0] & 0x0f) << 12) +\n \t ((self[1] & 0x3f) << 6) +\n \t (self[2] & 0x3f)\n \t )\n \twhen 4\n \t UCSCodepoint.new(\n \t ((self[0] & 0x07) << 18) +\n \t ((self[1] & 0x3f) << 12) +\n \t ((self[2] & 0x3f) << 6) +\n \t (self[3] & 0x3f)\n \t )\n \tend\n end",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def to_arabic(string_with_kansuji, type = nil)\n Parser.to_arabic(string_with_kansuji, type)\n end",
"def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end",
"def to_arabic(string_with_kansuji, type = nil)\n string_with_kansuji.gsub(kansuji_regxep) do |matched|\n case type\n when :mixed_arabic\n Kansuji.to_kansuji(to_i(matched), :mixed_arabic)\n else\n to_i(matched).to_s\n end\n end\n end",
"def convert(str)\n\t\t@result=convert_han(convert_words(str))\n\t\t# @result=convert_words(str)\n\t\t@result.gsub!(\" #%\",\"\")\n\t\t@result.gsub!(\"%# \",\"\")\n\t\t@result\n\tend",
"def toeuc(str)\n ::NKF::nkf('-em', str)\n end",
"def z_fix_charset\n Iconv.iconv('UTF-8', 'UTF-8', self).first.to_s\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def compress_str(_str)\n new_str = ''\n hash = Hash.new(0)\n\n _str.chars do |char|\n hash[char] += 1\n end\n\n hash.each do |char, counter|\n new_str += counter > 1 ? counter.to_s + char : char\n end\n\n new_str\nend",
"def compress_str(str)\n group = []\n str.each_char do |c|\n if group.empty?\n group.push([c])\n elsif c == group.last[0]\n group.last.push(c)\n else\n group.push([c])\n end\n end\n compressed = ''\n group.each do |el|\n if el.length > 1\n compressed = compressed + el.length.to_s + el[0]\n else\n compressed += el[0]\n end\n end\n compressed\nend",
"def translate_codepoints(str)\n str.gsub(/#x\\h+/) {|c| c[2..-1].scanf(\"%x\").first.chr(Encoding::UTF_8)}\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def additional_encoding(s)\n encoding_hash = {\":\" => \"%3A\", \"+\" => \"%2B\"}\n encoding_hash.each_pair do |k, v|\n s.gsub!(k, v)\n end\n s\n end",
"def test_to_norm_usascii\n result = ::UTF8Proc.normalize(@asciistr)\n assert_equal @asciistr, result\n assert_equal result.encoding, Encoding::US_ASCII unless jruby?\n refute_same @asciistr, result\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def number_encoding(str)\n result = ''\n str.downcase.each_char do |char|\n if char =~ /[a-z]/\n result << (char.ord - 96).to_s\n else\n result << char\n end\n end\n result\nend",
"def store_japanese_string(string)\n string = string.gsub(/[\\n\\r\\t ]+/, \" \")\n\n string.each_char do |c|\n w = if c.ascii_only? then 1 else 2 end\n\n @elements << Box.new(width: w, value: c)\n @elements << Glue.new(width: 1, shrink: 1, stretch: 1)\n end\n\n @elements.pop # Remove last glue element\n # Add unconditional break at the end of paragraph\n @elements << Glue(width: 0, shrink: Infinity, stretch: 0)\n @elements << Penaty(width: 0, penalty: -Infinity, flagged: 1)\n end",
"def convert_encoding(content); end",
"def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer,len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end",
"def to_utf8!; replace(to_utf8); end",
"def do_encoding_terminal(string)\n string = string.to_s\n string.gsub!(\"\\r\\r\", \"\\r\")\n string.gsub!(\"\\r\\n\", \"\\n\")\n string.gsub!(\"\\r\\$\\s\", \"\")\n\n string.gsub!(/.\\r/, \"\")\n string.gsub!(/\\x1B\\[\\d*?[ABCDsuKJ]/, '')\n string\n end",
"def fix_encoding(str)\n str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)\n str\nend",
"def encode(string)\n string.unpack('B*')[0].tr('01', \" \\n\")\n end",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def force_to_ascii s\n out = \"\"\n s.each_byte do |b|\n if (b & 128) != 0\n out << \"\\\\x#{b.to_s 16}\"\n else\n out << b.chr\n end\n end\n #out.force_encoding Encoding::UTF_8 if in_ruby19_hell? # not necessary?\n out\n end",
"def toutf16; Kconv.toutf16(self) end",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def return_in_latin(input)\n input.tr('αβεηικμνορτχυζ'.upcase, 'abehikmnoptxyz'.upcase) \n end",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def compress_str(str)\n result = str[0]\n prev = {char: str[0], num: 1}\n (1...str.length).each do |i|\n if str[i] == prev[:char]\n prev[:num] += 1\n if prev[:num] > 2\n result = result[0...-2] + prev[:num].to_s + prev[:char]\n else\n result = result[0...-1] + prev[:num].to_s + prev[:char]\n end \n else\n result += str[i]\n prev[:char], prev[:num] = str[i], 1\n end\n end\n\n result\nend",
"def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer, len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end",
"def zen2n(s)\n '0123456789'.index(s)\n end",
"def to_utf7(s)\n return force_encoding(force_encoding(s, 'UTF-8').gsub(/(&)|([^\\x20-\\x7e]+)/u) {\n if $1\n \"&-\"\n else\n base64 = [$&.unpack(\"U*\").pack(\"n*\")].pack(\"m\")\n \"&\" + base64.delete(\"=\\n\").tr(\"/\", \",\") + \"-\"\n end\n }, \"ASCII-8BIT\")\n end"
] |
[
"0.7633478",
"0.72962385",
"0.7130548",
"0.6998048",
"0.69295764",
"0.65437055",
"0.6470854",
"0.62177044",
"0.61156046",
"0.5964748",
"0.5874158",
"0.58657634",
"0.5723059",
"0.5618021",
"0.55948216",
"0.55146575",
"0.5369005",
"0.5367491",
"0.5343318",
"0.52747214",
"0.522919",
"0.5225852",
"0.5130281",
"0.51221144",
"0.5063072",
"0.50310594",
"0.50275636",
"0.5014453",
"0.5006939",
"0.50025535",
"0.500143",
"0.49997556",
"0.49933553",
"0.49859664",
"0.4960353",
"0.49603194",
"0.4959603",
"0.49559182",
"0.49552763",
"0.4937704",
"0.49287325",
"0.4898001",
"0.4894388",
"0.48909062",
"0.48860666",
"0.48658276",
"0.48340738",
"0.48332742",
"0.4823626",
"0.4821578",
"0.48208937",
"0.48148796",
"0.4785063",
"0.4782801",
"0.47761306",
"0.47717148",
"0.475765",
"0.47555083",
"0.47263202",
"0.47231653",
"0.4717605",
"0.4703753",
"0.46891388",
"0.46723795",
"0.46677533",
"0.46612298",
"0.4657741",
"0.4657528",
"0.4656807",
"0.46535775",
"0.46333855",
"0.46328342",
"0.4617164",
"0.4615495",
"0.46138638",
"0.46112987",
"0.45987636",
"0.45858976",
"0.45858744",
"0.4582882",
"0.45772332",
"0.4573456",
"0.45666632",
"0.45637158",
"0.45611587",
"0.45563215",
"0.455353",
"0.4547138",
"0.4546246",
"0.45438",
"0.45423177",
"0.4536229",
"0.4535035",
"0.45307866",
"0.4527142",
"0.45264402",
"0.4525547",
"0.4524258",
"0.4514133",
"0.4511413"
] |
0.64277506
|
7
|
callseq: Kconv.toutf8(str) > string Convert str to UTF8 Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('wxm0', str).
|
def toutf8(str)
::NKF::nkf('-wm', str)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def toutf8; Kconv.toutf8(self) end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def to_utf8!; replace(to_utf8); end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def force_to_utf8(text)\n ActiveSupport::Multibyte::Unicode.tidy_bytes(text)\n end",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def to_utf8(raw_text)\n if raw_text.platform_id == 1 && raw_text.encoding_id == 0\n return raw_text\n else\n begin\n raw_text.encode(\"UTF-8\", \"UTF-16BE\")\n rescue\n raw_text\n end\n end\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def to_utf8(text)\n replaced = text\n unless replaced.nil?\n replaced = replaced.force_encoding(\"UTF-8\") if is_ascii_8bit?(replaced)\n replaced = cleanup_utf8(replaced)\n end\n replaced\n end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def to_utf8(s)\n return nil if s.nil?\n\n # Attempt to politely transcode the string.\n s.encode(\"UTF-8\").scrub\n rescue\n # If that doesn't work, then overwrite the existing encoding and\n # clobber any strange characters.\n s.force_encoding(\"UTF-8\").scrub\n end",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def convert_to_utf8(input)\n if input.is_a?(Hash)\n record = {}\n input.each do |key, value|\n record[convert_to_utf8(key)] = convert_to_utf8(value)\n end\n\n return record\n end\n return input.map { |value| convert_to_utf8(value) } if input.is_a?(Array)\n return input unless input.respond_to?(:encode)\n\n if @coerce_to_utf8\n input.encode(\n 'utf-8',\n invalid: :replace,\n undef: :replace,\n replace: @non_utf8_replacement_string)\n else\n begin\n input.encode('utf-8')\n rescue EncodingError\n @log.error 'Encountered encoding issues potentially due to non ' \\\n 'UTF-8 characters. To allow non-UTF-8 characters and ' \\\n 'replace them with spaces, please set \"coerce_to_utf8\" ' \\\n 'to true.'\n raise\n end\n end\n end",
"def utf8(string)\n string.force_encoding(Encoding::UTF_8)\n end",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def to_utf8(v)\n return v unless v.is_a?(String)\n return v if (enc = v.encoding) == (utf = Encoding::UTF_8)\n Encoding::Converter.new(enc, utf).convert(v) rescue v.dup.force_encoding(utf)\nend",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def utf8safe(text)\n require 'iconv'\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n return ic.iconv(text + ' ')[0..-2]\nend",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def params_toutf8\n all_toutf8!(params)\n end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def kana2kana(str1)\n result = []\n str2 = Kana2rom::hira_to_kata(str1)\n str3 = Kana2rom::kata_to_hira(str1)\n result << str1\n result << str2 if str2.length > 0 and str1 !=str2\n result << str3 if str3.length > 0 and str2 !=str3 and str3 != str1\n return result\n end",
"def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def reencode_string(input); end",
"def utf8(string)\n string.force_encoding('utf-8') unless string.nil?\n end",
"def toutf16; Kconv.toutf16(self) end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def tojis; Kconv.tojis(self) end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def unicode_filter_encode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_encode(str) : str\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def safe_encode_utf8(text)\n text.force_encoding('ASCII-8BIT').encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :universal_newline => true)\nend",
"def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def z_fix_charset\n Iconv.iconv('UTF-8', 'UTF-8', self).first.to_s\n end",
"def mb_charify(text)\n if RUBY_VERSION >= '1.9'\n text.dup\n elsif text.respond_to?(:mb_chars)\n text.frozen? ? text.dup.mb_chars : text.mb_chars\n else\n raise \"StringUtils: No unicode support for strings\"\n end\n end",
"def to_utf8(mixed)\n if mixed.kind_of? Array\n mixed.each {|elem| to_utf8(elem)}\n else mixed.kind_of? String\n charset = NKF.guess(mixed).name\n charset == \"UTF-8\" ? mixed : mixed.encode!(\"UTF-8\", charset)\n end\n mixed\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def clean(str)\n st = str.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')\n return st.encode('UTF-8', 'UTF-16')\nend",
"def iconv() end",
"def _encode_string(string)\n return string unless string.kind_of? String\n string.encode(\"UTF-8\", :undef => :replace, :invalid => :replace, :replace => \"?\")\n end",
"def utf8_safe\n encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def convert_to_utf8(hash)\n charset = hash[:charset]\n hash.map { |k, v| [k, v.dup.force_encoding(charset).encode(\"utf-8\")] }.to_h.symbolize_keys\n end",
"def normalize string\r\n begin\r\n string.dup.force_encoding('UTF-8')\r\n rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e\r\n # @todo Improve error handling\r\n Solargraph::Logging.logger.warn \"Normalize error: #{e.message}\"\r\n string\r\n end\r\n end",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def isutf8(str)\n RegexpUtf8.match( str )\n end",
"def fix_encoding(str)\n str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)\n str\nend",
"def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end",
"def unicode(str)\n\t\tRex::Text.to_unicode(str)\n\tend",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def quote_zenkaku(str)\n if str.mbchar? >= 0\n \"「\" + str + \"」\"\n else\n \"'\" + str + \"'\"\n end\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def try_utf8!(string, encoding = ::Encoding::UTF_8)\n return nil unless string\n string.force_encoding(::Encoding::ASCII_8BIT) unless string.force_encoding(encoding).valid_encoding?\n string\n end",
"def wide_string(str)\n # if given a nil string, assume caller wants to pass a nil pointer to win32\n return nil if str.nil?\n\n str.encode('UTF-16LE')\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def toeuc(str)\n ::NKF::nkf('-em', str)\n end",
"def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end",
"def decode_string(str)\n\nend",
"def plaintext_utf8(delim=\"\\n\")\n plaintext(delim).encode('UTF-8', invalid: :replace, undef: :replace, \n replace: '?')\n end",
"def encode_non_ascii_delimiter(str)\n return str if str.empty?\n # split would split the str without the specified delimiter while partition would output the delimiter as well\n partitioned_str = str.partition(' ') \n delimiter = 257.chr(Encoding::UTF_8)\n encoded_str = ''\n partitioned_str.each do |s|\n if s == \" \"\n encoded_str+= delimiter \n else\n encoded_str+= s\n end\n end\n encoded_str\nend",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def unify_voiced_katakana!(src)\n halfwidth =\n Characters::HALFWIDTH_VOICED_KATAKANA +\n Characters::HALFWIDTH_SEMI_VOICED_KATAKANA\n fullwidth =\n Characters::VOICED_KATAKANA +\n Characters::SEMI_VOICED_KATAKANA\n halfwidth.zip(fullwidth).inject(src) do |str, (h, f)|\n str.gsub!(h, f) || str\n end\n end"
] |
[
"0.8075774",
"0.7412787",
"0.67929983",
"0.67686206",
"0.67330045",
"0.6707624",
"0.6656892",
"0.655789",
"0.6537718",
"0.6502155",
"0.64538467",
"0.6434924",
"0.63885677",
"0.63417566",
"0.6299238",
"0.6287334",
"0.62757605",
"0.6227602",
"0.61906576",
"0.61903065",
"0.61630064",
"0.6152687",
"0.6147988",
"0.61429685",
"0.6118462",
"0.61128914",
"0.6091721",
"0.60833925",
"0.60833925",
"0.6050323",
"0.6050323",
"0.6025155",
"0.60173213",
"0.60151327",
"0.6013286",
"0.5957267",
"0.5953322",
"0.5943233",
"0.59398985",
"0.59385335",
"0.591675",
"0.59155923",
"0.5887423",
"0.5880062",
"0.58758837",
"0.58560795",
"0.5850356",
"0.5830462",
"0.57913107",
"0.57900476",
"0.5764623",
"0.57277006",
"0.5722308",
"0.57197195",
"0.57105196",
"0.5697006",
"0.5694594",
"0.56870633",
"0.5665297",
"0.5660317",
"0.5656535",
"0.56472516",
"0.56468195",
"0.56452715",
"0.56102645",
"0.55961627",
"0.5564533",
"0.5557173",
"0.5552288",
"0.5542153",
"0.553999",
"0.55243254",
"0.55198795",
"0.55024344",
"0.5495297",
"0.5494411",
"0.548856",
"0.5483255",
"0.54639",
"0.54618144",
"0.5458224",
"0.5451908",
"0.5448515",
"0.5447467",
"0.5439702",
"0.5435733",
"0.54294324",
"0.54245543",
"0.54225194",
"0.5409155",
"0.5386438",
"0.5385602",
"0.5369929",
"0.5344211",
"0.5334369",
"0.5325715",
"0.5308354",
"0.5296186",
"0.528915",
"0.528333"
] |
0.77158505
|
1
|
callseq: Kconv.toutf16(str) > string Convert str to UTF16 Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('w16xm0', str).
|
def toutf16(str)
::NKF::nkf('-w16m', str)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_utf16(str)\n if str.respond_to?(:encode)\n str.encode('UTF-16BE')\n else\n Iconv.conv('UTF-16BE', 'UTF-8', str)\n end\n end",
"def toutf16; Kconv.toutf16(self) end",
"def get_utf16_of(character)\n character.encode('UTF-16BE').unpack('H*').first.upcase\nend",
"def to_utf16\r\n Iconv.iconv(\"utf-16LE\", \"utf-8\", self).first + \"\\x00\\x00\"\r\n end",
"def from_utf16\r\n ret = Iconv.iconv(\"utf-8\", \"utf-16le\", self).first\r\n if ret[-1] == 0\r\n ret = ret[0..-2]\r\n end\r\n end",
"def clean(str)\n st = str.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')\n return st.encode('UTF-8', 'UTF-16')\nend",
"def from_utf16_buffer\r\n self[0..index(\"\\0\\0\\0\")+2].from_utf16\r\n end",
"def wide_string(str)\n # if given a nil string, assume caller wants to pass a nil pointer to win32\n return nil if str.nil?\n\n str.encode('UTF-16LE')\n end",
"def str_to_uni_z(str)\n enc = str.encode('UTF-16LE').force_encoding('binary')\n enc += \"\\x00\\x00\"\n return enc\n end",
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def unicode_text(pdf, str, options={})\n pdf.text(e(\"\\xfe\\xff#{str}\", :encoding => 'UTF-16BE'), options) # start Unicode UTF-16BE encoding\n end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def read_string(data, offset, length, encoding)\n if \"UTF-16\".casecmp(encoding) == 0\n out = data[offset, length].unpack('v*').pack('U*')\n else\n out = data[offset, length].unpack('C*').pack('U*')\n end\n return out\n end",
"def uniz_to_str(uniz)\n uniz.force_encoding('UTF-16LE').encode('UTF-8')\n end",
"def uC\n NWRFCLib::Cutf16le_to_utf8.iconv(self).strip\n end",
"def uC\n self.force_encoding('UTF-16LE').encode('UTF-8').strip\n end",
"def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end",
"def fix_utf_errors\n self.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')\n end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def toutf8; Kconv.toutf8(self) end",
"def write_utf16be_string(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return -1 if (args.size < 3) # Check the number of args\n\n record = 0x00FD # Record identifier\n length = 0x000A # Bytes to follow\n\n row = args[0] # Zero indexed row\n col = args[1] # Zero indexed column\n strlen = args[2].length\n str = args[2]\n xf = xf_record_index(row, col, args[3]) # The cell format\n encoding = 0x1\n str_error = 0\n\n # Check that row and col are valid and store max and min values\n return -2 if check_dimensions(row, col) != 0\n\n # Limit the utf16 string to the max number of chars (not bytes).\n if strlen > 32767* 2\n str = str[0..32767*2]\n str_error = -3\n end\n\n num_bytes = str.length\n num_chars = (num_bytes / 2).to_i\n\n # Check for a valid 2-byte char string.\n raise \"Uneven number of bytes in Unicode string\" if num_bytes % 2 != 0\n\n # Change from UTF16 big-endian to little endian\n str = str.unpack('n*').pack('v*')\n\n # Add the encoding and length header to the string.\n str_header = [num_chars, encoding].pack(\"vC\")\n str = str_header + str\n\n unless @str_table[str]\n @str_table[str] = str_unique\n add_str_unique(1)\n end\n\n add_str_total(1)\n \n header = [record, length].pack(\"vv\")\n data = [row, col, xf, @str_table[str]].pack(\"vvvV\")\n\n # Store the data or write immediately depending on the compatibility mode.\n if @compatibility != 0\n tmp = []\n tmp[col] = header + data\n @table[row] = tmp\n else\n append(header, data)\n end\n\n return str_error\n end",
"def to_utf8(raw_text)\n if raw_text.platform_id == 1 && raw_text.encoding_id == 0\n return raw_text\n else\n begin\n raw_text.encode(\"UTF-8\", \"UTF-16BE\")\n rescue\n raw_text\n end\n end\n end",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def decode(base16_string)\n base16_string.to_i(BASE)\n end",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def codepoint(str)\n return str.gsub(/\\\\u[\\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }\n end",
"def clean_text(text)\n if RUBY_VERSION >= \"1.9\"\n\n # First, force to UTF-8 encoding\n if text.encoding.name != \"UTF-8\" \n text = text.force_encoding('UTF-8')\n end\n\n # If we still don't have a valid string, re-encode\n if !text.valid_encoding?\n text = text.encode('UTF-16', invalid: :replace, undef: :replace).encode('UTF-8')\n end\n\n end\n text\n end",
"def convert(str)\n\t\t@result=convert_han(convert_words(str))\n\t\t# @result=convert_words(str)\n\t\t@result.gsub!(\" #%\",\"\")\n\t\t@result.gsub!(\"%# \",\"\")\n\t\t@result\n\tend",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend",
"def read_binary_unicode_string(fname,fd,length)\n # The problem is: we get the length of the string IN CHARACTERS;\n # since a char in UTF-16 can be 16 or 32 bit long, we don't really know\n # how long the string is in bytes\n buff = fd.read(2*length)\n\n @unique_table[buff] = true unless @unique_table.has_key?(buff)\n return CFString.new(Binary.charset_convert(buff,\"UTF-16BE\",\"UTF-8\"))\n end",
"def sanitize_string(string)\n return string.encode(\"UTF-16BE\", :invalid=>:replace, :undef => :replace, :replace=>\"?\")\n .encode(\"UTF-8\")\n .gsub(/[\\u0080-\\u009F]/) {|x| x.getbyte(1).chr.force_encoding('windows-1252').encode('utf-8') }\n .gsub(/\\\"/, \"\\\\\\\"\") # escape double quotes in string\n end",
"def convert_to_unicode(char)\n \n if char =~ /\\A\\\\/\n char = char.gsub(\"\\\\\",\"\") # Fix double escaping\n char = [char[0..-1].to_i(16)].pack(\"U\")\n end\n \n raise ArgumentError, \"You can only pass one character\" if char.size > 1\n \n char\n end",
"def kan2n2(s)\n case s.length\n when 1\n '〇一二三四五六七八九十'.index(s)\n when 2\n '〇一二三四五六七八九十'.index(s[1]) + 10\n else\n raise '21以上の数値に対応していません'\n end\n end",
"def iconv() end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def get_unicode_of(character)\n character.unpack('U*').first.to_s(16).rjust(4, '0').upcase\nend",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def unicode(str)\n\t\tRex::Text.to_unicode(str)\n\tend",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def convert(string)\n\t# Adding space to handle words that end in a unicode character\n\tstring += \" \"\n\n\tword = \"\"\n\tunicode = false\n\tuni_string = \"\"\n\n\t# puts \"Starting each char...\"\n\tstring.each_char do |char|\n\t\t\n\t\t# puts \"char: #{char}\"\n\n\t\tif char != \"\\\\\" and !unicode\n\t\t\t# puts \"Adding #{char} to word\"\n\t\t\tword += convert_char(char)\n\n\t\telsif char == \"\\\\\"\n\t\t\t# puts \"Starting unicode string\"\n\t\t\tuni_string = \"\\\\\"\n\t\t\tunicode = true\n\n\t\telsif char != \" \" and unicode\n\t\t\t# puts \"Putting #{char} in unicode string: #{uni_string}\"\n\t\t\tuni_string += char\n\n\t\telsif unicode and char == \" \"\n\t\t\t# puts \"Found end of unicode string: #{uni_string}\"\n\t\t\tword += convert_char(uni_string)\n\t\t\tuni_string = \"\"\n\t\t\tunicode = false\n\t\telse\n\t\t\tputs \"Not sure what to do with #{char}\"\n\t\tend\n\tend\n\n\t# Strip to remove extra spaces\n\treturn word.strip\n\nend",
"def write_utf16le_string(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return -1 if (args.size < 3) # Check the number of args\n\n record = 0x00FD # Record identifier\n length = 0x000A # Bytes to follow\n\n row = args[0] # Zero indexed row\n col = args[1] # Zero indexed column\n str = args[2]\n format = args[3] # The cell format\n\n # Change from UTF16 big-endian to little endian\n str = str.unpack('n*').pack(\"v*\")\n\n return write_utf16be_string(row, col, str, format)\n end",
"def unicode_normalize!(form = :nfc)\n require 'unicode_normalize/normalize.rb' unless defined? UnicodeNormalize\n # String.send(:define_method, :unicode_normalize!, ->(form = :nfc) { replace(unicode_normalize(form)) } )\n replace(unicode_normalize(form))\n end",
"def write_word16_native(val)\n pw(val, 'S')\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def kana2kana(str1)\n result = []\n str2 = Kana2rom::hira_to_kata(str1)\n str3 = Kana2rom::kata_to_hira(str1)\n result << str1\n result << str2 if str2.length > 0 and str1 !=str2\n result << str3 if str3.length > 0 and str2 !=str3 and str3 != str1\n return result\n end",
"def text_conv(outform, inform, intext)\n\treturn Iconv.iconv(outform, inform, intext).join\nend",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def iconv\n @iconv ||= Iconv.new(vk_charset, 'UTF-8')\n end",
"def u16\n next_bytes(2).unpack(\"S>\").first\n end",
"def unify_voiced_katakana!(src)\n halfwidth =\n Characters::HALFWIDTH_VOICED_KATAKANA +\n Characters::HALFWIDTH_SEMI_VOICED_KATAKANA\n fullwidth =\n Characters::VOICED_KATAKANA +\n Characters::SEMI_VOICED_KATAKANA\n halfwidth.zip(fullwidth).inject(src) do |str, (h, f)|\n str.gsub!(h, f) || str\n end\n end",
"def encode(unicode)\n unicode.gsub!('U+', '\\u')\n\n unicode.gsub(/\\\\u[\\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }\n end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def word16(bytes_a, bytes_b)\n (bytes_a << 8) | bytes_b\n end",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def shortxlunicodestring(io)\n cch, flags = io.read(2).unpack('CC')\n _read_unicodestring(io, cch, flags)\n end",
"def translate_data(data)\n if data[0..3] == \"\\x4c\\x6f\\xa7\\x94\"\n # EBCDIC\n data = _ebcdic_to_ascii(data)\n elsif data[0..3] == \"\\x00\\x3c\\x00\\x3f\"\n # UTF-16BE\n data = uconvert(data, 'utf-16be', 'utf-8')\n elsif data.size >= 4 and data[0..1] == \"\\xfe\\xff\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16BE with BOM\n data = uconvert(data[2..-1], 'utf-16be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x3f\\x00\"\n # UTF-16LE\n data = uconvert(data, 'utf-16le', 'utf-8')\n elsif data.size >=4 and data[0..1] == \"\\xff\\xfe\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16LE with BOM\n data = uconvert(data[2..-1], 'utf-16le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\x00\\x3c\"\n # UTF-32BE\n data = uconvert(data, 'utf-32be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x00\\x00\"\n # UTF-32LE\n data = uconvert(data, 'utf-32le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\xfe\\xff\"\n # UTF-32BE with BOM\n data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')\n elsif data[0..3] == \"\\xff\\xfe\\x00\\x00\"\n # UTF-32LE with BOM\n data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')\n elsif data[0..2] == \"\\xef\\xbb\\xbf\"\n # UTF-8 with BOM\n data = data[3..-1]\n else\n # ASCII-compatible\n end\n return data\nend",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def decode_word(text)\n return text unless text =~ /=\\?([^?]+)\\?(.)\\?([^?]*)\\?=/\n \n charset, method, encoded_string = $1, $2, $3\n \n # Strip out the RFC2231 language specification if there is one.\n charset = $1 if charset =~ /^([^\\*]+)\\*?(.*)$/\n \n # Quoted-printable in RFC2047 substitutes spaces with underscores.\n encoded_string.tr!('_', ' ') if method.downcase == 'q'\n \n encoded_string.decode_mime(method).iconv('utf-8', charset)\n end",
"def escape_string(str)\n replacement = {\n ':)' => \"\\n\", ':>' => \"\\t\", ':o' => \"\\a\", ':\"' => '\"', '::' => ':'\n }\n str\n .gsub(/:[\\)>o\":]/, replacement)\n .gsub(/:\\(([0-9a-fA-F]+)\\)/) do |match|\n $1.to_i(16).chr(Encoding::UTF_8)\n end\n .gsub(/:\\[(.+?)\\]/) do |match|\n code = Unicode::DATA[$1]\n if code\n code.chr(Encoding::UTF_8)\n else\n $stderr.puts(\"Unknown Unicode normative name: #{$1}\")\n match\n end\n end\n end",
"def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend",
"def decoder(string)\n string.gsub(/(WUB)+/, ' ').strip\nend",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def utf8safe(text)\n require 'iconv'\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n return ic.iconv(text + ' ')[0..-2]\nend",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def set(string)\n self.data = string.encode(Encoding::UTF_16BE)\n end",
"def uint16()\n _uint16(\"uint16\")\n end",
"def unescape(str)\n # Escape all the things\n str.gsub(/\\\\(?:([#{UNESCAPES.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\' then '\\\\' else UNESCAPES[$1] end\n elsif $2 # escape \\u0000 unicode\n [\"#$2\".hex].pack('U*')\n elsif $3 # escape \\0xff or \\xff\n [$3].pack('H2')\n end\n }\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n # Escape all the things\n str.gsub(/\\\\(?:([#{chars.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\'\n then '\\\\'\n else\n chars[$1]\n end\n elsif $2\n [\"#$2\".hex].pack('U*')\n elsif $3\n [$3].pack('H2')\n end\n }\n end",
"def encode(str)\n\tswap_raw = \"GA-DE-RY-PO-LU-KI\".reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.split(\"-\")\n\tencoder = Hash.new\n\tswap_raw.each { |pair| encoder[pair[0]] = pair[1] }\n\tencoded_string = \"\"\n\tputs encoder\n\tfor char in str.split(\"\")\n\t\tif encoder.key?(char) #correct?\n\t\t\tencoded_string += encoder[char]\n\t\telse\n\t\t\tencoded_string += char\n\t\tend\n\tend\n\treturn encoded_string\nend",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def convert_text!(text, error_handler)\n text = AnselToUnicode.new(error_handler, true).convert(text) if convert_marc8_to_utf8?\n\n # Turn Horizon's weird escaping into UTF8: <U+nnnn> where nnnn is a hex unicode\n # codepoint, turn it UTF8 for that codepoint\n if settings[\"horizon.destination_encoding\"] == \"UTF8\" &&\n (settings[\"horizon.codepoint_translate\"].to_s == \"true\" ||\n settings[\"horizon.character_reference_translate\"].to_s == \"true\")\n\n regexp = if settings[\"horizon.codepoint_translate\"].to_s == \"true\" && settings[\"horizon.character_reference_translate\"].to_s == \"true\"\n # unicode codepoint in either HTML char reference form OR\n # weird horizon form. \n /(?:\\<U\\+|&#x)([0-9A-Fa-f]{4})(?:\\>|;)/\n elsif settings[\"horizon.codepoint_translate\"].to_s == \"true\"\n # just weird horizon form\n /\\<U\\+([0-9A-Fa-f]{4})\\>/\n else # just character references\n /&#x([0-9A-Fa-f]{4});/\n end\n \n text.gsub!(regexp) do\n [$1.hex].pack(\"U\")\n end\n end\n\n # eliminate illegal control chars. All ASCII less than 0x20\n # _except_ for four legal ones (including MARC delimiters). \n # http://www.loc.gov/marc/specifications/specchargeneral.html#controlfunction\n # this is all bytes from 0x00 to 0x19 except for the allowed 1B, 1D, 1E, 1F. \n text.gsub!(/[\\x00-\\x1A\\x1C]/, '')\n\n return text\n end",
"def sterilize(str)\n str.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n str.gsub!(0x00.chr,'[NUL]')\n str.gsub!(0x01.chr,'[SOH]')\n str.gsub!(0x02.chr,'[STX]')\n str.gsub!(0x03.chr,'[ETX]')\n str.gsub!(0x04.chr,'[EOT]')\n str.gsub!(0x05.chr,'[ENQ]')\n str.gsub!(0x06.chr,'[ACK]')\n str.gsub!(0x07.chr,'[BEL]')\n # 0x08 is backspace\n # 0x09 is TAB\n # 0x10 is line feed\n str.gsub!(0x0B.chr,'[VT]')\n # 0x0c is form feed\n # 0x0d is carriage return\n str.gsub!(0x0E.chr,'[SO]')\n str.gsub!(0x0F.chr,'[SI]')\n str.gsub!(0x10.chr,'[DLE]')\n str.gsub!(0x11.chr,'[DC1]')\n str.gsub!(0x12.chr,'[DC2]')\n str.gsub!(0x13.chr,'[DC3]')\n str.gsub!(0x14.chr,'[DC4]')\n str.gsub!(0x15.chr,'[NAK]')\n str.gsub!(0x16.chr,'[SYN]')\n str.gsub!(0x17.chr,'[ETB]')\n str.gsub!(0x18.chr,'[CAN]')\n str.gsub!(0x19.chr,'[EM]')\n str.gsub!(0x1a.chr,'[SUB]')\n str.gsub!(0x1C.chr,'[FS]')\n str.gsub!(0x1D.chr,'[GS]')\n str.gsub!(0x1E.chr,'[RS]')\n str.gsub!(0x1F.chr,'[US]')\n str\n end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def convert_string string\n string\n end",
"def get_U16_field(field_name)\n\t\tend",
"def force_utf32=(_arg0); end",
"def force_utf32=(_arg0); end"
] |
[
"0.8049237",
"0.78257257",
"0.7342039",
"0.7328037",
"0.7024019",
"0.64593583",
"0.62446725",
"0.61012155",
"0.59815633",
"0.58657616",
"0.5748576",
"0.56195813",
"0.5603677",
"0.5586325",
"0.5581748",
"0.5555502",
"0.55537474",
"0.5509358",
"0.54509634",
"0.5442488",
"0.5406557",
"0.54004425",
"0.53947157",
"0.5356743",
"0.5343374",
"0.5309423",
"0.5299885",
"0.52798325",
"0.5255502",
"0.52096605",
"0.5189875",
"0.5166111",
"0.51656103",
"0.51214546",
"0.5114479",
"0.5109748",
"0.50484216",
"0.50323683",
"0.5002146",
"0.49978933",
"0.4994761",
"0.49857447",
"0.49481133",
"0.4923568",
"0.49205783",
"0.49119568",
"0.49111667",
"0.48769656",
"0.48205298",
"0.48126367",
"0.48124257",
"0.48085815",
"0.4748361",
"0.4746111",
"0.47456113",
"0.4735064",
"0.4719751",
"0.47187677",
"0.46896574",
"0.46864408",
"0.46686298",
"0.46644127",
"0.46600315",
"0.4649582",
"0.46345183",
"0.46291137",
"0.4612575",
"0.46054602",
"0.46007046",
"0.45953074",
"0.45941898",
"0.45883775",
"0.4582762",
"0.456128",
"0.4558974",
"0.4554331",
"0.4546658",
"0.45453718",
"0.45391074",
"0.45359206",
"0.45294335",
"0.4525472",
"0.45206144",
"0.45127872",
"0.45119232",
"0.45094636",
"0.45091116",
"0.45091116",
"0.44864404",
"0.4485495",
"0.44822082",
"0.4476272",
"0.44649962",
"0.4456966",
"0.4456313",
"0.4449236",
"0.44481242",
"0.44274846",
"0.440924",
"0.440924"
] |
0.86275566
|
0
|
guess callseq: Kconv.guess(str) > integer Guess input encoding by NKF.guess2
|
def guess(str)
::NKF::guess(str)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def guess_old(str)\n ::NKF::guess1(str)\n end",
"def score_string(guess)\n results = Array.new()\n guess.split('').each_with_index do |char, index|\n if char == @code[index]\n results[index] = :h\n elsif @code.include? char\n results[index] = :n\n else\n results[index] = :m\n end\n end\n results\n end",
"def correct_guess(guess)\n end",
"def make_guess(_placeholder, _placeholder2)\n get_code('guess')\n end",
"def read_guess\n print \"Pretty please enter your guess: \"\n gets.to_i\nend",
"def init_guess\n init_guess_table = { 1 => \"A\", 2 => \"A\", 3 => \"A\", 4 => \"A\", 5 => \"S\",\n 6 => \"E\", 7 => \"E\", 8 => \"E\", 9 => \"E\", 10 => \"E\",\n 11 => \"E\", 12 => \"E\", 13 => \"I\", 14 => \"I\", 15 => \"I\",\n 16 => \"I\", 17 => \"I\", 18 => \"I\", 19 => \"I\", 20 => \"I\",\n 21 => \"O\", 22 => \"O\", 23 => \"O\", 24 => \"O\", 28 => \"I\" }\n @last_guess = init_guess_table[@last_feedback.length]\n end",
"def guess!(letter)\n end",
"def compare_guess(guess, str)\n#compare_guess stopped working when user interface added :(\n @guess_count = 0\n index = 0\n @result = \"\"\n while index < @str.length\n @guess.each_char do\n if @guess[index] == str[index]\n @result << @guess[index]\n else\n @result << \"-\"\n end\n @guess_count += 1\n index += 1\n end\n end\n return @result\nend",
"def guess(guess)\n \t@guess = guess\n\n \tguess_response\n end",
"def ask_for_guess\n @guess_count += 1\n @guess = get_code(\"Please enter your guess in the format 'color color color color'(to list available color options enter 'options'):\")\n end",
"def guess(guess)\n \t@guess = guess\n \treturn :correct if solved?\n \t@guess > @answer ? :high : :low\n end",
"def ask_guess\n guess = gets.chomp.downcase\n check_guess_is_valid?(guess) ? guess : ask_guess\n end",
"def getguess guess\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t if guess.length == 1\r\n\t\t\t\t if check_repeated_choice guess\r\n\t\t\t\t @message = \"Already guessed this letter!\"\r\n\t\t\t\t if @console\r\n\t\t\t\t\t\t\t\t@output.puts \"#{@message}\"\r\n\t\t\t\t\t\t\t\tword_input = take_user_word_input\r\n\t\t\t\t\t\t\t\tvalid = false\r\n\t\t\t\t\t\t\t while !valid do\r\n\t\t if validate_input word_input\r\n\t\t valid = true\r\n\t\t else\r\n\t\t @output.puts \"Invalid input\"\r\n\t\t word_input = take_user_word_input\r\n\t\t end\r\n\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif check_enter word_input\r\n\t\t\t\t\t\t\t\t\t\t@break_flag = true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t getguess word_input\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t end\r\n\t\t\t\t else\r\n\t\t\t\t \t@message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @guess_counter+=1\r\n\t\t\t\t check_guess guess\r\n\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t end\r\n\t\t\t\t success = check_phrase @resulta.join(',').gsub(\",\",\"\")\r\n\t\t\t\t return success ? true : false\r\n\t\t\t\telse\r\n\t\t\t\t\t if check_phrase guess\r\n\t\t\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t\t\t i = 0\r\n\t\t\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\t\t\t@resulta[i] = phrase[i]\r\n\t\t\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t return true\r\n\t\t\t\t\t else\r\n\t\t\t\t\t\t @num_guessed = 0\r\n\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t @guess_counter+=1\r\n\t\t\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t\t\t return false\r\n\t\t\t\t\t end\r\n\t\t\t\tend\r\n\t\t\t\tend",
"def get_guess(r)\n\tputs \"Guess the number from 1-10\"\n\tguess = gets\n\tcheck_guess(r, guess)\nend",
"def incorrect_guess(guess)\n end",
"def guess\n puts \"Write down a guess.\"\n @guess_code.make_seq\n @code_seq = guess_code.sequence\n end",
"def calculate_guess(guess, analisis)\n if analisis.nil?\n @all_guesses = (1111..6666).map(&:to_s).reject { |g| g.include?('0') }\n '1122'\n else\n @all_guesses.delete(guess)\n @all_guesses.select! { |g| 4 - (g.chars - guess.chars).size == analisis.count('?') + analisis.count('!') }\n @all_guesses.select! do |g|\n g.chars.select.with_index { |c, idx| c == guess.chars[idx] }.size == analisis.count('!')\n end\n @all_guesses[0]\n end\n end",
"def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end",
"def gets_user_guess\n @guess = gets.strip.downcase\n generate_new_card\n end",
"def get_hint(secret, guess)\n bulls = 0\n cows = 0\n\n tracker = Hash.new(0)\n secret.each_char { |char| tracker[char] += 1 }\n guess.each_char.with_index do |char, i|\n if secret[i] == guess[i]\n bulls += 1\n if tracker[char] > 0\n tracker[char] -= 1\n else\n cows -= 1\n end\n elsif tracker[char] > 0\n tracker[char] -= 1\n cows += 1\n end\n end\n\n \"#{bulls}A#{cows}B\"\nend",
"def guess\n letters = @possible_letters.collect {|letter| [ score_for(letter),letter ]}\n letter = letters.min {|letter1,letter2| letter1 <=> letter2 }\n letter[1]\n end",
"def guess\n\t\tcollect_words_of_length\n\t\tputs \"Already guessed letters by computer: #{@guessed_letters}\"\n\t\t@guessing_letter = nil\n\t\twhile @guessing_letter == nil || invalid?(@guessing_letter)\n\t\t\t@guessing_letter = guessing_letter\n\t\tend\n\t\t@guessed_letters << @guessing_letter\n\t\t@guessing_letter\n\tend",
"def player_guess\n puts \"Turn #{@turn} - Put your guess in below:\"\n begin\n guess = gets.chomp\n guess_code = Code.new(guess.upcase)\n rescue StandardError => e\n puts e\n retry\n end\n guess_code\n end",
"def capture_guess(user_input)\n @guess = user_input.scan(/./)\n end",
"def input_guess\n puts 'Input a code!'\n begin\n input = gets\n parse(input)\n rescue NoMethodError\n input_error\n end\n end",
"def decode_strong(guess, code)\n guess.each_with_index.reduce(0) do |count, (code_peg, index)|\n if code_peg && code[index] == code_peg\n count += 1\n code[index] = nil\n guess[index] = nil\n end\n count\n end\n end",
"def return_guess\n 5\n end",
"def guessbrian(guess)\n #error checking\n if guess == nil || guess == \"\" || guess =='%'\n throw :guess\n end\n #initialize variables and split\n guess = guess.downcase\n flag = 0\n splitWord = @word\n splitWord = splitWord.downcase.split(\"\")\n #check and assign\n splitWord.each { |x|\n if x == guess\n flag = 1\n end\n }\n if flag == 1\n if @guesses == guess\n return false\n else\n @guesses << guess\n return true\n end\n else\n if guess == guess.gsub(/[^A-Za-z]/, '') && guess != @wrong_guesses\n @wrong_guesses << guess\n return true\n else\n return false\n end\n end\n end",
"def word_to_guess (user_word)\n\t\tuser_word.downcase!\n\t\t@number_guess = user_word.length\n\t\t@answer_word = user_word.split(\"\")\n\tend",
"def check_guess guess\r\n\t\t\t\t @resultb.push(guess)\r\n\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t i = 0\r\n\t\t\t\t @num_guessed = 0\r\n\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\tif phrase[i] == guess\r\n\t\t\t\t\t\t\t\t @resulta[i] = guess\r\n\t\t\t\t\t\t\t\t @num_guessed += 1\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif @num_guessed > 0\r\n\t\t\t\t\t\t\t\t@score += (@reward.to_i * @num_guessed)\r\n\t\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t\t\tend\r\n\t\t end",
"def check_guess(input)\n @guessed_letters.push(input)\n if @secret_word.match?(input)\n @secret_word.split(//).each_with_index { |char, index| @guessed_word[index] = char if char == input }\n else\n puts 'Incorrect'\n @guesses_left -= 1\n @wrong_letters.push(input)\n end\n end",
"def guess\n # takes human input and stores guess\n puts 'Pick a letter'\n self.human_guess = gets.chomp\n end",
"def make_guess(secret_code)\n if guess == [0, 0, 0, 0]\n first_guess\n return guess\n end\n reduce_solution_set(secret_code)\n update_guess\n guess\n end",
"def check_guess(guess)\n # checks human guess, displays discovered, and return if letter found\n letter_found = false\n self.secret_word.split('').each_with_index do |chr, ind|\n if chr == guess\n self.currently_discovered[ind] = chr\n letter_found = true\n end\n end\n p self.currently_discovered\n letter_found\n end",
"def check_guess(guess)\n bulls = 0\n cows = 0\n guess.upcase.split('').each_with_index do |letter, idx|\n if @dictionary.keys.include?(letter)\n if letter == @dictionary.keys[idx]\n bulls += 1\n else\n cows += 1\n end\n end\n end\n @guess_count += 1\n { guess: guess, cows: cows, bulls: bulls, score: (bulls * 5 + cows) }\n end",
"def guess_letter(letter)\n\t\tif @ans_word.include?(letter)\n\t\t\ti = @ans_word.index(letter)\n\t\t\t@guess.insert(i, letter)\n\t\t\t@guess.pop\n\t\t\tputs \"Good! You are getting closer: #{@guess*\"\"}\"\n\t\telse\n\t\t\tputs \"sorry, guess again\"\n\t\tend\n\tend",
"def choose_guess\n if @num_guesses.zero?\n Code.new([1, 1, 2, 2])\n else\n @valid_codes.sample\n end\n end",
"def get_hint(secret, guess)\r\n hash1 = Hash.new(0)\r\n hash2 = Hash.new(0)\r\n bulls = 0\r\n cows = 0\r\n \r\n secret.each_char.with_index do |char, idx| \r\n hash1[char] += 1\r\n bulls += 1 if secret[idx] == guess[idx]\r\n end\r\n \r\n guess.each_char {|char| hash2[char] += 1}\r\n hash1.keys.each {|key| cows += [hash1[key], hash2[key]].min}\r\n \r\n bulls.to_s + \"A\" + (cows-bulls).to_s + \"B\"\r\nend",
"def get_input\n if previous_guess\n second_guess\n else\n first_guess\n end\n end",
"def bad_guess_count()\r\n\t\t# TODO: fill in method body\r\n\t\treturn -1\r\n\tend",
"def make_guess\n\tputs \"#{ @name } is thinking...\"\n\tif @first_guess==[]\n\t return make_first_guess\n\telse\n\t # update the last guess, get a random sample from the set of available codes\n\t sleep 1\n\t @last_guess = @set_of_codes.sample \n\t return @last_guess\n\tend\n end",
"def give_feedback(guess)\n guess.split('').each_with_index do |val, index|\n if val == @code[index]\n print 'M'\n elsif @code.split('').include?(val)\n print 'O'\n else\n print 'X'\n end\n end\n puts\n end",
"def guess_params\n params.require(:guess).permit(:text, :card_id, :round_id)\n end",
"def bulls(guess)\n guess.split(//).zip(@word.split(//)).inject(0) { | r, (letter_1, letter_2) | letter_1 == letter_2 ? r + 1 : r }\n end",
"def guess(text, meta)\n nil\n end",
"def get_guess\n\t\twhile true\n\t\t\tguess = gets.chomp.upcase\n\t\t\treturn :save if guess == \"SAVE\" || guess == \"'SAVE'\"\n\t\t\tif guess.between?('A', 'Z') && guess.length == 1\n\t\t\t\tif @hits.include?(guess) || @misses.include?(guess)\n\t\t\t\t\tprint \"You guessed '#{ guess }' already. Select another letter: \"\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\treturn guess\n\t\t\tend\n\t\t\tprint \"Enter one letter for guess (or 'save' to save game): \"\n\t\tend\n\tend",
"def guess(word_pattern, possible_words)\r\n all_words = possible_words.flatten\r\n guess = $avail_letters.sort_by {|c|\r\n all_words.select{|w|w.index c}.length}.last\r\n $avail_letters -= [guess]\r\n $guess = guess\r\nend",
"def guess(guess)\r\n\t\t# Make sure the guess is either a letter or the whole word\r\n\t\tif guess.length != 1 && guess.length != @win_word.length\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp \"Guess a letter, or the complete word!\"\r\n\t\t# check for repeated guesses\r\n\t\telsif @past_guesses.include? guess\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"You guessed that already!\"\r\n\t\t# check if they guessed the entire word correctly\r\n\t\telsif guess == @win_word\r\n\t\t\twin\r\n\t\t# if the letter is not in the word\r\n\t\telsif !@win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tif @remaining_guesses == 1\r\n\t\t\t\tlose\r\n\t\t\telse\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"Sorry, try again!\"\r\n\t\t\tend\r\n\t\t# if the letter is in the word\r\n\t\telsif @win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tupdate_hint(guess)\r\n\t\t\tif @hint_str == @win_word\r\n\t\t\t\twin\r\n\t\t\telse\r\n\t\t\t\tp \"Nice guess!\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tp \"Error\"\r\n\t\tend\r\n\r\n\tend",
"def check_guess(letter)\n\t\tputs \"Please enter the correct positions where the guess occurs\"\n\t\tmatches = gets.chomp.split(\" \")\n\t\tmatches.map { |match| match.to_i }\n\tend",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def new_guess\n @possibleCodes = if @possibleCodes.empty?\n @possibleCodesAll.map do |i|\n if $game.check_silent(i, $game.lastGuess) == $game.match\n i\n else\n i = nil\n end\n end.compact!\n\n else\n @possibleCodes.map do |i|\n if $game.check_silent(i, $game.lastGuess) == $game.match\n i\n else\n i = nil\n end\n end.compact!\n\n end\n @possibleCodes.sample.split('').map!(&:to_i)\n end",
"def guess(word_pattern, possible_words)\n all_words = possible_words.flatten\n guess = $avail_letters.sort_by {|c|\n all_words.select{|w|w.index c}.length}.last\n $avail_letters -= [guess]\n $guess = guess\nend",
"def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end",
"def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end",
"def guess(g)\n return false unless valid?(g)\n @turns -= 1\n answer = []\n ges = g.clone\n tmp = @code.clone\n\n ges.size.times do |index|\n if ges[index] == tmp[index]\n answer << '+'\n tmp[index] = '0'\n ges[index] = 'a'\n end\n end\n \n tmp.each_char do |value| \n if ges.include? value\n answer << '-'\n ges.sub!(value, 'a')\n end\n end\n\n ret = 1 if answer == ['+', '+', '+', '+']\n \n ret ||= 0 if @turns == 0 \n ret ||= answer.join\n @log << {a: ret, guess: g}\n ret\n end",
"def guess_hidden_word\n puts (\"Enter your guess: \")\n end",
"def decode_weak(guess, code)\n guess.compact.each.reduce(0) do |count, code_peg|\n index = code.find_index(code_peg)\n if index\n count += 1\n code[index] = nil\n end\n count\n end\n end",
"def good_guess?(intgr)\nif intgr == 42\n return true\nelse return false\nend\nend",
"def number_decoder( input )\n output = \"\"\n \n # build number to letter hash\n translator = Hash.new\n letters = ('A'..'Z').to_a\n letters.each_index{|i| translator [(i+1).to_s] = letters[i] }\n \n input.each(' ') do |nibble|\n\n \n num = nibble.strip.to_i\n if (num == 0 or num.nil?) then output << \" \"\n else\n case (num-1)/26\n when 0 then output << translator[num.to_s]# + ' '\n when 1 then output << translator[(num - 26).to_s]\n end\n end\n end\n \n output\nend",
"def set_guess\n @guess = Array.new(@word.length, '*')\n end",
"def guess(text, meta)\n @proc.call(text)\n end",
"def expect_guess\n print \"Guess ##{turn}. What's your code? \"\n input = gets.chomp\n throw :quit if input == \"q\"\n \n if valid_input? input\n self.last_guess = Code.parse(input)\n puts \"Your guess was #{last_guess}.\"\n else\n puts \"Please enter 4 valid colors.\"\n expect_guess\n end\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def guess(letters)\n raise ArgumentError if letters == \"\"\n raise ArgumentError if letters !~ %r{\\w}\n letters.downcase!\n if @word.include?(letters) \n !@guesses.include?(letters) ? @guesses << letters : false\n\n else\n @wrong_guesses.include?(letters) ? false : wrong_guesses << letters \n end\n end",
"def guess(letter)\n # raise an execption\n # raise will 'break' the method if valid_guess? == false\n raise InvalidGuessException.new(\"Invalid guess!\") unless valid_guess?(letter)\n if word_has?(letter)\n \tput_letter_on_board(letter)\n else\n wrong_letter(letter) if !@guesses.include? letter\n end\n end",
"def guess(char)\n \n #Check if letter guessed is nil or empty or not a letter and throw error\n if char == nil \n raise ArgumentError\n elsif char == \"\"\n raise ArgumentError\n elsif !char.match(/[A-Za-z]/)\n raise ArgumentError\n end\n \n #Convert character to downcase to make it case insensitive.\n #Check if letter has already been guessed in correct or wrong guess buckets\n char = char.downcase\n if @guesses.include? char \n return false\n elsif @wrong_guesses.include? char\n return false\n end\n \n #Check if word contains letter. If yes, increment guesses by 1. If not, increment wrong guesses by 1.\n if @word.include? char\n @guesses += char\n return true\n else\n @wrong_guesses += char\n return true\n end\n\n end",
"def guess(letter)\r\n if word_has?(letter)\r\n \tput_letter_on_board(letter)\r\n else\r\n wrong_letter(letter) if !@guesses.include? letter\r\n end\r\n end",
"def guess(letter)\r\n\t\t@guessed << letter.downcase\r\n\t\t@word[0].each_index do |i| #Iterate through indexes instead of values\r\n\t\t\tif @word.dig(0,i) == letter #since @word is an array inside an array, dig helps us look in word ([0]) each index for the letter.\r\n\t\t\t\t@hidden_word[i] = letter #if found, substitute \"_\" for the letter guessed in the same index for @hidden_word\r\n\t\t\tend\r\n\t\tend\r\n\t\tp @hidden_word #give feedback of results\r\n\tend",
"def add_to_guess\n @guess = @guess.map!.with_index do |character, index|\n @word.downcase[index] == @letter ? @word[index] : character\n end\n end",
"def guess(letter)\n # STEP 1: check to make sure the letter is not any non-letter character and\n # raises an error if it is\n if /^[a-zA-Z]+$/.match(letter)\n letter.downcase!\n else raise_error(\"Invalid letter\")\n end\n\n # STEP 2: check to make sure the user does not guess the same letter more\n # than once\n if @guesses.include? letter; return false; end\n if @wrong_guesses.include? letter; return false; end\n\n # STEP 3: check to see if the guessed letter matches any letters in the \n # word\n if @word.include? letter\n @guesses += letter\n # if there is a match, update the word_with_guesses to show where\n # in the string the letter was matched\n @word.each_char.with_index do |c, i|\n if c == letter\n @word_with_guesses[i] = c\n end\n end \n else \n @wrong_guesses += letter\n @attempts += 1\n end\n # update the number of attempts and call the function to check if\n # the user won, lost, or continues playing\n check_win_or_lose\n end",
"def guessed\n\n end",
"def make_guess\n guess = input_guess\n check_guess(guess)\n render_code(guess)\n render_pegs(@black_pegs, @white_pegs)\n end",
"def make_guess\n\t\tbegin\n\t\t\thighest_letter_left = freq_hash\n\t\t\t\t.sort_by{|k, v| v}\n\t\t\t\t.reverse\n\t\t\t\t.map{|char, freq| char}\n\t\t\t\t.detect{|char| !@guessed_letters.include?(char)}\n\n\t\t\traise \"Aw, damn! Got nothin' left. Let's start a new game.\" unless highest_letter_left\n\t\trescue Exception => e\n\t\t\tputs e.message\n\t\t\texit\n\t\telse\n\t\t\t@guessed_letters << highest_letter_left\n\t\t\thighest_letter_left\n\t\tend\n\tend",
"def guess(input,dead_man)\n input.upcase!\n if input.length == 1\n letter_guess(input,dead_man) \n else\n whole_word_guess(input,dead_man)\n end\n end",
"def translate_string_to_number(input)\n\n #take the input\n #break it up into individual letters\n #map the letters to a dictionary (a = 1) or\n #map the input to a placement in an array\n\nend",
"def guess(letter)\n raise InvalidGuessException.new(\"Invalid Guess!\") unless valid_guess?(letter)\n \n if word_has?(letter)\n \tput_letter_on_board(letter)\n else\n wrong_letter(letter) if !@guesses.include? letter\n end\n end",
"def decode(sentence)\n i = 0\n base = @alphabet.length\n sentence.each_char { |c| i = i * base + @alphabet.index(c) }\n i - @booster\n end",
"def guess_code (last_feedback = nil)\n guess = \"\"\n if !last_feedback\n guess = set_code.join # first guess is always a random combination of colors\n else\n guess = include_exact_matches([nil, nil, nil, nil], last_feedback)\n guess = include_partial_matches(guess, last_feedback)\n guess = fill_gaps(guess).join\n end\n return guess\n end",
"def get_guess\n @user_guess = \"\"\n if @count >= 5\n abort(\"You guessed 5 times incorrectly. You Lose\")\n else\n while guess_letters_check\n print \"You must guess exactly 4 colors (R,Y,B,P,O,G).\\nGuess here:\"\n @user_guess = gets.chomp.upcase\n end\n end\n @count += 1\n check_guess(@user_guess)\n end",
"def guessnumber\r\n\t\t@tries = @wordlength * 3 / 2\r\n\t\tputs \"player 2: you have #{@tries} guesses to get the word\"\r\n\tend",
"def generate_guess\n feedback = @board.generate_feedback_key(convert_num_to_guess(@guess))\n\n @candidates = @candidates.select do |c|\n get_feedback(convert_num_to_guess(@guess), convert_num_to_guess(c)) == feedback\n end\n\n @guess = @candidates[0]\n end",
"def guess_several_letters(object, string)\n string.each { |letter| guess(letter) }\n end",
"def return_in_mixed_charset(input, bias)\n # Split the phrase in words and recursively try to return each word in the \"correct\" charset\n # If that is not possible (e.g. a word contains both \"Φ\" and \"C\", the word must either be greek-ified (default) \n # or latin-ified. The reason for this is that we will be able to do SQL queries, as long as the word - or phrase\n # we are looking for has been passed through dbl.\n # We first split the input phrase, based on the SYMBOLS delimiters \n words_arr = input.split(/(?<=[#{SYMBOLS}])/)\n if words_arr.length == 1 # If it was only one word, return it, according to the bias.\n if bias == 'greek'\n return return_in_greek(words_arr.join.to_s) # If the bias is 'greek', return the word 'greek-ified'\n elsif bias == 'latin'\n return return_in_latin(words_arr.join.to_s) # Else if bias is 'latin' return it 'latinified'.\n else \n return (words_arr.join.to_s) # Else return it as-is (not advisable!)\n end\n else # Else apply dbl to each word we got after splitting input\n words_arr2 =[]\n words_arr.each do |word|\n words_arr2 << dbl(word)\n end\n return words_arr2.join.to_s\n end\n end",
"def first_guess\n\tputs \"\\nSo, what do you think the number is?\"\n\tgets\nend",
"def letters_to_guess\n @letters.map do |letter|\n if @user_guesses.include?(normalize_letter(letter))\n letter\n else\n nil\n end\n end\n end",
"def guess(letter)\r\n letter = letter.downcase\r\n num = 0\r\n #iterate through word comparing guessed letter to letter's in the word\r\n @word_arr.each_index do |i| \r\n if @word_arr[i] == letter\r\n #if the letter matches update the game board in the equivalent spot\r\n @gameboard[i] = letter\r\n num += 1\r\n end\r\n end\r\n #add letter to guessed database, and lower amount of guesses by one\r\n @guessed_letters << letter\r\n @guesses -= 1\r\n return num\r\n end",
"def guess_next_character(current_guess, verbose: true)\n # Initialize a Hash where each a-z character has an empty array\n chars = ('a'..'z').to_a\n measurements = Hash[chars.map { |char| [char, []] }]\n # And precompute the guesses to save time\n guesses = Hash[chars.map { |char| [char, \"#{current_guess}#{char}\"]}]\n\n # iterations = 10_000_000\n progressbar = ProgressBar.create\n\n # Iterate 100 times for the progressbar\n 100.times do\n # Iterate 100 times more, for 1000 experiments per character\n 10.times do\n\n # To avoid baises, let's shuffle the order we test the characters\n chars.sample(chars.length).each do |char|\n\n # Guess the current password + this char\n guess = guesses[char]\n correct, time = timed_guess_password(guess)\n\n if correct\n # Got it! Return a payload with the correct password\n return {\n guess: guess,\n correct: true,\n next_guess: nil\n }\n else\n measurements[char] << time\n end\n\n end\n end\n\n progressbar.increment\n end\n\n puts \"Measured. Calculating...\"\n variance = calculate_variance(measurements)\n\n puts \"Calculated. Plotting...\"\n display_bar_chart(variance)\n\n # Our best guess is the character with the largest variance.\n elem = variance.max_by { |variant| variant[1] }\n\n # TODO: if there is no clear outlier, then we should assume we've got it\n # wrong and just give up, or go backwards.\n\n {\n guess: current_guess,\n correct: false,\n next_guess: elem[0]\n }\n end",
"def guess letter\n raise InvalidGuessError if letter.strip.empty? || letter.length > 1\n letter = letter[0].upcase\n if @guesses.include?(letter)\n return {advance: false, message: \"#{letter} has already been played, silly!\"}\n else\n @guesses << letter\n end\n @guessed.each_with_index do |guessed_pos, index|\n if guessed_pos\n if letter == secret[index]\n return {advance: false, message: \"#{letter} has already been played, silly!\"}\n end\n else\n if letter == secret[index]\n reveal_all(letter)\n return {advance: true, message: \"We found #{letter}!\"}\n end\n end\n end\n {advance: true, message: \"Sorry, we did not find #{letter}!\"}\n end",
"def game_guess\n if path == \"/game\" && verb == \"POST\"\n number = client.read\n game.guess(number)\n redirect(client)\n end\n end",
"def correct_guess?(guess)\n guess == @hidden_code ? true : false\nend",
"def decode5(str)\n num = 0\n i = 0\n str.each_char do |char|\n pow = BASE ** (str.length - i -1)\n num += KEYS_HASH[char] * pow\n i += 1\n end\n return num\nend",
"def _rl_find_prev_mbchar(string, seed, flags)\r\n if @encoding == 'N'\r\n return ((seed == 0) ? seed : seed - 1)\r\n end\r\n\r\n length = string.length\r\n if seed < 0\r\n return 0\r\n elsif length < seed\r\n return length\r\n end\r\n\r\n case @encoding\r\n when 'E'\r\n string[0,seed].scan(/./me)[0..-2].to_s.length\r\n when 'S'\r\n string[0,seed].scan(/./ms)[0..-2].to_s.length\r\n when 'U'\r\n string[0,seed].scan(/./mu)[0..-2].to_s.length\r\n when 'X'\r\n string[0,seed].force_encoding(@encoding_name)[0..-2].bytesize\r\n end\r\n end",
"def guessed_wrong_letter()\n if $hidden_word_arr.exclude?($input)\n $guessed.append($input)\n end\n end",
"def try_guess(char)\n if self.already_attempted?(char)\n p \"that has already been attempted\"\n return false\n else\n matching_indices = self.get_matching_indices(char)\n self.fill_indices(char, matching_indices)\n\n @remaining_incorrect_guesses -= 1 if matching_indices.empty?\n \n @attempted_chars << char\n return true\n end\n end",
"def guess(letter)\r\n\t\t\r\n\t\tif(@word.include?(letter))\r\n\t\t @good_guesses.add(letter)\r\n\t end\r\n\t\r\n\tend",
"def good_guess? (int)\n\tint = gets.chomp\n\tif int == 42 \n\t\treturn \"True\"\n\telsif \n\t int != 42\n\t\treturn \"False\"\n\tend\nend",
"def guess char\n #get 1st char\n \n if char.nil?\n raise ArgumentError, 'Argument is not string' \n return false\n end\n if char.length != 1\n raise ArgumentError, 'Argument is not string'\n return false\n end \n if char.match(/[a-zA-Z]/) == nil\n raise ArgumentError, 'Argument is not string' \n return false\n end\n \n pick = char.chr.downcase\n\n #catch replicant entries\n if @guesses.match(\"#{pick}\") != nil\n # @word_with_guesses << \"You have already used that letter\"\n return false\n end \n \n if @wrong_guesses.match(\"#{pick}\") != nil\n# @word_with_guesses << \"You have already used that letter\"\n return false\n end \n \n #actual match\n if @word.match(\"#{pick}\") != nil\n guesses << pick # 1st char\n else\n wrong_guesses << pick # \n @attempt += 1\n end\n \n # build up guess string i.e. \"----a-e\"\n @word_with_guesses = '';\n @check_win_or_lose = :win\n word.each_char { |a|\n if @guesses.match(\"#{a}\") != nil \n @word_with_guesses << a\n else\n @word_with_guesses << '-'\n @check_win_or_lose = :play\n end\n }\n \n #check game status\n if @attempt > 6\n @check_win_or_lose = :lose\n end\n \n return true\n end",
"def guess_code\n puts \"\\nYou'll have 12 turns to guess the color code set by me.\\nNot So Good Luck jk\\nOptions: r,b,y,g,o,w,v\"\n catch(:guessed) do\n guess = ''\n (1..12).each do |turn|\n print \"\\nGuess #{turn}: \"\n #print \"#{get_code} \"\n guess = gets.chomp!.downcase\n response = ''\n gc = get_code.split('')\n g = guess.split('')\n for i in 0..3 do \n if g[i]==gc[i]\n response += 'X'\n elsif gc.include?(g[i]) \n response += 'O'\n end\n end\n puts \"Response: #{response.split('').shuffle.join('')}\"\n if response=='XXXX'\n puts \"\\nCongratulations! I Lost\\nThe code was #{get_code}\"\n throw :guessed\n elsif response!='XXXX' and turn==12\n puts \"\\nBoohoo! I won\\nTHe code was #{get_code}\"\n throw :guessed\n end\n end\n end\n end",
"def solicit_guess\n\t\tputs \"\\nPlease input a letter!\"\n\t\tguess = gets.chomp.downcase\n\t\tif guess.downcase == \"save\"\n\t\t\t$save = true\n\t\telse\t\n\t\t\tuntil !(@guess_tracker.include?(guess)) && (guess.length == 1) && (guess <= 'z' && guess >= 'a')\n\t\t\t\tputs \"Unacceptable input (maybe you already guessed that?), please try again!\"\n\t\t\t\tguess = gets.chomp.downcase\n\t\t\tend\n\t\tend\n\t\tguess\n\tend",
"def input_evaluation(guess, correct_word)\n if correct_word.word.include?(guess)\n # We learned that .each_with_index can be used to locate each letter corresponding with each spacific index\n # Then if the letter matches it will subsitue the \"_\", at the correct index, with the corresponding letter\n correct_word.word.each_with_index do |letter, index|\n if letter == guess\n correct_word.progress[index] = guess\n end\n end\n else\n # Storing wrong letters into an array and updating max_guesses\n correct_word.wrong_guesses << guess\n correct_word.max_guesses -= 3\n end\nend"
] |
[
"0.7673906",
"0.64907783",
"0.6242254",
"0.62359",
"0.6129248",
"0.61051196",
"0.6074401",
"0.607052",
"0.59913135",
"0.59260213",
"0.5920192",
"0.58827853",
"0.5854205",
"0.5852523",
"0.5802686",
"0.579727",
"0.5737099",
"0.571667",
"0.5707337",
"0.5700339",
"0.568195",
"0.5677932",
"0.5673217",
"0.56723475",
"0.561814",
"0.56032926",
"0.5574445",
"0.55735487",
"0.55655104",
"0.5565261",
"0.5554504",
"0.55430406",
"0.5531883",
"0.55280846",
"0.55225474",
"0.55135053",
"0.5478931",
"0.5478075",
"0.54594964",
"0.54579127",
"0.54514956",
"0.54429644",
"0.54352695",
"0.5428612",
"0.54260445",
"0.5424587",
"0.5419405",
"0.54184604",
"0.5418265",
"0.5415331",
"0.54016036",
"0.5393906",
"0.53891367",
"0.53891367",
"0.5386638",
"0.53808993",
"0.53767824",
"0.53666323",
"0.5361294",
"0.53510207",
"0.5347366",
"0.53464067",
"0.5346265",
"0.53272086",
"0.53241795",
"0.5322598",
"0.53206134",
"0.530995",
"0.53079593",
"0.5307235",
"0.5298926",
"0.528381",
"0.527899",
"0.52668583",
"0.52644134",
"0.5260989",
"0.5249411",
"0.5247823",
"0.524681",
"0.5241829",
"0.5241392",
"0.523533",
"0.52267206",
"0.5225692",
"0.52240473",
"0.5218776",
"0.52173537",
"0.52053595",
"0.5201617",
"0.51952434",
"0.5182049",
"0.5180803",
"0.51711667",
"0.51679265",
"0.516271",
"0.5162123",
"0.51601297",
"0.5159062",
"0.51580817",
"0.51555157"
] |
0.7727014
|
0
|
callseq: Kconv.guess_old(str) > integer Guess input encoding by NKF.guess1
|
def guess_old(str)
::NKF::guess1(str)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def guess(str)\n ::NKF::guess(str)\n end",
"def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end",
"def score_string(guess)\n results = Array.new()\n guess.split('').each_with_index do |char, index|\n if char == @code[index]\n results[index] = :h\n elsif @code.include? char\n results[index] = :n\n else\n results[index] = :m\n end\n end\n results\n end",
"def compare_guess(guess, str)\n#compare_guess stopped working when user interface added :(\n @guess_count = 0\n index = 0\n @result = \"\"\n while index < @str.length\n @guess.each_char do\n if @guess[index] == str[index]\n @result << @guess[index]\n else\n @result << \"-\"\n end\n @guess_count += 1\n index += 1\n end\n end\n return @result\nend",
"def correct_guess(guess)\n end",
"def init_guess\n init_guess_table = { 1 => \"A\", 2 => \"A\", 3 => \"A\", 4 => \"A\", 5 => \"S\",\n 6 => \"E\", 7 => \"E\", 8 => \"E\", 9 => \"E\", 10 => \"E\",\n 11 => \"E\", 12 => \"E\", 13 => \"I\", 14 => \"I\", 15 => \"I\",\n 16 => \"I\", 17 => \"I\", 18 => \"I\", 19 => \"I\", 20 => \"I\",\n 21 => \"O\", 22 => \"O\", 23 => \"O\", 24 => \"O\", 28 => \"I\" }\n @last_guess = init_guess_table[@last_feedback.length]\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def make_guess(_placeholder, _placeholder2)\n get_code('guess')\n end",
"def guess!(letter)\n end",
"def decode_strong(guess, code)\n guess.each_with_index.reduce(0) do |count, (code_peg, index)|\n if code_peg && code[index] == code_peg\n count += 1\n code[index] = nil\n guess[index] = nil\n end\n count\n end\n end",
"def _rl_find_prev_mbchar(string, seed, flags)\r\n if @encoding == 'N'\r\n return ((seed == 0) ? seed : seed - 1)\r\n end\r\n\r\n length = string.length\r\n if seed < 0\r\n return 0\r\n elsif length < seed\r\n return length\r\n end\r\n\r\n case @encoding\r\n when 'E'\r\n string[0,seed].scan(/./me)[0..-2].to_s.length\r\n when 'S'\r\n string[0,seed].scan(/./ms)[0..-2].to_s.length\r\n when 'U'\r\n string[0,seed].scan(/./mu)[0..-2].to_s.length\r\n when 'X'\r\n string[0,seed].force_encoding(@encoding_name)[0..-2].bytesize\r\n end\r\n end",
"def guess(guess)\n \t@guess = guess\n \treturn :correct if solved?\n \t@guess > @answer ? :high : :low\n end",
"def incorrect_guess(guess)\n end",
"def read_guess\n print \"Pretty please enter your guess: \"\n gets.to_i\nend",
"def check_guess(input)\n @guessed_letters.push(input)\n if @secret_word.match?(input)\n @secret_word.split(//).each_with_index { |char, index| @guessed_word[index] = char if char == input }\n else\n puts 'Incorrect'\n @guesses_left -= 1\n @wrong_letters.push(input)\n end\n end",
"def reencode_string(input); end",
"def convert (str)\r\n# REFERENCE : Using logic from this source https://stackoverflow.com/questions/13498688/pig-latin-method-translation\r\n alpha = ('a'..'z').to_a\r\n vowels = %w[a e i o u]\r\n consonants = alpha - vowels\r\n lstr = str.downcase\r\n if vowels.include?(lstr[0])\r\n str + 'way'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1]) && consonants.include?(lstr[2])\r\n str[3..-1] + str[0..2] + 'ay'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1])\r\n str[2..-1] + str[0..1] + 'ay'\r\n elsif consonants.include?(lstr[0])\r\n str[1..-1] + str[0] + 'ay'\r\n else\r\n str # return unchanged\r\n end\r\nend",
"def new_guess\n @possibleCodes = if @possibleCodes.empty?\n @possibleCodesAll.map do |i|\n if $game.check_silent(i, $game.lastGuess) == $game.match\n i\n else\n i = nil\n end\n end.compact!\n\n else\n @possibleCodes.map do |i|\n if $game.check_silent(i, $game.lastGuess) == $game.match\n i\n else\n i = nil\n end\n end.compact!\n\n end\n @possibleCodes.sample.split('').map!(&:to_i)\n end",
"def guess\n\t\tcollect_words_of_length\n\t\tputs \"Already guessed letters by computer: #{@guessed_letters}\"\n\t\t@guessing_letter = nil\n\t\twhile @guessing_letter == nil || invalid?(@guessing_letter)\n\t\t\t@guessing_letter = guessing_letter\n\t\tend\n\t\t@guessed_letters << @guessing_letter\n\t\t@guessing_letter\n\tend",
"def translate_string_to_number(input)\n\n #take the input\n #break it up into individual letters\n #map the letters to a dictionary (a = 1) or\n #map the input to a placement in an array\n\nend",
"def word_to_guess (user_word)\n\t\tuser_word.downcase!\n\t\t@number_guess = user_word.length\n\t\t@answer_word = user_word.split(\"\")\n\tend",
"def encode(str)\n\tswap_raw = \"GA-DE-RY-PO-LU-KI\".reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.split(\"-\")\n\tencoder = Hash.new\n\tswap_raw.each { |pair| encoder[pair[0]] = pair[1] }\n\tencoded_string = \"\"\n\tputs encoder\n\tfor char in str.split(\"\")\n\t\tif encoder.key?(char) #correct?\n\t\t\tencoded_string += encoder[char]\n\t\telse\n\t\t\tencoded_string += char\n\t\tend\n\tend\n\treturn encoded_string\nend",
"def guess\n puts \"Write down a guess.\"\n @guess_code.make_seq\n @code_seq = guess_code.sequence\n end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def ask_guess\n guess = gets.chomp.downcase\n check_guess_is_valid?(guess) ? guess : ask_guess\n end",
"def decode_weak(guess, code)\n guess.compact.each.reduce(0) do |count, code_peg|\n index = code.find_index(code_peg)\n if index\n count += 1\n code[index] = nil\n end\n count\n end\n end",
"def guess(guess)\n \t@guess = guess\n\n \tguess_response\n end",
"def guess\n letters = @possible_letters.collect {|letter| [ score_for(letter),letter ]}\n letter = letters.min {|letter1,letter2| letter1 <=> letter2 }\n letter[1]\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def return_in_mixed_charset(input, bias)\n # Split the phrase in words and recursively try to return each word in the \"correct\" charset\n # If that is not possible (e.g. a word contains both \"Φ\" and \"C\", the word must either be greek-ified (default) \n # or latin-ified. The reason for this is that we will be able to do SQL queries, as long as the word - or phrase\n # we are looking for has been passed through dbl.\n # We first split the input phrase, based on the SYMBOLS delimiters \n words_arr = input.split(/(?<=[#{SYMBOLS}])/)\n if words_arr.length == 1 # If it was only one word, return it, according to the bias.\n if bias == 'greek'\n return return_in_greek(words_arr.join.to_s) # If the bias is 'greek', return the word 'greek-ified'\n elsif bias == 'latin'\n return return_in_latin(words_arr.join.to_s) # Else if bias is 'latin' return it 'latinified'.\n else \n return (words_arr.join.to_s) # Else return it as-is (not advisable!)\n end\n else # Else apply dbl to each word we got after splitting input\n words_arr2 =[]\n words_arr.each do |word|\n words_arr2 << dbl(word)\n end\n return words_arr2.join.to_s\n end\n end",
"def number_decoder( input )\n output = \"\"\n \n # build number to letter hash\n translator = Hash.new\n letters = ('A'..'Z').to_a\n letters.each_index{|i| translator [(i+1).to_s] = letters[i] }\n \n input.each(' ') do |nibble|\n\n \n num = nibble.strip.to_i\n if (num == 0 or num.nil?) then output << \" \"\n else\n case (num-1)/26\n when 0 then output << translator[num.to_s]# + ' '\n when 1 then output << translator[(num - 26).to_s]\n end\n end\n end\n \n output\nend",
"def ask_for_guess\n @guess_count += 1\n @guess = get_code(\"Please enter your guess in the format 'color color color color'(to list available color options enter 'options'):\")\n end",
"def guessed_wrong_letter()\n if $hidden_word_arr.exclude?($input)\n $guessed.append($input)\n end\n end",
"def player_guess\n puts \"Turn #{@turn} - Put your guess in below:\"\n begin\n guess = gets.chomp\n guess_code = Code.new(guess.upcase)\n rescue StandardError => e\n puts e\n retry\n end\n guess_code\n end",
"def get_input\n if previous_guess\n second_guess\n else\n first_guess\n end\n end",
"def make_guess\n\t\tbegin\n\t\t\thighest_letter_left = freq_hash\n\t\t\t\t.sort_by{|k, v| v}\n\t\t\t\t.reverse\n\t\t\t\t.map{|char, freq| char}\n\t\t\t\t.detect{|char| !@guessed_letters.include?(char)}\n\n\t\t\traise \"Aw, damn! Got nothin' left. Let's start a new game.\" unless highest_letter_left\n\t\trescue Exception => e\n\t\t\tputs e.message\n\t\t\texit\n\t\telse\n\t\t\t@guessed_letters << highest_letter_left\n\t\t\thighest_letter_left\n\t\tend\n\tend",
"def decode(sentence)\n i = 0\n base = @alphabet.length\n sentence.each_char { |c| i = i * base + @alphabet.index(c) }\n i - @booster\n end",
"def iconv() end",
"def gets_user_guess\n @guess = gets.strip.downcase\n generate_new_card\n end",
"def guess(input,dead_man)\n input.upcase!\n if input.length == 1\n letter_guess(input,dead_man) \n else\n whole_word_guess(input,dead_man)\n end\n end",
"def getguess guess\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t if guess.length == 1\r\n\t\t\t\t if check_repeated_choice guess\r\n\t\t\t\t @message = \"Already guessed this letter!\"\r\n\t\t\t\t if @console\r\n\t\t\t\t\t\t\t\t@output.puts \"#{@message}\"\r\n\t\t\t\t\t\t\t\tword_input = take_user_word_input\r\n\t\t\t\t\t\t\t\tvalid = false\r\n\t\t\t\t\t\t\t while !valid do\r\n\t\t if validate_input word_input\r\n\t\t valid = true\r\n\t\t else\r\n\t\t @output.puts \"Invalid input\"\r\n\t\t word_input = take_user_word_input\r\n\t\t end\r\n\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif check_enter word_input\r\n\t\t\t\t\t\t\t\t\t\t@break_flag = true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t getguess word_input\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t end\r\n\t\t\t\t else\r\n\t\t\t\t \t@message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @guess_counter+=1\r\n\t\t\t\t check_guess guess\r\n\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t end\r\n\t\t\t\t success = check_phrase @resulta.join(',').gsub(\",\",\"\")\r\n\t\t\t\t return success ? true : false\r\n\t\t\t\telse\r\n\t\t\t\t\t if check_phrase guess\r\n\t\t\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t\t\t i = 0\r\n\t\t\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\t\t\t@resulta[i] = phrase[i]\r\n\t\t\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t return true\r\n\t\t\t\t\t else\r\n\t\t\t\t\t\t @num_guessed = 0\r\n\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t @guess_counter+=1\r\n\t\t\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t\t\t return false\r\n\t\t\t\t\t end\r\n\t\t\t\tend\r\n\t\t\t\tend",
"def input_guess\n puts 'Input a code!'\n begin\n input = gets\n parse(input)\n rescue NoMethodError\n input_error\n end\n end",
"def north_korean_cipher(coded_message)\n\tinput = coded_message.downcase.split(\"\") # Check out this method in IRB to see how it works! Also refer to the ruby docs.\n\tdecoded_sentence = []\n\tcipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n\t\t\t\t\t\t\"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n\t\t\t\t\t\t\"g\" => \"c\", \n\t\t\t\t\t\t\"h\" => \"d\", \n\t\t\t\t\t\t\"i\" => \"e\", \n\t\t\t\t\t\t\"j\" => \"f\",\n\t\t\t\t\t\t\"k\" => \"g\",\n\t\t\t\t\t\t\"l\" => \"h\",\n\t\t\t\t\t\t\"m\" => \"i\",\n\t\t\t\t\t\t\"n\" => \"j\",\n\t\t\t\t\t\t\"o\" => \"k\",\n\t\t\t\t\t\t\"p\" => \"l\",\n\t\t\t\t\t\t\"q\" => \"m\",\n\t\t\t\t\t\t\"r\" => \"n\",\n\t\t\t\t\t\t\"s\" => \"o\",\n\t\t\t\t\t\t\"t\" => \"p\",\n\t\t\t\t\t\t\"u\" => \"q\",\n\t\t\t\t\t\t\"v\" => \"r\",\n\t\t\t\t\t\t\"w\" => \"s\",\n\t\t\t\t\t\t\"x\" => \"t\",\n\t\t\t\t\t\t\"y\" => \"u\",\n\t\t\t\t\t\t\"z\" => \"v\",\n\t\t\t\t\t\t\"a\" => \"w\",\n\t\t\t\t\t\t\"b\" => \"x\",\n\t\t\t\t\t\t\"c\" => \"y\",\n\t\t\t\t\t\t\"d\" => \"z\"}\n\t\n# This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n# the best data structure for this problem? What are the pros and cons of hashes?\n# \n# We automated this task with our own method that shifts letters automatically. It even allows you to\n# specify the amount the letters need to be shifted. This will output our needed hash, without having to\n# manually write every key/value pair.\n\n\tinput.each do |x| # iterate through each letter in the coded message (input is an array of all letters in order)\n\t\tfound_match = false # If found_match is set to true, the block code \"if not found_match\" will NEVER be executed\n\t\t\t\t\t\t\t\t\t\t\t\t # so the unmapped letter will not be added back to the decoded message\n\t\tcipher.each_key do |y| # iterate through each key in the hash table\n\t\t\tif x == y # compare the current letter in the coded message to the key in the hash table. If they are equals,\n\t\t\t\t\t\t\t\t # meaning the decoded letter is found, add the mapped value to the decoded message\n\t\t\t\tputs \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n\t\t\t\tdecoded_sentence << cipher[y]\n\t\t\t\tfound_match = true\n\t\t\t\tbreak # Once the decoded letter is found, break out of the loop and go for the next letter in the input message\n\t\t\telsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" # If any of these symbols is\n\t\t\t\t# found in the coded message, it is equivalent to a space. These are all OR statements, so if any are found to\n\t\t\t\t# be true, it will run the block of code.\n\t\t\t\tdecoded_sentence << \" \"\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\telsif (0..9).to_a.include?(x) # This puts all the numbers from 0 to 9 into an array and check if that array contains x\n\t\t\t\tdecoded_sentence << x\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\tend \n\t\tend\n\t\tif not found_match # If some character not covered by any of the if statments is found in the coded message\n\t\t# that character is put into the decoded message\n\t\t\tdecoded_sentence << x\n\t\tend\n\tend\n\tdecoded_sentence = decoded_sentence.join(\"\")\n \n\tif decoded_sentence.match(/\\d+/) #Checks the decoded message for any numbers \n\t\tdecoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } # Replaces those numbers with a number divided by 100, because\n\t\t# he has been known to exaggerate about the amount of stuff he has\n\tend \n\treturn decoded_sentence # return the decoded message \nend",
"def decode5(str)\n num = 0\n i = 0\n str.each_char do |char|\n pow = BASE ** (str.length - i -1)\n num += KEYS_HASH[char] * pow\n i += 1\n end\n return num\nend",
"def guess_letter(letter)\n\t\tif @ans_word.include?(letter)\n\t\t\ti = @ans_word.index(letter)\n\t\t\t@guess.insert(i, letter)\n\t\t\t@guess.pop\n\t\t\tputs \"Good! You are getting closer: #{@guess*\"\"}\"\n\t\telse\n\t\t\tputs \"sorry, guess again\"\n\t\tend\n\tend",
"def add_to_guess\n @guess = @guess.map!.with_index do |character, index|\n @word.downcase[index] == @letter ? @word[index] : character\n end\n end",
"def input_evaluation(guess, correct_word)\n if correct_word.word.include?(guess)\n # We learned that .each_with_index can be used to locate each letter corresponding with each spacific index\n # Then if the letter matches it will subsitue the \"_\", at the correct index, with the corresponding letter\n correct_word.word.each_with_index do |letter, index|\n if letter == guess\n correct_word.progress[index] = guess\n end\n end\n else\n # Storing wrong letters into an array and updating max_guesses\n correct_word.wrong_guesses << guess\n correct_word.max_guesses -= 3\n end\nend",
"def make_guess(secret_code)\n if guess == [0, 0, 0, 0]\n first_guess\n return guess\n end\n reduce_solution_set(secret_code)\n update_guess\n guess\n end",
"def guess(guess)\r\n\t\t# Make sure the guess is either a letter or the whole word\r\n\t\tif guess.length != 1 && guess.length != @win_word.length\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp \"Guess a letter, or the complete word!\"\r\n\t\t# check for repeated guesses\r\n\t\telsif @past_guesses.include? guess\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"You guessed that already!\"\r\n\t\t# check if they guessed the entire word correctly\r\n\t\telsif guess == @win_word\r\n\t\t\twin\r\n\t\t# if the letter is not in the word\r\n\t\telsif !@win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tif @remaining_guesses == 1\r\n\t\t\t\tlose\r\n\t\t\telse\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"Sorry, try again!\"\r\n\t\t\tend\r\n\t\t# if the letter is in the word\r\n\t\telsif @win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tupdate_hint(guess)\r\n\t\t\tif @hint_str == @win_word\r\n\t\t\t\twin\r\n\t\t\telse\r\n\t\t\t\tp \"Nice guess!\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tp \"Error\"\r\n\t\tend\r\n\r\n\tend",
"def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end",
"def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end",
"def guessbrian(guess)\n #error checking\n if guess == nil || guess == \"\" || guess =='%'\n throw :guess\n end\n #initialize variables and split\n guess = guess.downcase\n flag = 0\n splitWord = @word\n splitWord = splitWord.downcase.split(\"\")\n #check and assign\n splitWord.each { |x|\n if x == guess\n flag = 1\n end\n }\n if flag == 1\n if @guesses == guess\n return false\n else\n @guesses << guess\n return true\n end\n else\n if guess == guess.gsub(/[^A-Za-z]/, '') && guess != @wrong_guesses\n @wrong_guesses << guess\n return true\n else\n return false\n end\n end\n end",
"def get_guess(r)\n\tputs \"Guess the number from 1-10\"\n\tguess = gets\n\tcheck_guess(r, guess)\nend",
"def get_hint(secret, guess)\n bulls = 0\n cows = 0\n\n tracker = Hash.new(0)\n secret.each_char { |char| tracker[char] += 1 }\n guess.each_char.with_index do |char, i|\n if secret[i] == guess[i]\n bulls += 1\n if tracker[char] > 0\n tracker[char] -= 1\n else\n cows -= 1\n end\n elsif tracker[char] > 0\n tracker[char] -= 1\n cows += 1\n end\n end\n\n \"#{bulls}A#{cows}B\"\nend",
"def to_num(input)\n result = 0\n #iterate on roman number hash\n MAPPING.each do |k,v|\n while input.index(k) == 0 #if \"CL\".index(\"C\") == 0\n result += v #assign value of current hash key\n input.slice!(0) #remove string \"C\" from input and so on\n end\n end\n result\n end",
"def check_guess(guess)\n # checks human guess, displays discovered, and return if letter found\n letter_found = false\n self.secret_word.split('').each_with_index do |chr, ind|\n if chr == guess\n self.currently_discovered[ind] = chr\n letter_found = true\n end\n end\n p self.currently_discovered\n letter_found\n end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def translate_codepoints(str)\n str.gsub(/#x\\h+/) {|c| c[2..-1].scanf(\"%x\").first.chr(Encoding::UTF_8)}\n end",
"def kcode() end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def capture_guess(user_input)\n @guess = user_input.scan(/./)\n end",
"def guess(text, meta)\n nil\n end",
"def guessed\n\n end",
"def calculate_guess(guess, analisis)\n if analisis.nil?\n @all_guesses = (1111..6666).map(&:to_s).reject { |g| g.include?('0') }\n '1122'\n else\n @all_guesses.delete(guess)\n @all_guesses.select! { |g| 4 - (g.chars - guess.chars).size == analisis.count('?') + analisis.count('!') }\n @all_guesses.select! do |g|\n g.chars.select.with_index { |c, idx| c == guess.chars[idx] }.size == analisis.count('!')\n end\n @all_guesses[0]\n end\n end",
"def pig_latin(sentence)\n \n\nend",
"def make_guess\n\tputs \"#{ @name } is thinking...\"\n\tif @first_guess==[]\n\t return make_first_guess\n\telse\n\t # update the last guess, get a random sample from the set of available codes\n\t sleep 1\n\t @last_guess = @set_of_codes.sample \n\t return @last_guess\n\tend\n end",
"def guess(word_pattern, possible_words)\r\n all_words = possible_words.flatten\r\n guess = $avail_letters.sort_by {|c|\r\n all_words.select{|w|w.index c}.length}.last\r\n $avail_letters -= [guess]\r\n $guess = guess\r\nend",
"def pig_latin(sentence)\nend",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def pig_latin(sentence)\n\nend",
"def guess(word_pattern, possible_words)\n all_words = possible_words.flatten\n guess = $avail_letters.sort_by {|c|\n all_words.select{|w|w.index c}.length}.last\n $avail_letters -= [guess]\n $guess = guess\nend",
"def give_feedback(guess)\n guess.split('').each_with_index do |val, index|\n if val == @code[index]\n print 'M'\n elsif @code.split('').include?(val)\n print 'O'\n else\n print 'X'\n end\n end\n puts\n end",
"def bad_guess_count()\r\n\t\t# TODO: fill in method body\r\n\t\treturn -1\r\n\tend",
"def caesar_guesser(encrypted_string, alphabet)\nend",
"def set_guess\n @guess = Array.new(@word.length, '*')\n end",
"def letters_to_guess\n @letters.map do |letter|\n if @user_guesses.include?(normalize_letter(letter))\n letter\n else\n nil\n end\n end\n end",
"def num_decodings(s)\n\n decode = ('A'..'Z').to_a\n number_of_prev_ended_singly = 1\n\n ways_count = 1\n number_of_prev_ended_singly = 1\n\n s.chars[1..-1].each_with_index do |ch, idx|\n if s[idx - 1].to_i == 1 ||\n s[idx - 1] == 2.to_i && ch.to_i.between?(1,6)\n\n numbers_added_this_time = ways_count - number_of_prev_ended_singly\n ways_count += numbers_added_this_time\n number_of_prev_ended_singly = numbers_added_this_time\n else\n number_of_prev_ended_singly = 0\n end\n end\n\n ways_count\n\nend",
"def choose_guess\n if @num_guesses.zero?\n Code.new([1, 1, 2, 2])\n else\n @valid_codes.sample\n end\n end",
"def bad_decode(letter1, letter2, letter3)\n new1 = \"abcdefghijklmnopqrstuvwxyz\".index(letter1) - 1\n puts \"abcdefghijklmnopqrstuvwxyz\"[new1.to_i]\n new2 = \"abcdefghijklmnopqrstuvwxyz\".index(letter2) - 1\n puts \"abcdefghijklmnopqrstuvwxyz\"[new2.to_i]\n new3 = \"abcdefghijklmnopqrstuvwxyz\".index(letter3) - 1\n puts \"abcdefghijklmnopqrstuvwxyz\"[new3.to_i]\nend",
"def guessed_word()\r\n\t\tresult = ''\r\n\r\n\t\t# TODO: fill in method body\r\n\t\t\r\n\t\treturn result\r\n\tend",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def decode3(str)\n num = 0\n str.each_char.with_index do |char, i|\n pow = BASE ** (str.length - i -1)\n num += KEYS.index(char) * pow\n end\n return num\nend",
"def guess\n # takes human input and stores guess\n puts 'Pick a letter'\n self.human_guess = gets.chomp\n end",
"def north_korean_cipher(coded_message)\n input = coded_message.downcase.split(\"\") # Turning every letter into a lower case letter and then splitting it into array\n decoded_sentence = []\n cipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n \"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n \"g\" => \"c\", # An array would be beeter structure, we can automate the shiffting of the letters\n \"h\" => \"d\",\n \"i\" => \"e\",\n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\",\n \"m\" => \"i\",\n \"n\" => \"j\",\n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n\n input.each do |x| # iterating over each input character\n found_match = false #when false the same character will be added to the solution\n cipher.each_key do |y| # iterating thruthe keys of cipher hash\n if x == y #if current character is equal to a hash key\n # puts \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n decoded_sentence << cipher[y]\n found_match = true\n break #it will end the loop once it finds its match\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" #If it matach one of these characters it will add a space\n decoded_sentence << \" \"\n found_match = true\n break\n elsif (0..9).to_a.include?(x) # turns a range into an array and then checks if that array includes the input\n decoded_sentence << x\n found_match = true\n break\n end\n end\n if not found_match #If there is no match then add the character to the solution\n decoded_sentence << x\n end\n end\n decoded_sentence = decoded_sentence.join(\"\")\n\n if decoded_sentence.match(/\\d+/) #Finding all the didgits\n decoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } #Replace and divide by 100\n end\n return decoded_sentence # it sreturning the string\nend",
"def get_hint(secret, guess)\r\n hash1 = Hash.new(0)\r\n hash2 = Hash.new(0)\r\n bulls = 0\r\n cows = 0\r\n \r\n secret.each_char.with_index do |char, idx| \r\n hash1[char] += 1\r\n bulls += 1 if secret[idx] == guess[idx]\r\n end\r\n \r\n guess.each_char {|char| hash2[char] += 1}\r\n hash1.keys.each {|key| cows += [hash1[key], hash2[key]].min}\r\n \r\n bulls.to_s + \"A\" + (cows-bulls).to_s + \"B\"\r\nend",
"def get_new_letter\n loop do\n puts \"What letter would you like to guess?\"\n @guess = gets.chomp.downcase\n break if valid_letter?(@guess)\n end\n end",
"def check_guess guess\r\n\t\t\t\t @resultb.push(guess)\r\n\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t i = 0\r\n\t\t\t\t @num_guessed = 0\r\n\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\tif phrase[i] == guess\r\n\t\t\t\t\t\t\t\t @resulta[i] = guess\r\n\t\t\t\t\t\t\t\t @num_guessed += 1\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif @num_guessed > 0\r\n\t\t\t\t\t\t\t\t@score += (@reward.to_i * @num_guessed)\r\n\t\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t\t\tend\r\n\t\t end",
"def energetic_encoding(sentence, hash)\n chars = sentence.split(\"\")\n new_sent = chars. map do |char|\n if hash.has_key?(char)\n hash[char]\n elsif char == \" \"\n \" \"\n else\n \"?\"\n end\n end \n new_sent.join(\"\")\nend",
"def decode1(str)\n num = 0\n i = 0\n while i < str.length\n pow = BASE ** (str.length - i -1)\n num += KEYS.index(str[i]) * pow\n i += 1\n end\n return num\nend",
"def guessed_letters()\n guessed = $bucket.join(\" \") # return a string of guessed letters\nend",
"def caesar_guesser(encrypted_string, alphabet)\r\n\r\nend",
"def guess(letter)\r\n letter = letter.downcase\r\n num = 0\r\n #iterate through word comparing guessed letter to letter's in the word\r\n @word_arr.each_index do |i| \r\n if @word_arr[i] == letter\r\n #if the letter matches update the game board in the equivalent spot\r\n @gameboard[i] = letter\r\n num += 1\r\n end\r\n end\r\n #add letter to guessed database, and lower amount of guesses by one\r\n @guessed_letters << letter\r\n @guesses -= 1\r\n return num\r\n end",
"def get_roman_equiv input\n\tval = \"\"\n\tcredithash, codehash = read_input \n\tinput.split(\" \").each { |r| \n\t\tif codehash.has_key?(r)\n\t\t\tval = val + codehash[r]\n\t\tend\n\t}\n\treturn val\nend",
"def guess(letters)\n raise ArgumentError if letters == \"\"\n raise ArgumentError if letters !~ %r{\\w}\n letters.downcase!\n if @word.include?(letters) \n !@guesses.include?(letters) ? @guesses << letters : false\n\n else\n @wrong_guesses.include?(letters) ? false : wrong_guesses << letters \n end\n end",
"def guess(g)\n return false unless valid?(g)\n @turns -= 1\n answer = []\n ges = g.clone\n tmp = @code.clone\n\n ges.size.times do |index|\n if ges[index] == tmp[index]\n answer << '+'\n tmp[index] = '0'\n ges[index] = 'a'\n end\n end\n \n tmp.each_char do |value| \n if ges.include? value\n answer << '-'\n ges.sub!(value, 'a')\n end\n end\n\n ret = 1 if answer == ['+', '+', '+', '+']\n \n ret ||= 0 if @turns == 0 \n ret ||= answer.join\n @log << {a: ret, guess: g}\n ret\n end",
"def guess(letter)\r\n\t\t@guessed << letter.downcase\r\n\t\t@word[0].each_index do |i| #Iterate through indexes instead of values\r\n\t\t\tif @word.dig(0,i) == letter #since @word is an array inside an array, dig helps us look in word ([0]) each index for the letter.\r\n\t\t\t\t@hidden_word[i] = letter #if found, substitute \"_\" for the letter guessed in the same index for @hidden_word\r\n\t\t\tend\r\n\t\tend\r\n\t\tp @hidden_word #give feedback of results\r\n\tend",
"def get_guess\n\t\twhile true\n\t\t\tguess = gets.chomp.upcase\n\t\t\treturn :save if guess == \"SAVE\" || guess == \"'SAVE'\"\n\t\t\tif guess.between?('A', 'Z') && guess.length == 1\n\t\t\t\tif @hits.include?(guess) || @misses.include?(guess)\n\t\t\t\t\tprint \"You guessed '#{ guess }' already. Select another letter: \"\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\treturn guess\n\t\t\tend\n\t\t\tprint \"Enter one letter for guess (or 'save' to save game): \"\n\t\tend\n\tend",
"def guess_code (last_feedback = nil)\n guess = \"\"\n if !last_feedback\n guess = set_code.join # first guess is always a random combination of colors\n else\n guess = include_exact_matches([nil, nil, nil, nil], last_feedback)\n guess = include_partial_matches(guess, last_feedback)\n guess = fill_gaps(guess).join\n end\n return guess\n end",
"def guess(letter)\n # STEP 1: check to make sure the letter is not any non-letter character and\n # raises an error if it is\n if /^[a-zA-Z]+$/.match(letter)\n letter.downcase!\n else raise_error(\"Invalid letter\")\n end\n\n # STEP 2: check to make sure the user does not guess the same letter more\n # than once\n if @guesses.include? letter; return false; end\n if @wrong_guesses.include? letter; return false; end\n\n # STEP 3: check to see if the guessed letter matches any letters in the \n # word\n if @word.include? letter\n @guesses += letter\n # if there is a match, update the word_with_guesses to show where\n # in the string the letter was matched\n @word.each_char.with_index do |c, i|\n if c == letter\n @word_with_guesses[i] = c\n end\n end \n else \n @wrong_guesses += letter\n @attempts += 1\n end\n # update the number of attempts and call the function to check if\n # the user won, lost, or continues playing\n check_win_or_lose\n end"
] |
[
"0.73427606",
"0.6043232",
"0.60032916",
"0.59891504",
"0.5946261",
"0.59267485",
"0.58515054",
"0.5780548",
"0.56909466",
"0.55836755",
"0.5577254",
"0.55177957",
"0.55114967",
"0.5471276",
"0.54660636",
"0.54580706",
"0.54511774",
"0.54375833",
"0.5425494",
"0.54016185",
"0.540116",
"0.53965074",
"0.5395379",
"0.5384289",
"0.5367761",
"0.5357564",
"0.5351842",
"0.5338379",
"0.5338019",
"0.53307503",
"0.5327412",
"0.53176916",
"0.53153044",
"0.53144747",
"0.5312233",
"0.53036875",
"0.52915305",
"0.52889997",
"0.52833366",
"0.5280365",
"0.5268796",
"0.5265195",
"0.5259865",
"0.52372605",
"0.5201239",
"0.5196698",
"0.51951045",
"0.51658344",
"0.5162477",
"0.51564735",
"0.5145421",
"0.5145421",
"0.51431406",
"0.51415104",
"0.513097",
"0.51306516",
"0.512807",
"0.5119626",
"0.51179403",
"0.5116278",
"0.5114676",
"0.5099736",
"0.5095116",
"0.5088379",
"0.50875324",
"0.5083864",
"0.5081796",
"0.50782055",
"0.507641",
"0.50759625",
"0.5075806",
"0.50756395",
"0.5074664",
"0.5065585",
"0.5055334",
"0.50550807",
"0.5054359",
"0.5050105",
"0.50450385",
"0.50434935",
"0.50380874",
"0.503726",
"0.50369143",
"0.50340235",
"0.5033913",
"0.50315595",
"0.50221974",
"0.50214404",
"0.5018646",
"0.50098294",
"0.5002727",
"0.5000284",
"0.49976137",
"0.49967638",
"0.49947196",
"0.49866652",
"0.49827442",
"0.49814713",
"0.49728417",
"0.49725515"
] |
0.81876945
|
0
|
isEncoding callseq: Kconv.iseuc(str) > obj or nil Returns whether input encoding is EUCJP or not. Note don't expect this return value is MatchData.
|
def iseuc(str)
RegexpEucjp.match( str )
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def isutf8;\tKconv.isutf8(self) end",
"def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def is_utf8?\n ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)\n end",
"def found_encoding; end",
"def found_encoding; end",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def encoding_found; end",
"def encoding_found; end",
"def find_encoding(encoding); end",
"def isutf8(str)\n RegexpUtf8.match( str )\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def check_utf8_encoding\n return nil if self.encoding != Encoding.find('utf-8')\n state = :s0\n n_of_chars = 0\n self.bytes.each do |byte|\n case state\n when :s0\n n_of_chars += 1\n if (0x00..0x7F).include?(byte) then state = :s0\n elsif (0xC2..0xDF).include?(byte) then state = :s1\n elsif 0xE0 == byte then state = :s2\n elsif (0xE1..0xEC).include?(byte) || (0xEE..0xEF).include?(byte) then state = :s3\n elsif 0xED == byte then state = :s4\n elsif 0xF0 == byte then state = :s5\n elsif (0xF1..0xF3).include?(byte) then state = :s7\n elsif 0xF4 == byte then state = :s8\n else return nil end\n when :s1\n if (0x80..0xBF).include?(byte) then state = :s0 \n else return nil end\n when :s2\n if (0xA0..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s3\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s4\n if (0x80..0x9F).include?(byte) then state = :s1\n else return nil end\n when :s5\n if (0x90..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s6\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s7\n if (0x80..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s8\n if (0x80..0x8F).include?(byte) then state = :s6\n else return nil end\n end # case\n end # self.bytes.each\n if state == :s0 then return n_of_chars\n else return nil end\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message.scrub =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def valid_utf8?(str)\n valid_utf8_bson?(str)\n end",
"def try_with_encoding(string, encoding); end",
"def try_with_encoding(string, encoding); end",
"def can_encode?(str, charset: BASIC_CHARSET)\n !str || !!(regex(charset) =~ str)\n end",
"def have_encoding?\n Object.const_defined? :Encoding\n end",
"def valid_utf8?(str)\n @connection.valid_utf8?(str)\n end",
"def is_nikkud(c)\n self.class.is_nikkud_by_encoding(c, self.encoding) # delegate to class method based on instance encoding\n end",
"def enc_utf8\n\n @@enc_utf8 ||= \n ( Encoding.find( \"utf-8\" ) or raise \"No utf-8 encoding found (?!)\" )\nend",
"def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def valid_utf_8_bytes?(string)\n original_encoding = string.encoding\n valid = string.force_encoding(Encoding::UTF_8).valid_encoding?\n string.force_encoding(original_encoding)\n valid\n end",
"def ascii?\n ASCII_ENCODINGS.include?(encoding)\n end",
"def valid_value?\n if ape_type == 'utf8' || ape_type == 'external'\n # :nocov:\n if RUBY_VERSION >= '1.9'\n # :nocov:\n begin\n map!{|v| v.to_s.encode('UTF-8')}\n rescue EncodingError\n return false\n end\n end\n string_value.unpack('U*')\n end\n rescue ArgumentError\n false\n else\n true\n end",
"def issjis(str)\n RegexpShiftjis.match( str )\n end",
"def try_utf8!(string, encoding = ::Encoding::UTF_8)\n return nil unless string\n string.force_encoding(::Encoding::ASCII_8BIT) unless string.force_encoding(encoding).valid_encoding?\n string\n end",
"def unicode?\n self.local =~ /[^\\p{InBasicLatin}]/ ? true : false\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def issjis;\tKconv.issjis(self) end",
"def encoding_from_feed_data\n if @encoding_from_feed_data.blank?\n raw_data = self.feed_data\n return nil if raw_data.nil?\n encoding_from_xml_instruct = \n raw_data.scan(\n /^<\\?xml [^>]*encoding=\"([^\\\"]*)\"[^>]*\\?>/\n ).flatten.first\n unless encoding_from_xml_instruct.blank?\n encoding_from_xml_instruct.downcase!\n end\n if encoding_from_xml_instruct.blank?\n begin\n doc = REXML::Document.new(raw_data)\n encoding_from_xml_instruct = doc.encoding.downcase\n if encoding_from_xml_instruct == \"utf-8\"\n # REXML has a tendency to report utf-8 overzealously, take with\n # grain of salt\n encoding_from_xml_instruct = nil\n end\n rescue\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if encoding_from_xml_instruct.blank?\n sniff_table = {\n \"Lo\\247\\224\" => \"ebcdic-cp-us\",\n \"<?xm\" => \"utf-8\"\n }\n sniff = self.feed_data[0..3]\n if sniff_table[sniff] != nil\n @encoding_from_feed_data = sniff_table[sniff].downcase\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if @encoding_from_feed_data.blank?\n # Safest assumption\n @encoding_from_feed_data = \"utf-8\"\n end\n end\n return @encoding_from_feed_data\n end",
"def is_multibyte(charset)\n charset == 0x31\n end",
"def encoding(encoding); end",
"def can_encode?(str)\n str.nil? || !(GSM_REGEX =~ str).nil?\n end",
"def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend",
"def is_ustring?(); @type == GRT_USTRING; end",
"def can_encode?\n !@encoding_map.empty?\n end",
"def external_utf8_check?(safe_path)\n iconv = system('command -v iconv > /dev/null 2>&1')\n return false unless iconv\n\n path = SafeFile.safepath_to_string(safe_path)\n system(\"iconv -f UTF-8 #{Shellwords.escape(path)} > /dev/null 2>&1\")\n end",
"def iconv() end",
"def detect_charset(path)\n Process.run_command 'uchardet', path\n rescue Errno::ENOENT\n # :nocov:\n Process.run_command('encguess', path).sub(/^.*\\s+/, '')\n # :nocov:\n end",
"def check_utf8(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"utf-8\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def encoding_error?(parser = T.unsafe(nil)); end",
"def determine_encodings!(*)\n @encoding ||= super\n end",
"def test_self_to_nfc_encoding\n assert_equal @unistr_up.NFC.encoding, Encoding::UTF_8\n end",
"def test_to_norm_usascii\n result = ::UTF8Proc.normalize(@asciistr)\n assert_equal @asciistr, result\n assert_equal result.encoding, Encoding::US_ASCII unless jruby?\n refute_same @asciistr, result\n end",
"def encoded?\n self.encoded.not_nil?\n end",
"def handle_encoding str\n str = str.dup\n has_enc = str.respond_to? :encoding # TODO: remove\n encoding = nil\n\n header = str.each_line.first(2)\n header.map! { |s| s.force_encoding \"ASCII-8BIT\" } if has_enc\n\n first = header.first || \"\"\n encoding, str = +\"utf-8\", str.b[3..-1] if first =~ /\\A\\xEF\\xBB\\xBF/\n\n encoding = $1.strip if header.find { |s|\n s[/^#.*?-\\*-.*?coding:\\s*([^ ;]+).*?-\\*-/, 1] ||\n s[/^#.*(?:en)?coding(?:\\s*[:=])\\s*([\\w-]+)/, 1]\n }\n\n if encoding then\n if has_enc then\n encoding.sub!(/utf-8-.+$/, \"utf-8\") # HACK for stupid emacs formats\n hack_encoding str, encoding\n else\n warn \"Skipping magic encoding comment\"\n end\n else\n # nothing specified... ugh. try to encode as utf-8\n hack_encoding str if has_enc\n end\n\n str\n end",
"def external_encoding; @_external_encoding || _external_encoding; end",
"def vowel?\n kor.jungsung? self\n end",
"def iseuc;\tKconv.iseuc(self) end",
"def html_encoding?(html)\n chunk = html[0..1024]\n\n charset = nil\n chunk.split(/\\n/).each do |l|\n m = /Content-Type.*\"(.*?)\"/i.match(l)\n if m && m[1]\n return encoding_from_content_type(m[1])\n end\n end\n nil\n end",
"def encoding\n # noop?\n end",
"def utf8(string)\n string.force_encoding('utf-8') unless string.nil?\n end",
"def iconv(to_charset, from_charset)\n failed = false\n begin\n converted = Iconv.new(to_charset, from_charset).iconv(self)\n rescue Iconv::IllegalSequence\n case from_charset.downcase\n when 'us-ascii'\n # Some mailers do not send a charset when it should be CP1252,\n # the default Windows Latin charset\n begin\n converted = Iconv.new(to_charset, 'cp1252').iconv(self)\n rescue Iconv::IllegalSequence\n failed = true\n end\n when 'ks_c_5601-1987'\n # Microsoft products erroneously use this for what should be CP949\n # see http://tagunov.tripod.com/cjk.html\n begin\n converted = Iconv.new(to_charset, 'cp949').iconv(self)\n rescue Iconv::IllegalSequence, Iconv::InvalidCharacter\n failed = true\n end\n else\n failed = true\n end\n rescue Iconv::InvalidCharacter\n if self =~ /\\n$/\n # Some messages can come in with a superfluous new line on the end,\n # which screws up the encoding. (ISO-2022-JP for example.)\n begin\n converted = Iconv.new(to_charset, 'iso-2022-jp').iconv(self.chomp) + \"\\n\"\n rescue Iconv::InvalidCharacter\n converted = self.tr(\"\\200-\\377\", \"\\041\")\n end\n else\n converted = self.tr(\"\\200-\\377\", \"\\041\")\n end\n end\n\n if failed\n begin\n converted = Iconv.new(to_charset + '//IGNORE', from_charset).iconv(self)\n rescue Iconv::InvalidCharacter\n converted = self.tr(\"\\200-\\377\", \"\\041\")\n end\n end\n\n converted\n end",
"def encoding\n e = param('ENCODING')\n\n if e\n if e.length > 1\n raise Vpim::InvalidEncodingError, \"multi-valued param 'ENCODING' (#{e})\"\n end\n e = e.first.upcase\n end\n e\n end",
"def wide_latin?\n codepoint.wide_latin?\n end",
"def check_utf8\n if params.has_key? 'utf8' and params['utf8'] != '✓'\n render text: 'Bad Request', status: 400\n end\n end",
"def any_hebrew?\n case self.encoding\n when Encoding::UTF_8\n self.each_codepoint {|cp| return true if is_hebrew_codepoint_utf8(cp) }\n return false\n when Encoding::WINDOWS_1255 || Encoding::CP1255\n self.each_codepoint {|cp| return true if is_hebrew_codepoint_cp1255(cp) }\n return false\n else\n return false\n end\n end",
"def multibyte?\n @multibyte\n end",
"def supported_internal_encoding?\n SUPPORTED_INTERNAL_ENCODINGS.include?(Encoding.default_internal)\n end",
"def process_encoding(source)\n source.force_encoding(Encoding::UTF_8)\n end",
"def detect_encodings(hint_enc=nil)\n detector = CharlockHolmes::EncodingDetector.new\n detector.detect_all(self, hint_enc)\n end",
"def is_ascii_character?\n dup.force_encoding(\"binary\")[0].ord < 128\n end",
"def ucern_email?(email)\n email.subject =~ UCERN_SUBJECT\n end",
"def ascii?\n ! self.unicode?\n end",
"def russian?(some_code)\n if some_code.length < 2\n eurasian?(some_code)\n else\n eurasian?(some_code) && !kazakh?(some_code)\n end\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def encodings; end",
"def fix_encoding(encoding)\n case encoding\n # ISO-8859-15, ISO-2022-JP and alike\n when /iso-?(\\d{4})-?(\\w{1,2})/i then return \"ISO-#{$1}-#{$2}\"\n # ISO_8859-15, ISO_2022-JP and alike\n when /iso_?(\\d{4})-?(\\w{1,2})/i then return \"ISO-#{$1}-#{$2}\"\n # \"ISO-2022-JP-KDDI\" and alike\n when /iso-?(\\d{4})-?(\\w{1,2})-?(\\w*)/i then return \"ISO-#{$1}-#{$2}-#{$3}\"\n # utf-8 and alike\n when /utf-?(.*)/i then return \"UTF-#{$1}\"\n # Windows-1252 and alike\n when /Windows-?(.*)/i then return \"Windows-#{$1}\"\n #more aliases to be added if needed\n else return encoding\n end\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def encoding(value = nil)\n value ? @encoding = value : @encoding\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def to_utf8(s)\n return nil if s.nil?\n\n # Attempt to politely transcode the string.\n s.encode(\"UTF-8\").scrub\n rescue\n # If that doesn't work, then overwrite the existing encoding and\n # clobber any strange characters.\n s.force_encoding(\"UTF-8\").scrub\n end",
"def iconv(charset)\n encode(charset, fallback: ->(c) { UTF8_TO_ASCII[c] || \"?\" })\n end",
"def from_native_charset(s, code, ignore_encoding_error = T.unsafe(nil), log = T.unsafe(nil)); end",
"def fix_encoding(output)\n output[/test/] # Running a regexp on the string throws error if it's not UTF-8\n rescue ArgumentError\n output.force_encoding(\"ISO-8859-1\")\n end",
"def is_persian(str)\n str =~ /\\p{Arabic}/\n end",
"def charset\n #@data.charset ||= CharGuess.guess(document).downcase\n end",
"def mime_type_charset_detecter(mime_type)\n if type = config[:mime_types][mime_type]\n if detect = type[:charset]\n return detect\n end\n end\n end",
"def encoding\n if @encoding.blank?\n if !self.http_headers.blank?\n if self.http_headers['content-type'] =~ /charset=([\\w\\d-]+)/\n @encoding = $1.downcase\n else\n @encoding = self.encoding_from_feed_data\n end \n else\n @encoding = self.encoding_from_feed_data\n end\n end\n return @encoding\n end",
"def test_encoding\n assert_equal \"UTF-8\", @conn.encoding\n end",
"def so_encoding(feature)\n if hash = @data[feature]\n if hash[\"encoding\"]\n return hash[\"encoding\"]\n end\n end\n end",
"def test_encoding\n assert_equal 'UTF-8', @conn.encoding\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def external_encoding()\n #This is a stub, used for indexing\n end",
"def japanese?\n !!(self =~ /\\p{Katakana}|\\p{Hiragana}/)\n end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end"
] |
[
"0.69005686",
"0.64844155",
"0.64839894",
"0.64839894",
"0.6385234",
"0.6375801",
"0.6375801",
"0.6300701",
"0.62573624",
"0.62573624",
"0.61445403",
"0.61025894",
"0.60882515",
"0.60882515",
"0.6062549",
"0.60594136",
"0.60585016",
"0.60305655",
"0.5958203",
"0.5911284",
"0.5911284",
"0.5891785",
"0.58530146",
"0.5828015",
"0.5809073",
"0.5722364",
"0.56664157",
"0.5627806",
"0.56194973",
"0.55976033",
"0.55174786",
"0.55100596",
"0.54965746",
"0.5484816",
"0.5446058",
"0.54222643",
"0.5389293",
"0.5386111",
"0.5369076",
"0.53379744",
"0.5320899",
"0.5288599",
"0.5280573",
"0.52733845",
"0.52339333",
"0.5223648",
"0.5207251",
"0.5199082",
"0.5190569",
"0.51777345",
"0.5173355",
"0.5163617",
"0.5152015",
"0.5142809",
"0.513952",
"0.5119359",
"0.51174325",
"0.51002884",
"0.5086101",
"0.5070461",
"0.50697154",
"0.50657725",
"0.5043243",
"0.50371516",
"0.50355464",
"0.50354165",
"0.5031817",
"0.5031085",
"0.5029138",
"0.5001118",
"0.49727684",
"0.4966924",
"0.49609548",
"0.49500299",
"0.49500299",
"0.4949517",
"0.49492222",
"0.4945139",
"0.49384928",
"0.4930928",
"0.491404",
"0.49136525",
"0.48976442",
"0.48716345",
"0.48671594",
"0.48667586",
"0.48658612",
"0.4862425",
"0.4857224",
"0.48564038",
"0.4852713",
"0.48523083",
"0.48523083",
"0.4841176",
"0.48337772",
"0.48322767",
"0.48168963",
"0.4809514",
"0.47988185",
"0.47988185"
] |
0.62073314
|
10
|
callseq: Kconv.issjis(str) > obj or nil Returns whether input encoding is Shift_JIS or not. Note don't expect this return value is MatchData.
|
def issjis(str)
RegexpShiftjis.match( str )
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def issjis;\tKconv.issjis(self) end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def sjis_to_jis(sjis)\n hi = (sjis >> 8) & 0xff\n lo = sjis & 0xff\n return lo if hi == 0\n hi -= (hi<=0x9f) ? 0x71 : 0xb1\n hi = hi * 2 + 1\n lo -= (lo > 0x7f) ? 1 : 0\n hi += (lo >= 0x9e) ? 1 : 0\n lo -= (lo >= 0x9e) ? 0x7d : 0x1f\n return hi << 8 | lo\nend",
"def tosjis; Kconv.tosjis(self) end",
"def tojis; Kconv.tojis(self) end",
"def tosjis(str)\n ::NKF::nkf('-sm', str)\n end",
"def iseuc(str)\n RegexpEucjp.match( str )\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def japanese?\n !!(self =~ /\\p{Katakana}|\\p{Hiragana}/)\n end",
"def check_utf8_encoding\n return nil if self.encoding != Encoding.find('utf-8')\n state = :s0\n n_of_chars = 0\n self.bytes.each do |byte|\n case state\n when :s0\n n_of_chars += 1\n if (0x00..0x7F).include?(byte) then state = :s0\n elsif (0xC2..0xDF).include?(byte) then state = :s1\n elsif 0xE0 == byte then state = :s2\n elsif (0xE1..0xEC).include?(byte) || (0xEE..0xEF).include?(byte) then state = :s3\n elsif 0xED == byte then state = :s4\n elsif 0xF0 == byte then state = :s5\n elsif (0xF1..0xF3).include?(byte) then state = :s7\n elsif 0xF4 == byte then state = :s8\n else return nil end\n when :s1\n if (0x80..0xBF).include?(byte) then state = :s0 \n else return nil end\n when :s2\n if (0xA0..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s3\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s4\n if (0x80..0x9F).include?(byte) then state = :s1\n else return nil end\n when :s5\n if (0x90..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s6\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s7\n if (0x80..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s8\n if (0x80..0x8F).include?(byte) then state = :s6\n else return nil end\n end # case\n end # self.bytes.each\n if state == :s0 then return n_of_chars\n else return nil end\n end",
"def can_encode?(str)\n str.nil? || !(GSM_REGEX =~ str).nil?\n end",
"def issn\n suffix.scan(/^(?:(?:j\\.|issn\\.)|S|\\(ISSN\\))?(\\d{4}-\\d{3}[\\dx])\\b/i).flatten.first\n end",
"def found_encoding; end",
"def found_encoding; end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def isutf8(str)\n RegexpUtf8.match( str )\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def can_encode?(str, charset: BASIC_CHARSET)\n !str || !!(regex(charset) =~ str)\n end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def single_issn\n return nil unless issn.present?\n return issn.first if issn.is_a?(Array)\n return JSON.parse(issn)&.first if issn.start_with?('[')\n\n issn\n end",
"def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end",
"def encoding_found; end",
"def encoding_found; end",
"def normalize_issn(input, options={})\n content = options[:content] || \"__content__\"\n\n issn = if input.blank?\n nil\n elsif input.is_a?(String) && options[:content].nil?\n input\n elsif input.is_a?(Hash)\n input.fetch(content, nil)\n elsif input.is_a?(Array)\n a = input.find { |a| a[\"media_type\"] == \"electronic\" } || input.first\n a.fetch(content, nil)\n end\n\n case issn.to_s.length\n when 9\n issn\n when 8\n issn[0..3] + \"-\" + issn[4..7]\n else\n nil\n end\n end",
"def is_roman?\n @input.is_a? String\n end",
"def issn\n issn = @pubmed['IS'].strip\n if ! issn.blank?\n issn_array=issn.split(\"\\n\")\n issn = \"\"\n issn_array.each do |issn_item|\n if issn_item =~ /linking/i\n issn_item =~ /([0-9]+-[0-9]+[0-9X])/\n issn = $&\n break\n end\n end\n end\n issn\n end",
"def find_encoding(encoding); end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end",
"def encode_for_excel(s)\n s.encode(default_encoding, invalid: :replace, undef: :replace)\n end",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def is_i?(s)\n !!(s =~ /\\A[-+]?[0-9]+\\z/)\n end",
"def is_utf8?\n ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message.scrub =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def is_italicized()\n validate_worksheet\n if @workbook.fonts[font_id()][:font][:i].nil?\n false\n else\n true\n end\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def has_kanji_entry?(d)\n d.has_kind?(Rkanren::KANJI)\n end",
"def parse_ikkatsuline\n s0 = @scanner.pos\n if match_str('|') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s3 = parse_masu\n if s3 == :failed\n s2 = :failed\n else\n s2 = []\n while s3 != :failed\n s2 << s3\n s3 = parse_masu\n end\n end\n if s2 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str('|') != :failed\n s4 = parse_nonls!\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif parse_nl != :failed\n @reported_pos = s0\n s0 = s2\n else\n @scanner.pos = s0\n s0 = :failed\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n end\n\n s0\n end",
"def valid?(cnpj)\n if cnpj.is_a? String\n orig_valid?(cnpj.to_i)\n else\n orig_valid?(cnpj)\n end\n end",
"def is_nikkud(c)\n self.class.is_nikkud_by_encoding(c, self.encoding) # delegate to class method based on instance encoding\n end",
"def is? str\n !!match(str)\n end",
"def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end",
"def try_with_encoding(string, encoding); end",
"def try_with_encoding(string, encoding); end",
"def html_encoding?(html)\n chunk = html[0..1024]\n\n charset = nil\n chunk.split(/\\n/).each do |l|\n m = /Content-Type.*\"(.*?)\"/i.match(l)\n if m && m[1]\n return encoding_from_content_type(m[1])\n end\n end\n nil\n end",
"def isNiktoScan(payload)\n if payload.scan(/Nikto/i).length > 0\n return true\n elsif payload.scan(/\\x4E\\x69\\x6B\\x74\\x6F/).length > 0\n return true\n else\n return false\n end\nend",
"def handle_encoding str\n str = str.dup\n has_enc = str.respond_to? :encoding # TODO: remove\n encoding = nil\n\n header = str.each_line.first(2)\n header.map! { |s| s.force_encoding \"ASCII-8BIT\" } if has_enc\n\n first = header.first || \"\"\n encoding, str = +\"utf-8\", str.b[3..-1] if first =~ /\\A\\xEF\\xBB\\xBF/\n\n encoding = $1.strip if header.find { |s|\n s[/^#.*?-\\*-.*?coding:\\s*([^ ;]+).*?-\\*-/, 1] ||\n s[/^#.*(?:en)?coding(?:\\s*[:=])\\s*([\\w-]+)/, 1]\n }\n\n if encoding then\n if has_enc then\n encoding.sub!(/utf-8-.+$/, \"utf-8\") # HACK for stupid emacs formats\n hack_encoding str, encoding\n else\n warn \"Skipping magic encoding comment\"\n end\n else\n # nothing specified... ugh. try to encode as utf-8\n hack_encoding str if has_enc\n end\n\n str\n end",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def is_multibyte(charset)\n charset == 0x31\n end",
"def hackerrankInString(str)\n expected_chars = %w[h a c k e r r a n k]\n input_chars = str.chars\n\n str.chars.each do |char|\n # Thought so, apparently not: Edge case: there should be no more chars after the last 'k' in hackerrank.\n # break if expected_chars.empty?\n\n input_chars.shift\n expected_chars.shift if char == expected_chars[0]\n end\n\n expected_chars.empty? && input_chars.empty? ? 'YES' : 'NO'\nend",
"def from_native_charset(s, code, ignore_encoding_error = T.unsafe(nil), log = T.unsafe(nil)); end",
"def sierra_code\n match = SierraCodeZcodeMatch.find_by_zcode(code)\n return nil if !match\n\n return match.sierra_code\n end",
"def issn\n generate_barcode('barcode.issn')\n end",
"def is_s?\n true if String(self) rescue false\n end",
"def ascii?\n ASCII_ENCODINGS.include?(encoding)\n end",
"def SmileyExist(smiley)\n uri = URI('http://www.emoji-cheat-sheet.com/graphics/emojis/'+smiley+'.png')\n res = Net::HTTP.get_response(uri)\n\n if res.code == '200'\n return true\n else\n return false\n end\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def issn_array\n return nil unless issn.present?\n return issn if issn.is_a?(Array)\n return JSON.parse(issn) if issn.start_with?('[')\n\n [issn]\n end",
"def code_unwrapper str\n str.unpack('a' * str.length).map { |code| code == '1' }\n end",
"def encoding_error?(parser = T.unsafe(nil)); end",
"def valid_utf8?(str)\n valid_utf8_bson?(str)\n end",
"def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend",
"def encoded?\n self.encoded.not_nil?\n end",
"def check_utf8(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"utf-8\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def valid_utf8?(str)\n @connection.valid_utf8?(str)\n end",
"def jruby?\n JRUBY\n end",
"def is_sticker_code?\n self.scan(/^\\[\\[[0-9]{4,}\\]\\]$/).any?\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def get_data(imei)\n unless valid?(imei)\n @errors << 'IMEI invalid'\n return false\n end\n begin\n content = open(\"https://selfsolve.apple.com/wcResults.do?sn=#{imei}&num=0\") { |f| f.read }.split(\"\\n\")\n rescue StandardError => e\n @errors << e.message\n return false\n end\n\n parse(content)\n end",
"def SmileyExist(smiley, animated = false)\n if animated\n uri = URI('http://' + Animated_Smiley_URI + '/images/Skype/'+ smiley + '.gif')\n else\n uri = URI('http://' + General_Smiley_URI + '/graphics/emojis/' + smiley + '.png')\n end\n\n res = Net::HTTP.get_response(uri)\n \n if res.code == '200'\n return true\n else\n return false\n end\n end",
"def have_encoding?\n Object.const_defined? :Encoding\n end",
"def consume_isa\n position = 0\n buffer = \" \"\n\n # @todo: This would probably more optimal if it was written like\n # consume(\"I\") >>= consume_prefix(\"S\") >>= consume_prefix(\"A\")\n while @input.defined_at?(position)\n character = @input.at(position)\n position += 1\n\n unless Reader.is_control_character?(character)\n # Slide the \"window\" forward one character\n buffer = buffer.slice(1..-1)\n buffer = buffer + character.upcase\n if buffer == \"ISA\"\n return success(advance(position))\n end\n end\n end\n\n failure(\"reached end of input before finding ISA segment identifier\")\n end",
"def is_int? str\n Integer(str) rescue return false\n return true\nend",
"def wide_latin?\n codepoint.wide_latin?\n end",
"def is_integer str\n return str.class == Fixnum || str == str.to_i.to_s\n end",
"def is_knj?\n return true\n end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def issn; end",
"def ===(s)\n if (s.is_a?(StringScanner))\n s.scan(self)\n else\n super(s)\n end\n end",
"def is_integer(str)\n Integer(str) != nil rescue false\n end",
"def solve(encoding)\r\n cnf_formula = make_cnf_formula(encoding)\r\n \r\n # Try solving the formula using the SAT solver\r\n #\r\n sat_solver = SatSolver.new(cnf_formula)\r\n result = sat_solver.solve_without_search(:failed_literal => true)\r\n \r\n if result[0] == :sat\r\n update_board_from_solution(result[1])\r\n \r\n if board_solved?\r\n return true\r\n else\r\n fail \"Error: SAT Solution invalid\"\r\n end\r\n else\r\n return false\r\n end\r\n end",
"def exists?(s)\n final = true\n index = @trie\n s.each_char do |c|\n tindex = index.dup\n r = 0\n tindex = tindex[c]\n if tindex == nil\n r += 1\n end\n\n jindex = index.dup\n current = c.swapcase\n jindex = jindex[current]\n if jindex == nil\n r += 2\n end\n\n if r == 1\n index = jindex\n elsif r == 2\n index = tindex\n else\n return false\n end\n end\n return true\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def count_syllables(str)\n\tstr = str.downcase\n\tarr = str.split('')\n\tsentry = arr[0]\n\tsyllable = arr[0]\n\tarr.shift\n\tarr.each do |n| \n\t\tif n == sentry\n\t\t\tbreak \n\t\telse\n\t\t syllable += n \n\t\tend\n\tend\n\tstr.scan(syllable).size\nend",
"def hydrate_iss_keys(iss)\n uri = iss.sub(%r{[\\/]+$}, '') + well_known\n json = json_req uri.to_s\n body = json_req json['jwks_uri']\n\n raise InvalidKey, \"no valid JWK found, #{json['jwks_uri']}\" if body['keys']&.blank?\n\n keys = body['keys'].select { |key| valid_key(key) }\n hydrate_store(keys, iss)\n end",
"def test_to_norm_usascii\n result = ::UTF8Proc.normalize(@asciistr)\n assert_equal @asciistr, result\n assert_equal result.encoding, Encoding::US_ASCII unless jruby?\n refute_same @asciistr, result\n end",
"def iseuc;\tKconv.iseuc(self) end",
"def detect_charset(path)\n Process.run_command 'uchardet', path\n rescue Errno::ENOENT\n # :nocov:\n Process.run_command('encguess', path).sub(/^.*\\s+/, '')\n # :nocov:\n end",
"def is_i?\n !!( self =~ /\\A[-+]?[0-9]+\\z/ )\n end",
"def iconv(to_charset, from_charset)\n failed = false\n begin\n converted = Iconv.new(to_charset, from_charset).iconv(self)\n rescue Iconv::IllegalSequence\n case from_charset.downcase\n when 'us-ascii'\n # Some mailers do not send a charset when it should be CP1252,\n # the default Windows Latin charset\n begin\n converted = Iconv.new(to_charset, 'cp1252').iconv(self)\n rescue Iconv::IllegalSequence\n failed = true\n end\n when 'ks_c_5601-1987'\n # Microsoft products erroneously use this for what should be CP949\n # see http://tagunov.tripod.com/cjk.html\n begin\n converted = Iconv.new(to_charset, 'cp949').iconv(self)\n rescue Iconv::IllegalSequence, Iconv::InvalidCharacter\n failed = true\n end\n else\n failed = true\n end\n rescue Iconv::InvalidCharacter\n if self =~ /\\n$/\n # Some messages can come in with a superfluous new line on the end,\n # which screws up the encoding. (ISO-2022-JP for example.)\n begin\n converted = Iconv.new(to_charset, 'iso-2022-jp').iconv(self.chomp) + \"\\n\"\n rescue Iconv::InvalidCharacter\n converted = self.tr(\"\\200-\\377\", \"\\041\")\n end\n else\n converted = self.tr(\"\\200-\\377\", \"\\041\")\n end\n end\n\n if failed\n begin\n converted = Iconv.new(to_charset + '//IGNORE', from_charset).iconv(self)\n rescue Iconv::InvalidCharacter\n converted = self.tr(\"\\200-\\377\", \"\\041\")\n end\n end\n\n converted\n end",
"def kana?\n codepoint.kana?\n end",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def is_in_cis?(obj)\n @cis['countries'].include?(obj.is_a?(String) ? obj : obj.country_code)\n end",
"def is_ascii_character?\n dup.force_encoding(\"binary\")[0].ord < 128\n end",
"def ruby_code?(str)\n str = str.to_s\n return false if str.empty?\n checker = FoodCritic::ErrorChecker.new(str)\n checker.parse\n ! checker.error?\n end",
"def russian?(some_code)\n if some_code.length < 2\n eurasian?(some_code)\n else\n eurasian?(some_code) && !kazakh?(some_code)\n end\n end"
] |
[
"0.7661919",
"0.6343163",
"0.6321212",
"0.59379035",
"0.58789",
"0.5490069",
"0.52220505",
"0.4881004",
"0.47428605",
"0.46546423",
"0.46505144",
"0.4622918",
"0.46080738",
"0.46080738",
"0.45883483",
"0.4574256",
"0.4567638",
"0.45228842",
"0.44611442",
"0.44537628",
"0.44511318",
"0.4419525",
"0.4419525",
"0.43700156",
"0.43418884",
"0.43269166",
"0.43208742",
"0.43067044",
"0.43020427",
"0.42942122",
"0.4272859",
"0.4268869",
"0.42615634",
"0.42454523",
"0.4237104",
"0.4204244",
"0.41675875",
"0.41675875",
"0.41600126",
"0.41485527",
"0.41417417",
"0.41366926",
"0.41309044",
"0.41308004",
"0.4125099",
"0.4125099",
"0.41147837",
"0.40902025",
"0.4074579",
"0.40698838",
"0.4056834",
"0.40545657",
"0.40395936",
"0.4033092",
"0.40231827",
"0.4012552",
"0.40101153",
"0.40069118",
"0.3972639",
"0.39705563",
"0.396069",
"0.39502668",
"0.39254403",
"0.39188582",
"0.39138374",
"0.3910405",
"0.39095017",
"0.38789985",
"0.38715154",
"0.38683993",
"0.38664225",
"0.38664225",
"0.38461593",
"0.3834093",
"0.38276866",
"0.38208917",
"0.38163665",
"0.38105634",
"0.38024786",
"0.38011643",
"0.37977624",
"0.37894377",
"0.37795568",
"0.37776127",
"0.37771004",
"0.3765563",
"0.3753024",
"0.37518668",
"0.37514606",
"0.37508506",
"0.37477604",
"0.37405238",
"0.37373295",
"0.3725019",
"0.37112162",
"0.371062",
"0.3700564",
"0.36994615",
"0.368084",
"0.36803353"
] |
0.8358608
|
0
|
callseq: Kconv.isutf8(str) > obj or nil Returns whether input encoding is UTF8 or not. Note don't expect this return value is MatchData.
|
def isutf8(str)
RegexpUtf8.match( str )
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def isutf8;\tKconv.isutf8(self) end",
"def valid_utf8?(str)\n valid_utf8_bson?(str)\n end",
"def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end",
"def is_utf8?\n ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)\n end",
"def valid_utf8?(str)\n @connection.valid_utf8?(str)\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def valid_utf_8_bytes?(string)\n original_encoding = string.encoding\n valid = string.force_encoding(Encoding::UTF_8).valid_encoding?\n string.force_encoding(original_encoding)\n valid\n end",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def check_utf8(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"utf-8\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def try_utf8!(string, encoding = ::Encoding::UTF_8)\n return nil unless string\n string.force_encoding(::Encoding::ASCII_8BIT) unless string.force_encoding(encoding).valid_encoding?\n string\n end",
"def check_utf8_encoding\n return nil if self.encoding != Encoding.find('utf-8')\n state = :s0\n n_of_chars = 0\n self.bytes.each do |byte|\n case state\n when :s0\n n_of_chars += 1\n if (0x00..0x7F).include?(byte) then state = :s0\n elsif (0xC2..0xDF).include?(byte) then state = :s1\n elsif 0xE0 == byte then state = :s2\n elsif (0xE1..0xEC).include?(byte) || (0xEE..0xEF).include?(byte) then state = :s3\n elsif 0xED == byte then state = :s4\n elsif 0xF0 == byte then state = :s5\n elsif (0xF1..0xF3).include?(byte) then state = :s7\n elsif 0xF4 == byte then state = :s8\n else return nil end\n when :s1\n if (0x80..0xBF).include?(byte) then state = :s0 \n else return nil end\n when :s2\n if (0xA0..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s3\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s4\n if (0x80..0x9F).include?(byte) then state = :s1\n else return nil end\n when :s5\n if (0x90..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s6\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s7\n if (0x80..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s8\n if (0x80..0x8F).include?(byte) then state = :s6\n else return nil end\n end # case\n end # self.bytes.each\n if state == :s0 then return n_of_chars\n else return nil end\n end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def can_encode?(str, charset: BASIC_CHARSET)\n !str || !!(regex(charset) =~ str)\n end",
"def utf8(string)\n string.force_encoding('utf-8') unless string.nil?\n end",
"def have_encoding?\n Object.const_defined? :Encoding\n end",
"def check_utf8\n if params.has_key? 'utf8' and params['utf8'] != '✓'\n render text: 'Bad Request', status: 400\n end\n end",
"def external_utf8_check?(safe_path)\n iconv = system('command -v iconv > /dev/null 2>&1')\n return false unless iconv\n\n path = SafeFile.safepath_to_string(safe_path)\n system(\"iconv -f UTF-8 #{Shellwords.escape(path)} > /dev/null 2>&1\")\n end",
"def is_equal_to_utf8cstring(a,b)\n JavaScriptCore::Lib.JSStringIsEqualToUTF8CString(a,b)\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def found_encoding; end",
"def found_encoding; end",
"def enc_utf8\n\n @@enc_utf8 ||= \n ( Encoding.find( \"utf-8\" ) or raise \"No utf-8 encoding found (?!)\" )\nend",
"def is_ustring?(); @type == GRT_USTRING; end",
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def to_utf8(s)\n return nil if s.nil?\n\n # Attempt to politely transcode the string.\n s.encode(\"UTF-8\").scrub\n rescue\n # If that doesn't work, then overwrite the existing encoding and\n # clobber any strange characters.\n s.force_encoding(\"UTF-8\").scrub\n end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def utf8(string)\n string.force_encoding(Encoding::UTF_8)\n end",
"def convert_to_utf8(input)\n if input.is_a?(Hash)\n record = {}\n input.each do |key, value|\n record[convert_to_utf8(key)] = convert_to_utf8(value)\n end\n\n return record\n end\n return input.map { |value| convert_to_utf8(value) } if input.is_a?(Array)\n return input unless input.respond_to?(:encode)\n\n if @coerce_to_utf8\n input.encode(\n 'utf-8',\n invalid: :replace,\n undef: :replace,\n replace: @non_utf8_replacement_string)\n else\n begin\n input.encode('utf-8')\n rescue EncodingError\n @log.error 'Encountered encoding issues potentially due to non ' \\\n 'UTF-8 characters. To allow non-UTF-8 characters and ' \\\n 'replace them with spaces, please set \"coerce_to_utf8\" ' \\\n 'to true.'\n raise\n end\n end\n end",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def find_encoding(encoding); end",
"def encoding_found; end",
"def encoding_found; end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def ascii?\n ASCII_ENCODINGS.include?(encoding)\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def multibyte?\n @multibyte\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def valid_value?\n if ape_type == 'utf8' || ape_type == 'external'\n # :nocov:\n if RUBY_VERSION >= '1.9'\n # :nocov:\n begin\n map!{|v| v.to_s.encode('UTF-8')}\n rescue EncodingError\n return false\n end\n end\n string_value.unpack('U*')\n end\n rescue ArgumentError\n false\n else\n true\n end",
"def is_multibyte(charset)\n charset == 0x31\n end",
"def unicode?\n self.local =~ /[^\\p{InBasicLatin}]/ ? true : false\n end",
"def string?(input)\n input.class == String\nend",
"def eightchar?(string)\n if string.length <= 8\n return false\n else\n return true\n end\nend",
"def try_with_encoding(string, encoding); end",
"def try_with_encoding(string, encoding); end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message.scrub =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\n rescue StandardError\n nil\n end",
"def ascii?\n ! self.unicode?\n end",
"def toutf8; Kconv.toutf8(self) end",
"def to_utf8(v)\n return v unless v.is_a?(String)\n return v if (enc = v.encoding) == (utf = Encoding::UTF_8)\n Encoding::Converter.new(enc, utf).convert(v) rescue v.dup.force_encoding(utf)\nend",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend",
"def is_ascii_character?\n dup.force_encoding(\"binary\")[0].ord < 128\n end",
"def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end",
"def can_encode?(str)\n str.nil? || !(GSM_REGEX =~ str).nil?\n end",
"def test_encoding\n assert_equal \"UTF-8\", @conn.encoding\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def test_encoding\n assert_equal 'UTF-8', @conn.encoding\n end",
"def handle_encoding str\n str = str.dup\n has_enc = str.respond_to? :encoding # TODO: remove\n encoding = nil\n\n header = str.each_line.first(2)\n header.map! { |s| s.force_encoding \"ASCII-8BIT\" } if has_enc\n\n first = header.first || \"\"\n encoding, str = +\"utf-8\", str.b[3..-1] if first =~ /\\A\\xEF\\xBB\\xBF/\n\n encoding = $1.strip if header.find { |s|\n s[/^#.*?-\\*-.*?coding:\\s*([^ ;]+).*?-\\*-/, 1] ||\n s[/^#.*(?:en)?coding(?:\\s*[:=])\\s*([\\w-]+)/, 1]\n }\n\n if encoding then\n if has_enc then\n encoding.sub!(/utf-8-.+$/, \"utf-8\") # HACK for stupid emacs formats\n hack_encoding str, encoding\n else\n warn \"Skipping magic encoding comment\"\n end\n else\n # nothing specified... ugh. try to encode as utf-8\n hack_encoding str if has_enc\n end\n\n str\n end",
"def encode_as_utf8(obj)\n if obj.is_a? Hash\n obj.each_pair do |key, val|\n encode_as_utf8(val)\n end\n elsif obj.is_a?(Array)\n obj.each do |val|\n encode_as_utf8(val)\n end\n elsif obj.is_a?(String) && obj.encoding != Encoding::UTF_8\n if !obj.force_encoding(\"UTF-8\").valid_encoding?\n obj.force_encoding(\"ISO-8859-1\").encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end\n obj\n end",
"def is_string?(); @type == GRT_STRING; end",
"def html_encoding?(html)\n chunk = html[0..1024]\n\n charset = nil\n chunk.split(/\\n/).each do |l|\n m = /Content-Type.*\"(.*?)\"/i.match(l)\n if m && m[1]\n return encoding_from_content_type(m[1])\n end\n end\n nil\n end",
"def string?\n data_type == String\n end",
"def encoding_error?(parser = T.unsafe(nil)); end",
"def check_binary(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"binary\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def binary?\n BINARY_ENCODINGS.include?(encoding)\n end",
"def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end",
"def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end",
"def string?(str)\n str.is_a?(String)\n end",
"def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end",
"def force_utf8(buf)\n return buf if buf.valid_encoding?\n buf.force_encoding('ISO-8859-1').encode('UTF-8', 'UTF-8', replace: nil)\n end",
"def ===(string)\n return false unless string.respond_to?(:each_byte)\n\n string.each_byte do |b|\n return false unless include?(b)\n end\n\n return true\n end",
"def unicode?\n \"\\u2501\" != 'u2501'\n end",
"def count_multibyte_char(str)\n str.each_char.select{ |c| c.bytesize > 1 }.count\nend",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def is_string(input)\n input.kind_of?(String)\n end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def to_utf8(raw_text)\n if raw_text.platform_id == 1 && raw_text.encoding_id == 0\n return raw_text\n else\n begin\n raw_text.encode(\"UTF-8\", \"UTF-16BE\")\n rescue\n raw_text\n end\n end\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def is_string\n return @is_string\n end",
"def is? str\n !!match(str)\n end",
"def process_encoding(source)\n source.force_encoding(Encoding::UTF_8)\n end",
"def is_wildcard_char? str\n self.class.is_wildcard_char? str\n end",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def safe_encode_utf8(text)\n text.force_encoding('ASCII-8BIT').encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :universal_newline => true)\nend",
"def is_strtype?(); @type == GRT_STRTYPE; end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding\n Encoding::UTF_8\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\nend",
"def wp_check_invalid_utf8(string, strip = false)\n string = string.to_s\n\n return '' if string == ''\n\n # Store the site charset as a static to avoid multiple calls to get_option()\n is_utf8 = nil\n\n if is_utf8.nil? # TODO because it's called from a module function, it cannot access get_option from the helper\n is_utf8 = true # ['utf8', 'utf-8', 'UTF8', 'UTF-8'].include?(get_option('blog_charset'))\n end\n return string unless is_utf8\n\n # Check for support for utf8 in the installed PCRE library once and store the result in a static\n utf8_pcre = nil\n if utf8_pcre.nil?\n utf8_pcre = 'a'.match(/^./u)\n end\n # We can't demand utf8 in the PCRE installation, so just return the string in those cases\n return string unless utf8_pcre.nil?\n\n # preg_match fails when it encounters invalid UTF8 in $string\n return string unless string.match(/^./us).nil?\n\n # TODO continue implement function wp_check_invalid_utf8\n # # Attempt to strip the bad chars if requested (not recommended)\n # if ( strip && function_exists( 'iconv' ) )\n # return iconv( 'utf-8', 'utf-8', string )\n # end\n #\n\t ''\n end",
"def has_ansi?(str)\n str.match(ANSI_MATCHR).is_a?(\n MatchData\n )\n end"
] |
[
"0.80969024",
"0.78433543",
"0.78011835",
"0.76702",
"0.766819",
"0.7629463",
"0.7629463",
"0.7285058",
"0.7136782",
"0.6962411",
"0.67771316",
"0.66091025",
"0.64248896",
"0.6385777",
"0.63589907",
"0.62616825",
"0.62520456",
"0.61481845",
"0.61409163",
"0.6046982",
"0.6046982",
"0.60302204",
"0.5993175",
"0.5993175",
"0.598577",
"0.5945694",
"0.59423614",
"0.59133404",
"0.58615553",
"0.5827987",
"0.58013666",
"0.58013666",
"0.5798824",
"0.5793669",
"0.57804966",
"0.57221985",
"0.5680886",
"0.5680886",
"0.56773794",
"0.56606406",
"0.564953",
"0.5617741",
"0.56122285",
"0.56119657",
"0.5607757",
"0.55764407",
"0.5563842",
"0.5561695",
"0.5551212",
"0.55486196",
"0.55486196",
"0.5547048",
"0.5533884",
"0.5523717",
"0.5477331",
"0.5455606",
"0.5454927",
"0.5446307",
"0.54308414",
"0.54283154",
"0.5416392",
"0.5415036",
"0.54104954",
"0.5406208",
"0.54017955",
"0.5398167",
"0.5389121",
"0.5377746",
"0.5348466",
"0.5334145",
"0.5324012",
"0.53170526",
"0.531391",
"0.5304054",
"0.5297106",
"0.5290618",
"0.5288099",
"0.5281231",
"0.5260755",
"0.5250763",
"0.52415526",
"0.5239678",
"0.5237044",
"0.52224684",
"0.5214806",
"0.5181909",
"0.51781213",
"0.5169464",
"0.51490486",
"0.5140028",
"0.51253754",
"0.5112708",
"0.51102614",
"0.51071835",
"0.510684",
"0.510684",
"0.5104006",
"0.50894046",
"0.5086057",
"0.5081735"
] |
0.80582535
|
1
|
to Encoding callseq: Stringtojis > string Convert self to ISO2022JP Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('jxm0', str).
|
def tojis; Kconv.tojis(self) end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def tosjis; Kconv.tosjis(self) end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def toutf8; Kconv.toutf8(self) end",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def reencode_string(input); end",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def kana2kana(str1)\n result = []\n str2 = Kana2rom::hira_to_kata(str1)\n str3 = Kana2rom::kata_to_hira(str1)\n result << str1\n result << str2 if str2.length > 0 and str1 !=str2\n result << str3 if str3.length > 0 and str2 !=str3 and str3 != str1\n return result\n end",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def encode(string); end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def to_arabic(string_with_kansuji, type = nil)\n Parser.to_arabic(string_with_kansuji, type)\n end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def to_utf8!; replace(to_utf8); end",
"def issjis(str)\n RegexpShiftjis.match( str )\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def encode_string; end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def encode(str)\n\tswap_raw = \"GA-DE-RY-PO-LU-KI\".reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.split(\"-\")\n\tencoder = Hash.new\n\tswap_raw.each { |pair| encoder[pair[0]] = pair[1] }\n\tencoded_string = \"\"\n\tputs encoder\n\tfor char in str.split(\"\")\n\t\tif encoder.key?(char) #correct?\n\t\t\tencoded_string += encoder[char]\n\t\telse\n\t\t\tencoded_string += char\n\t\tend\n\tend\n\treturn encoded_string\nend",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def iconv() end",
"def issjis;\tKconv.issjis(self) end",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def encode_string_ex; end",
"def encode(s)\n return s if s.nil?\n return s if s.valid_encoding?\n if s.force_encoding(\"iso-8859-1\").valid_encoding?\n return s.encode('utf-8', 'iso-8859-1')\n end\n s\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def encode(immune, input)\n return nil if input.nil?\n encoded_string = ''\n encoded_string.encode!(Encoding::UTF_8)\n input.encode(Encoding::UTF_8).chars do |c|\n encoded_string << encode_char(immune,c)\n end\n encoded_string\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def to_arabic(string_with_kansuji, type = nil)\n string_with_kansuji.gsub(kansuji_regxep) do |matched|\n case type\n when :mixed_arabic\n Kansuji.to_kansuji(to_i(matched), :mixed_arabic)\n else\n to_i(matched).to_s\n end\n end\n end",
"def unicode_filter_encode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_encode(str) : str\n end",
"def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def convert_encoding(content); end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def to_ascii(string)\n require 'unidecode'\n\n begin\n #string.unpack(\"U*\").map{|c|c.chr}.join\n #Iconv.iconv(\"US-ASCII//TRANSLIT\", \"UTF-8\", string).first\n Unidecoder.decode(string).gsub(\"[?]\", \"\").gsub(/`/, \"'\").strip\n \n \n rescue => errmsg\n p errmsg\n string\n end\n end",
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def decode_string(str)\n\nend",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def tosjis(str)\n ::NKF::nkf('-sm', str)\n end",
"def encode_string s\n s.downcase.split(//).inject(\"\") do |code,char|\n code + encode_char(char)\n end\n end",
"def to_utf7(s)\n return force_encoding(force_encoding(s, 'UTF-8').gsub(/(&)|([^\\x20-\\x7e]+)/u) {\n if $1\n \"&-\"\n else\n base64 = [$&.unpack(\"U*\").pack(\"n*\")].pack(\"m\")\n \"&\" + base64.delete(\"=\\n\").tr(\"/\", \",\") + \"-\"\n end\n }, \"ASCII-8BIT\")\n end",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def to_utf8(text)\n replaced = text\n unless replaced.nil?\n replaced = replaced.force_encoding(\"UTF-8\") if is_ascii_8bit?(replaced)\n replaced = cleanup_utf8(replaced)\n end\n replaced\n end",
"def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend",
"def to_ascii!; replace(to_ascii); end",
"def convert_string string\n return string unless @in_b or @in_em\n chars = if @in_b then\n string.chars.map do |char| \"#{char}\\b#{char}\" end\n elsif @in_em then\n string.chars.map do |char| \"_\\b#{char}\" end\n end\n\n chars.join\n end",
"def fix_encoding(str)\n str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)\n str\nend",
"def fix_encoding(encoding)\n case encoding\n # ISO-8859-15, ISO-2022-JP and alike\n when /iso-?(\\d{4})-?(\\w{1,2})/i then return \"ISO-#{$1}-#{$2}\"\n # ISO_8859-15, ISO_2022-JP and alike\n when /iso_?(\\d{4})-?(\\w{1,2})/i then return \"ISO-#{$1}-#{$2}\"\n # \"ISO-2022-JP-KDDI\" and alike\n when /iso-?(\\d{4})-?(\\w{1,2})-?(\\w*)/i then return \"ISO-#{$1}-#{$2}-#{$3}\"\n # utf-8 and alike\n when /utf-?(.*)/i then return \"UTF-#{$1}\"\n # Windows-1252 and alike\n when /Windows-?(.*)/i then return \"Windows-#{$1}\"\n #more aliases to be added if needed\n else return encoding\n end\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def to_utf8(mixed)\n if mixed.kind_of? Array\n mixed.each {|elem| to_utf8(elem)}\n else mixed.kind_of? String\n charset = NKF.guess(mixed).name\n charset == \"UTF-8\" ? mixed : mixed.encode!(\"UTF-8\", charset)\n end\n mixed\n end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def mobile_encoding\n\t'ISO-8859-1'\nend",
"def try_with_encoding(string, encoding); end",
"def try_with_encoding(string, encoding); end",
"def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end",
"def _encode_string(string)\n return string unless string.kind_of? String\n string.encode(\"UTF-8\", :undef => :replace, :invalid => :replace, :replace => \"?\")\n end",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end",
"def encode(input_string)\n return input_string.tr(\"a-z\", \"n-za-m\")\nend",
"def string_encoder\n return string if string.valid_encoding?\n str = string\n Encoding.list.each do |e|\n begin\n str.force_encoding(e.name)\n tmp_string = str.encode('UTF-8')\n return tmp_string if tmp_string.valid_encoding?\n rescue\n Rails.logger.debug { \"Rescue -> #{e.name}\" } if defined?(::Rails)\n end\n end\n\n impossible_encoding\n\n string\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def encode_for_excel(s)\n s.encode(default_encoding, invalid: :replace, undef: :replace)\n end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def latin\n @input = I18n.transliterate(@input)\n end"
] |
[
"0.72973675",
"0.6658342",
"0.65902394",
"0.65656745",
"0.6443691",
"0.6428121",
"0.64044416",
"0.6237717",
"0.60328895",
"0.6001594",
"0.59991425",
"0.5940418",
"0.59331274",
"0.59236026",
"0.591415",
"0.58946717",
"0.5888195",
"0.5881566",
"0.5857376",
"0.5840343",
"0.58389086",
"0.5825264",
"0.5820171",
"0.57795423",
"0.5773037",
"0.5769679",
"0.57677907",
"0.5745483",
"0.57430255",
"0.5740489",
"0.5735759",
"0.5727622",
"0.5688817",
"0.5679468",
"0.56793416",
"0.567324",
"0.56699204",
"0.5664873",
"0.5664195",
"0.5661794",
"0.5656636",
"0.56472266",
"0.56433696",
"0.56326354",
"0.56313914",
"0.56257856",
"0.5604579",
"0.56018275",
"0.56002766",
"0.5597999",
"0.55954695",
"0.5589643",
"0.55738074",
"0.5571757",
"0.55543566",
"0.55385953",
"0.5507773",
"0.550145",
"0.5484132",
"0.54813355",
"0.5476033",
"0.5457845",
"0.54307085",
"0.54136723",
"0.5407769",
"0.54055244",
"0.54055244",
"0.54008555",
"0.53918964",
"0.538404",
"0.5379945",
"0.53691614",
"0.53688467",
"0.5363491",
"0.5363491",
"0.5363491",
"0.5363491",
"0.5363491",
"0.53632903",
"0.53632903",
"0.53614134",
"0.53614134",
"0.53596425",
"0.53596425",
"0.53560036",
"0.53533775",
"0.53533775",
"0.5353074",
"0.53528965",
"0.5347312",
"0.5332808",
"0.5332724",
"0.53304917",
"0.5328309",
"0.5322447",
"0.53077275",
"0.5304205",
"0.52966726",
"0.52686965",
"0.52645993"
] |
0.6933535
|
1
|
callseq: Stringtoeuc > string Convert self to EUCJP Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('exm0', str).
|
def toeuc; Kconv.toeuc(self) end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def toutf8; Kconv.toutf8(self) end",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def to_ascii(string)\n require 'unidecode'\n\n begin\n #string.unpack(\"U*\").map{|c|c.chr}.join\n #Iconv.iconv(\"US-ASCII//TRANSLIT\", \"UTF-8\", string).first\n Unidecoder.decode(string).gsub(\"[?]\", \"\").gsub(/`/, \"'\").strip\n \n \n rescue => errmsg\n p errmsg\n string\n end\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def toeuc(str)\n ::NKF::nkf('-em', str)\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def iconv() end",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def convert_string string\n return string unless @in_b or @in_em\n chars = if @in_b then\n string.chars.map do |char| \"#{char}\\b#{char}\" end\n elsif @in_em then\n string.chars.map do |char| \"_\\b#{char}\" end\n end\n\n chars.join\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def to_arabic(string_with_kansuji, type = nil)\n Parser.to_arabic(string_with_kansuji, type)\n end",
"def normalize string\r\n begin\r\n string.dup.force_encoding('UTF-8')\r\n rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e\r\n # @todo Improve error handling\r\n Solargraph::Logging.logger.warn \"Normalize error: #{e.message}\"\r\n string\r\n end\r\n end",
"def to_ascii(string)\n\t\tstring.unpack(\"U*\").map do |c| \n\t\t\tc.chr if c < 128\n\t\tend.join\n\tend",
"def isutf8;\tKconv.isutf8(self) end",
"def unicode(str)\n\t\tRex::Text.to_unicode(str)\n\tend",
"def convert_text!(text, error_handler)\n text = AnselToUnicode.new(error_handler, true).convert(text) if convert_marc8_to_utf8?\n\n # Turn Horizon's weird escaping into UTF8: <U+nnnn> where nnnn is a hex unicode\n # codepoint, turn it UTF8 for that codepoint\n if settings[\"horizon.destination_encoding\"] == \"UTF8\" &&\n (settings[\"horizon.codepoint_translate\"].to_s == \"true\" ||\n settings[\"horizon.character_reference_translate\"].to_s == \"true\")\n\n regexp = if settings[\"horizon.codepoint_translate\"].to_s == \"true\" && settings[\"horizon.character_reference_translate\"].to_s == \"true\"\n # unicode codepoint in either HTML char reference form OR\n # weird horizon form. \n /(?:\\<U\\+|&#x)([0-9A-Fa-f]{4})(?:\\>|;)/\n elsif settings[\"horizon.codepoint_translate\"].to_s == \"true\"\n # just weird horizon form\n /\\<U\\+([0-9A-Fa-f]{4})\\>/\n else # just character references\n /&#x([0-9A-Fa-f]{4});/\n end\n \n text.gsub!(regexp) do\n [$1.hex].pack(\"U\")\n end\n end\n\n # eliminate illegal control chars. All ASCII less than 0x20\n # _except_ for four legal ones (including MARC delimiters). \n # http://www.loc.gov/marc/specifications/specchargeneral.html#controlfunction\n # this is all bytes from 0x00 to 0x19 except for the allowed 1B, 1D, 1E, 1F. \n text.gsub!(/[\\x00-\\x1A\\x1C]/, '')\n\n return text\n end",
"def аватар text\n Data.emoji(text, exact: false, number: 0, lang: :ru)\n end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def convert (str)\r\n# REFERENCE : Using logic from this source https://stackoverflow.com/questions/13498688/pig-latin-method-translation\r\n alpha = ('a'..'z').to_a\r\n vowels = %w[a e i o u]\r\n consonants = alpha - vowels\r\n lstr = str.downcase\r\n if vowels.include?(lstr[0])\r\n str + 'way'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1]) && consonants.include?(lstr[2])\r\n str[3..-1] + str[0..2] + 'ay'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1])\r\n str[2..-1] + str[0..1] + 'ay'\r\n elsif consonants.include?(lstr[0])\r\n str[1..-1] + str[0] + 'ay'\r\n else\r\n str # return unchanged\r\n end\r\nend",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def iseuc(str)\n RegexpEucjp.match( str )\n end",
"def return_in_latin(input)\n input.tr('αβεηικμνορτχυζ'.upcase, 'abehikmnoptxyz'.upcase) \n end",
"def reencode_string(input); end",
"def test_to_norm_usascii\n result = ::UTF8Proc.normalize(@asciistr)\n assert_equal @asciistr, result\n assert_equal result.encoding, Encoding::US_ASCII unless jruby?\n refute_same @asciistr, result\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def emoji; end",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def encode(immune, input)\n return nil if input.nil?\n encoded_string = ''\n encoded_string.encode!(Encoding::UTF_8)\n input.encode(Encoding::UTF_8).chars do |c|\n encoded_string << encode_char(immune,c)\n end\n encoded_string\n end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def to_ascii!; replace(to_ascii); end",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def encode_string_ex; end",
"def to_utf8!; replace(to_utf8); end",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def codepoint\n unless $KCODE =~ /^u/i\n raise ArgumentError, \"unsupported encoding (#{$KCODE})\"\n end\n unless jlength == 1\n raise RangeError, \"string must be exactly one character long\"\n end\n \n\t case self.length\n \twhen 1\n \t UCSCodepoint.new(self[0])\n \twhen 2\n \t UCSCodepoint.new(\n \t ((self[0] & 0x1f) << 6) +\n \t (self[1] & 0x3f)\n \t )\n \twhen 3\n \t UCSCodepoint.new(\n \t ((self[0] & 0x0f) << 12) +\n \t ((self[1] & 0x3f) << 6) +\n \t (self[2] & 0x3f)\n \t )\n \twhen 4\n \t UCSCodepoint.new(\n \t ((self[0] & 0x07) << 18) +\n \t ((self[1] & 0x3f) << 12) +\n \t ((self[2] & 0x3f) << 6) +\n \t (self[3] & 0x3f)\n \t )\n \tend\n end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def tuc(arg)\n h = Hash.[](\".\"=>\"་\", \"/\"=>\"།\", \";\"=>\"༔\", \"\"=>\"\",\n \"ka\"=>\"ཀ\", \"kha\"=>\"ཁ\", \"ga\"=>\"ག\", \"nga\"=>\"ང\",\n \"ca\"=>\"ཅ\", \"cha\"=>\"ཆ\", \"ja\"=>\"ཇ\", \"nya\"=>\"ཉ\",\n \"ta\"=>\"ཏ\", \"tha\"=>\"ཐ\", \"da\"=>\"ད\", \"na\"=>\"ན\",\n \"pa\"=>\"པ\", \"pha\"=>\"ཕ\", \"ba\"=>\"བ\", \"ma\"=>\"མ\",\n \"tsa\"=>\"ཙ\", \"tsha\"=>\"ཚ\", \"dza\"=>\"ཛ\", \"wa\"=>\"ཝ\",\n \"zha\"=>\"ཞ\", \"za\"=>\"ཟ\", \"'a\"=>\"འ\", \"ya\"=>\"ཡ\",\n \"ra\"=>\"ར\", \"la\"=>\"ལ\", \"sha\"=>\"ཤ\", \"sa\"=>\"ས\",\n \"ha\"=>\"ཧ\", \"a\"=>\"ཨ\",\n # numbers !!! better include number_generator\n \"0\"=>\"༠\", \"1\"=>\"༡\", \"2\"=>\"༢\", \"3\"=>\"༣\",\n \"4\"=>\"༤\", \"5\"=>\"༥\", \"6\"=>\"༦\", \"7\"=>\"༧\",\n \"8\"=>\"༨\", \"9\"=>\"༩\",\n # vowel signs\n \".e\"=>\"ེ\", \".i\"=>\"ི\", \".o\"=>\"ོ\", \".u\"=>\"ུ\",\n # double vowel signs\n \"E\" => \"ཻ\", \"O\" => \"ཽ\",\n # subscribed characters\n \"x_ka\"=>\"ྐ\", \"x_kha\"=>\"ྑ\", \"x_ga\"=>\"ྒ\", \"x_nga\"=>\"ྔ\",\n \"x_ca\"=>\"ྕ\", \"x_cha\"=>\"ྖ\", \"x_ja\"=>\"ྗ\", \"x_nya\"=>\"ྙ\",\n \"x_ta\"=>\"ྟ\", \"x_tha\"=>\"ྐ\", \"x_da\"=>\"ྡ\", \"x_na\"=>\"ྣ\",\n \"x_pa\"=>\"ྤ\", \"x_pha\"=>\"ྥ\", \"x_ba\"=>\"ྦ\", \"x_ma\"=>\"ྨ\",\n \"x_tsa\"=>\"ྩ\", \"x_tsha\"=>\"ྪ\", \"x_dza\"=>\"ྫ\", \"x_wa\"=>\"ྭ\",\n \"x_zha\"=>\"ྮ\", \"x_za\"=>\"ྯ\", \"x_'a\"=>\"ཱ\", \"x_ya\"=>\"ྱ\",\n \"x_ra\"=>\"ྲ\", \"x_la\"=>\"ླ\", \"x_sha\"=>\"ྴ\", \"x_sa\"=>\"ྶ\",\n \"x_ha\"=>\"ྷ\", \"x_a\"=>\"ྸ\",\n # superscribed character\n \"ra_x\"=>\"ར\",\n # revered letters\n \"Ta\"=>\"ཊ\", \"Tha\" => \"ཋ\", \"Da\" => \"ཌ\", \"Na\" => \"ཎ\",\n \"Sha\" => \"ཥ\")\n\n result = h[arg]\n if result != nil\n erg = result\n else\n erg = \"\"\n end\n return erg\n end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def encode(string); end",
"def to_arabic(string_with_kansuji, type = nil)\n string_with_kansuji.gsub(kansuji_regxep) do |matched|\n case type\n when :mixed_arabic\n Kansuji.to_kansuji(to_i(matched), :mixed_arabic)\n else\n to_i(matched).to_s\n end\n end\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def replace_invalid_characters(str)\n utf8_string = SUPPORTED_ENCODINGS.include?(str.encoding)\n return str if utf8_string && str.valid_encoding?\n\n temp_str = str.dup\n temp_str.encode!(TEMP_ENCODING, **ENCODING_OPTIONS) if utf8_string\n temp_str.encode!('utf-8', **ENCODING_OPTIONS)\n end",
"def to_unicode(string)\n SimpleIDN.to_unicode(string)\n end",
"def he_decode(text); self.class.he_decode text; end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def decode_string(str)\n\nend",
"def unicode_filter_encode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_encode(str) : str\n end",
"def encode(input_string)\n return input_string.tr(\"a-z\", \"n-za-m\")\nend",
"def to_utf\n begin\n Iconv.new(\"utf-8\", \"cp1251\").iconv(self)\n rescue Iconv::IllegalSequence => e\n STDERR << \"!! Failed converting from UTF-8 -> cp1251 (#{self}). Already the right charset?\"\n self\n end\n end",
"def decoder(string)\n string.gsub(/(WUB)+/, ' ').strip\nend",
"def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def decode(string)\n if string.class != String\n return \"Input is not a string\"\n else\n string_array = string.downcase.split('')\n alphabet_array = \"abcdefghijklmnopqrstuvwxyz\".split('')\n new_string = \"\"\n string_array.map! do |x|\n letter_index = alphabet_array.index(x)\n if x =~ /[A-Za-z]/\n alphabet_array[-letter_index-1]\n else\n x\n end\n end\n final_string = string_array.join('')\n end\n if final_string =~ /\\s/\n final_string_array = final_string.split('? ')\n final_string_array.map! do |x|\n x.capitalize\n end\n final_string_array.join('? ')\n else\n final_string\n end\nend",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def tojis; Kconv.tojis(self) end",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def latin\n @input = I18n.transliterate(@input)\n end",
"def to_english(string)\nend",
"def unicode_text(pdf, str, options={})\n pdf.text(e(\"\\xfe\\xff#{str}\", :encoding => 'UTF-16BE'), options) # start Unicode UTF-16BE encoding\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def convert(string)\n\t# Adding space to handle words that end in a unicode character\n\tstring += \" \"\n\n\tword = \"\"\n\tunicode = false\n\tuni_string = \"\"\n\n\t# puts \"Starting each char...\"\n\tstring.each_char do |char|\n\t\t\n\t\t# puts \"char: #{char}\"\n\n\t\tif char != \"\\\\\" and !unicode\n\t\t\t# puts \"Adding #{char} to word\"\n\t\t\tword += convert_char(char)\n\n\t\telsif char == \"\\\\\"\n\t\t\t# puts \"Starting unicode string\"\n\t\t\tuni_string = \"\\\\\"\n\t\t\tunicode = true\n\n\t\telsif char != \" \" and unicode\n\t\t\t# puts \"Putting #{char} in unicode string: #{uni_string}\"\n\t\t\tuni_string += char\n\n\t\telsif unicode and char == \" \"\n\t\t\t# puts \"Found end of unicode string: #{uni_string}\"\n\t\t\tword += convert_char(uni_string)\n\t\t\tuni_string = \"\"\n\t\t\tunicode = false\n\t\telse\n\t\t\tputs \"Not sure what to do with #{char}\"\n\t\tend\n\tend\n\n\t# Strip to remove extra spaces\n\treturn word.strip\n\nend",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def decoder(message)\n translated = message\n translated.gsub!(/\\w/).each do |letter|\n if letter.ord + 13 < 122\n letter.gsub!(letter, (letter.ord + 13).chr)\n else\n letter.gsub!(letter, (letter.ord-13).chr)\n end\n end\nend",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def get_unicode_of(character)\n character.unpack('U*').first.to_s(16).rjust(4, '0').upcase\nend",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def special2csa(str)\n {\n '中断' => 'CHUDAN',\n '投了' => 'TORYO',\n '持将棋' => 'JISHOGI',\n '千日手' => 'SENNICHITE',\n '詰み' => 'TSUMI',\n '不詰' => 'FUZUMI',\n '切れ負け' => 'TIME_UP',\n '反則勝ち' => 'ILLEGAL_ACTION', # 直前の手が反則(先頭に+か-で反則した側の情報を含める必要が有る)\n '反則負け' => 'ILLEGAL_MOVE' # ここで手番側が反則,反則の内容はコメントで表現\n }[str] || (raise ParseError)\n end",
"def convert(str)\n\t\t@result=convert_han(convert_words(str))\n\t\t# @result=convert_words(str)\n\t\t@result.gsub!(\" #%\",\"\")\n\t\t@result.gsub!(\"%# \",\"\")\n\t\t@result\n\tend",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def encode_string; end"
] |
[
"0.63241917",
"0.6312091",
"0.62795883",
"0.62537575",
"0.6230468",
"0.61383516",
"0.61236346",
"0.61236346",
"0.6008206",
"0.6007853",
"0.60051024",
"0.5998348",
"0.5972655",
"0.595269",
"0.5906833",
"0.58974916",
"0.5888481",
"0.5876529",
"0.58731574",
"0.58645785",
"0.5827313",
"0.58218956",
"0.58093345",
"0.5805185",
"0.5805078",
"0.57841694",
"0.57836777",
"0.57777995",
"0.57720464",
"0.5768571",
"0.57656693",
"0.57593685",
"0.57410574",
"0.5740874",
"0.57404065",
"0.5734977",
"0.57348317",
"0.5730467",
"0.57279664",
"0.5726311",
"0.5720134",
"0.5710042",
"0.5701775",
"0.56784105",
"0.5677082",
"0.56677926",
"0.5663527",
"0.56634843",
"0.56620336",
"0.56484646",
"0.5630631",
"0.56100553",
"0.5606544",
"0.5579686",
"0.55710614",
"0.55702436",
"0.5569598",
"0.555934",
"0.5543743",
"0.5542557",
"0.55408794",
"0.553989",
"0.55361646",
"0.5524356",
"0.55088645",
"0.5505266",
"0.5505259",
"0.54958075",
"0.54916656",
"0.54827344",
"0.54691005",
"0.5467995",
"0.5467029",
"0.54616326",
"0.5448844",
"0.5443789",
"0.5435832",
"0.5434434",
"0.54201436",
"0.54070026",
"0.5406859",
"0.54062957",
"0.54062957",
"0.54057205",
"0.5398106",
"0.5392346",
"0.5387537",
"0.53791165",
"0.5375191",
"0.5372828",
"0.5369996",
"0.5369029",
"0.53527486",
"0.53232974",
"0.5320802",
"0.53144246",
"0.5305122",
"0.530487",
"0.5304604",
"0.52804095"
] |
0.588238
|
17
|
callseq: Stringtosjis > string Convert self to Shift_JIS Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('sxm0', str).
|
def tosjis; Kconv.tosjis(self) end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def tojis; Kconv.tojis(self) end",
"def issjis(str)\n RegexpShiftjis.match( str )\n end",
"def sjis_to_jis(sjis)\n hi = (sjis >> 8) & 0xff\n lo = sjis & 0xff\n return lo if hi == 0\n hi -= (hi<=0x9f) ? 0x71 : 0xb1\n hi = hi * 2 + 1\n lo -= (lo > 0x7f) ? 1 : 0\n hi += (lo >= 0x9e) ? 1 : 0\n lo -= (lo >= 0x9e) ? 0x7d : 0x1f\n return hi << 8 | lo\nend",
"def issjis;\tKconv.issjis(self) end",
"def tosjis(str)\n ::NKF::nkf('-sm', str)\n end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def encode_for_excel(s)\n s.encode(default_encoding, invalid: :replace, undef: :replace)\n end",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def energetic_encoding(str, hsh)\n new_str = str.split(\"\").map do |char| \n if hsh.key?(char)\n hsh[char] \n elsif char != \" \"\n \"?\"\n else\n char\n end\n end\n\n new_str.join(\"\")\nend",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def reencode_string(input); end",
"def processString(s=@orig_string) \n # All LaTeX Macron codes begin with an '=' token. Scan for that using a \n # RegEx. The value is set to firstSlash. \n \n firstSlash = s =~ /(\\\\=.*?\\})/\n return s if $1.nil?\n \n testChar = $1\n \n # In the event that the first character is macron-bearing follow this \n # case. \n if firstSlash == 0\n return processChar(testChar).to_s +\n processString(s[firstSlash+testChar.length..s.length])\n end\n \n # In the more general case, we take the original string up to the first\n # macron-beginning-slash. We return that + running processChar on the\n # remainder of the string, that is return part_ok +\n # processString(the_rest).\n \n return s[0..firstSlash-1] + processChar(testChar).to_s +\n processString(s[firstSlash+testChar.length..s.length])\n end",
"def toutf8; Kconv.toutf8(self) end",
"def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def kana2kana(str1)\n result = []\n str2 = Kana2rom::hira_to_kata(str1)\n str3 = Kana2rom::kata_to_hira(str1)\n result << str1\n result << str2 if str2.length > 0 and str1 !=str2\n result << str3 if str3.length > 0 and str2 !=str3 and str3 != str1\n return result\n end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def iconv() end",
"def energetic_encoding(str, hash)\n str.chars.map! do |char| \n if char == \" \"\n char\n elsif hash[char].nil?\n \"?\"\n else\n hash[char]\n end\n end.join(\"\")\nend",
"def store_japanese_string(string)\n string = string.gsub(/[\\n\\r\\t ]+/, \" \")\n\n string.each_char do |c|\n w = if c.ascii_only? then 1 else 2 end\n\n @elements << Box.new(width: w, value: c)\n @elements << Glue.new(width: 1, shrink: 1, stretch: 1)\n end\n\n @elements.pop # Remove last glue element\n # Add unconditional break at the end of paragraph\n @elements << Glue(width: 0, shrink: Infinity, stretch: 0)\n @elements << Penaty(width: 0, penalty: -Infinity, flagged: 1)\n end",
"def encode(string); end",
"def isutf8;\tKconv.isutf8(self) end",
"def codepoint\n unless $KCODE =~ /^u/i\n raise ArgumentError, \"unsupported encoding (#{$KCODE})\"\n end\n unless jlength == 1\n raise RangeError, \"string must be exactly one character long\"\n end\n \n\t case self.length\n \twhen 1\n \t UCSCodepoint.new(self[0])\n \twhen 2\n \t UCSCodepoint.new(\n \t ((self[0] & 0x1f) << 6) +\n \t (self[1] & 0x3f)\n \t )\n \twhen 3\n \t UCSCodepoint.new(\n \t ((self[0] & 0x0f) << 12) +\n \t ((self[1] & 0x3f) << 6) +\n \t (self[2] & 0x3f)\n \t )\n \twhen 4\n \t UCSCodepoint.new(\n \t ((self[0] & 0x07) << 18) +\n \t ((self[1] & 0x3f) << 12) +\n \t ((self[2] & 0x3f) << 6) +\n \t (self[3] & 0x3f)\n \t )\n \tend\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def width(str, cjk = false)\n raise NotImplementedError\n end",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def encode_string_ex; end",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer,len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end",
"def additional_encoding(s)\n encoding_hash = {\":\" => \"%3A\", \"+\" => \"%2B\"}\n encoding_hash.each_pair do |k, v|\n s.gsub!(k, v)\n end\n s\n end",
"def convert_encoding(content); end",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def do_encoding(string)\n ## removing newline (needed for pty/expect newlines)\n string[0, 2] = '' if string.start_with? \"\\r\\n\"\n string[0, 3] = '' if string.start_with? \"\\r\\r\\n\"\n string.gsub!(\"\\r\\n\", \"\\n\")\n # string.chomp!\n string\n end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def encode_string; end",
"def encode_string s\n s.downcase.split(//).inject(\"\") do |code,char|\n code + encode_char(char)\n end\n end",
"def force_encoding(*); self; end",
"def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer, len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end",
"def weirdFixString(str)\n idx = str.index(\"\\000\\000\")\n idx.nil? ? str : str[0..idx]\n end",
"def to_utf7(s)\n return force_encoding(force_encoding(s, 'UTF-8').gsub(/(&)|([^\\x20-\\x7e]+)/u) {\n if $1\n \"&-\"\n else\n base64 = [$&.unpack(\"U*\").pack(\"n*\")].pack(\"m\")\n \"&\" + base64.delete(\"=\\n\").tr(\"/\", \",\") + \"-\"\n end\n }, \"ASCII-8BIT\")\n end",
"def kan2n2(s)\n case s.length\n when 1\n '〇一二三四五六七八九十'.index(s)\n when 2\n '〇一二三四五六七八九十'.index(s[1]) + 10\n else\n raise '21以上の数値に対応していません'\n end\n end",
"def do_encoding_terminal(string)\n string = string.to_s\n string.gsub!(\"\\r\\r\", \"\\r\")\n string.gsub!(\"\\r\\n\", \"\\n\")\n string.gsub!(\"\\r\\$\\s\", \"\")\n\n string.gsub!(/.\\r/, \"\")\n string.gsub!(/\\x1B\\[\\d*?[ABCDsuKJ]/, '')\n string\n end",
"def encode(str)\n\tswap_raw = \"GA-DE-RY-PO-LU-KI\".reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.reverse.split(\"-\") + \"GA-DE-RY-PO-LU-KI\".split(\"-\") + \"GA-DE-RY-PO-LU-KI\".downcase.split(\"-\")\n\tencoder = Hash.new\n\tswap_raw.each { |pair| encoder[pair[0]] = pair[1] }\n\tencoded_string = \"\"\n\tputs encoder\n\tfor char in str.split(\"\")\n\t\tif encoder.key?(char) #correct?\n\t\t\tencoded_string += encoder[char]\n\t\telse\n\t\t\tencoded_string += char\n\t\tend\n\tend\n\treturn encoded_string\nend",
"def special2csa(str)\n {\n '中断' => 'CHUDAN',\n '投了' => 'TORYO',\n '持将棋' => 'JISHOGI',\n '千日手' => 'SENNICHITE',\n '詰み' => 'TSUMI',\n '不詰' => 'FUZUMI',\n '切れ負け' => 'TIME_UP',\n '反則勝ち' => 'ILLEGAL_ACTION', # 直前の手が反則(先頭に+か-で反則した側の情報を含める必要が有る)\n '反則負け' => 'ILLEGAL_MOVE' # ここで手番側が反則,反則の内容はコメントで表現\n }[str] || (raise ParseError)\n end",
"def konverze s1\n s2 = String.new(s1)\n if WINDOWS == true and KONVERZE == true\n replace(s1,s2,\"\\xec\",\"\\xd8\") # e s hackem\n replace(s1,s2,\"\\xe8\",\"\\x9f\") # c s hackem\n replace(s1,s2,\"\\xf8\",\"\\xfd\") # r s hackem\n\n replace(s1,s2,\"\\xcc\",\"\\xb7\") # E s hackem\n replace(s1,s2,\"\\xc8\",\"\\xac\") # C s hackem\n replace(s1,s2,\"\\xd8\",\"\\xfc\") # R s hackem\n\n replace(s1,s2,\"\\xef\",\"\\xd4\") # d s hackem\n replace(s1,s2,\"\\xf2\",\"\\xe5\") # n s hackem\n replace(s1,s2,\"\\x9d\",\"\\x9c\") # t s hackem\n\n replace(s1,s2,\"\\xcf\",\"\\xd2\") # D s hackem\n replace(s1,s2,\"\\xd2\",\"\\xd5\") # N s hackem\n replace(s1,s2,\"\\x8d\",\"\\x9b\") # T s hackem\n\n replace(s1,s2,\"\\x9e\",\"\\xa7\") # z s hackem\n replace(s1,s2,\"\\x9a\",\"\\xe7\") # s s hackem\n\n replace(s1,s2,\"\\x8e\",\"\\xa6\") # Z s hackem\n replace(s1,s2,\"\\x8a\",\"\\xe6\") # S s hackem\n\n replace(s1,s2,\"\\xe1\",\"\\xa0\") # a s carkou\n replace(s1,s2,\"\\xe9\",\"\\x82\") # e s carkou\n replace(s1,s2,\"\\xed\",\"\\xa1\") # i s carkou\n replace(s1,s2,\"\\xf3\",\"\\xa2\") # o s carkou\n replace(s1,s2,\"\\xfa\",\"\\xa3\") # u s carkou\n replace(s1,s2,\"\\xfd\",\"\\xec\") # y s carkou\n replace(s1,s2,\"\\xf9\",\"\\x85\") # u s krouzkem\n\n replace(s1,s2,\"\\xc1\",\"\\xb5\") # A s carkou\n replace(s1,s2,\"\\xc9\",\"\\x90\") # E s carkou\n replace(s1,s2,\"\\xcd\",\"\\xd6\") # I s carkou\n replace(s1,s2,\"\\xd3\",\"\\xe0\") # O s carkou\n replace(s1,s2,\"\\xda\",\"\\xe9\") # U s carkou\n replace(s1,s2,\"\\xdd\",\"\\xed\") # Y s carkou\n replace(s1,s2,\"\\xd9\",\"\\xde\") # U s kroužkem\n end\n return s2\nend",
"def encode(immune, input)\n return nil if input.nil?\n encoded_string = ''\n encoded_string.encode!(Encoding::UTF_8)\n input.encode(Encoding::UTF_8).chars do |c|\n encoded_string << encode_char(immune,c)\n end\n encoded_string\n end",
"def wide_string(str)\n # if given a nil string, assume caller wants to pass a nil pointer to win32\n return nil if str.nil?\n\n str.encode('UTF-16LE')\n end",
"def unify_voiced_katakana!(src)\n halfwidth =\n Characters::HALFWIDTH_VOICED_KATAKANA +\n Characters::HALFWIDTH_SEMI_VOICED_KATAKANA\n fullwidth =\n Characters::VOICED_KATAKANA +\n Characters::SEMI_VOICED_KATAKANA\n halfwidth.zip(fullwidth).inject(src) do |str, (h, f)|\n str.gsub!(h, f) || str\n end\n end",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def fix_encoding(str)\n str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)\n str\nend",
"def from_native_charset(s, code, ignore_encoding_error = T.unsafe(nil), log = T.unsafe(nil)); end",
"def encode(string)\n string.unpack('B*')[0].tr('01', \" \\n\")\n end",
"def to_utf8!; replace(to_utf8); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend",
"def encode(s)\n return s if s.nil?\n return s if s.valid_encoding?\n if s.force_encoding(\"iso-8859-1\").valid_encoding?\n return s.encode('utf-8', 'iso-8859-1')\n end\n s\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def convert(str)\n\t\t@result=convert_han(convert_words(str))\n\t\t# @result=convert_words(str)\n\t\t@result.gsub!(\" #%\",\"\")\n\t\t@result.gsub!(\"%# \",\"\")\n\t\t@result\n\tend",
"def z_fix_charset\n Iconv.iconv('UTF-8', 'UTF-8', self).first.to_s\n end",
"def north_korean_cipher(coded_message)\n\tinput = coded_message.downcase.split(\"\") # Check out this method in IRB to see how it works! Also refer to the ruby docs.\n\tdecoded_sentence = []\n\tcipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n\t\t\t\t\t\t\"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n\t\t\t\t\t\t\"g\" => \"c\", \n\t\t\t\t\t\t\"h\" => \"d\", \n\t\t\t\t\t\t\"i\" => \"e\", \n\t\t\t\t\t\t\"j\" => \"f\",\n\t\t\t\t\t\t\"k\" => \"g\",\n\t\t\t\t\t\t\"l\" => \"h\",\n\t\t\t\t\t\t\"m\" => \"i\",\n\t\t\t\t\t\t\"n\" => \"j\",\n\t\t\t\t\t\t\"o\" => \"k\",\n\t\t\t\t\t\t\"p\" => \"l\",\n\t\t\t\t\t\t\"q\" => \"m\",\n\t\t\t\t\t\t\"r\" => \"n\",\n\t\t\t\t\t\t\"s\" => \"o\",\n\t\t\t\t\t\t\"t\" => \"p\",\n\t\t\t\t\t\t\"u\" => \"q\",\n\t\t\t\t\t\t\"v\" => \"r\",\n\t\t\t\t\t\t\"w\" => \"s\",\n\t\t\t\t\t\t\"x\" => \"t\",\n\t\t\t\t\t\t\"y\" => \"u\",\n\t\t\t\t\t\t\"z\" => \"v\",\n\t\t\t\t\t\t\"a\" => \"w\",\n\t\t\t\t\t\t\"b\" => \"x\",\n\t\t\t\t\t\t\"c\" => \"y\",\n\t\t\t\t\t\t\"d\" => \"z\"}\n\t\n# This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n# the best data structure for this problem? What are the pros and cons of hashes?\n# \n# We automated this task with our own method that shifts letters automatically. It even allows you to\n# specify the amount the letters need to be shifted. This will output our needed hash, without having to\n# manually write every key/value pair.\n\n\tinput.each do |x| # iterate through each letter in the coded message (input is an array of all letters in order)\n\t\tfound_match = false # If found_match is set to true, the block code \"if not found_match\" will NEVER be executed\n\t\t\t\t\t\t\t\t\t\t\t\t # so the unmapped letter will not be added back to the decoded message\n\t\tcipher.each_key do |y| # iterate through each key in the hash table\n\t\t\tif x == y # compare the current letter in the coded message to the key in the hash table. If they are equals,\n\t\t\t\t\t\t\t\t # meaning the decoded letter is found, add the mapped value to the decoded message\n\t\t\t\tputs \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n\t\t\t\tdecoded_sentence << cipher[y]\n\t\t\t\tfound_match = true\n\t\t\t\tbreak # Once the decoded letter is found, break out of the loop and go for the next letter in the input message\n\t\t\telsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" # If any of these symbols is\n\t\t\t\t# found in the coded message, it is equivalent to a space. These are all OR statements, so if any are found to\n\t\t\t\t# be true, it will run the block of code.\n\t\t\t\tdecoded_sentence << \" \"\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\telsif (0..9).to_a.include?(x) # This puts all the numbers from 0 to 9 into an array and check if that array contains x\n\t\t\t\tdecoded_sentence << x\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\tend \n\t\tend\n\t\tif not found_match # If some character not covered by any of the if statments is found in the coded message\n\t\t# that character is put into the decoded message\n\t\t\tdecoded_sentence << x\n\t\tend\n\tend\n\tdecoded_sentence = decoded_sentence.join(\"\")\n \n\tif decoded_sentence.match(/\\d+/) #Checks the decoded message for any numbers \n\t\tdecoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } # Replaces those numbers with a number divided by 100, because\n\t\t# he has been known to exaggerate about the amount of stuff he has\n\tend \n\treturn decoded_sentence # return the decoded message \nend",
"def to_arabic(string_with_kansuji, type = nil)\n Parser.to_arabic(string_with_kansuji, type)\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end",
"def mobile_encoding\n\t'ISO-8859-1'\nend",
"def to_jtext\n\t\tBangou.integer_to_japanese_text(self)\n\tend",
"def best_mime_encoding\n if self.is_ascii?\n :none\n elsif self.length > (self.mb_chars.length * 1.1)\n :base64\n else\n :quoted_printable\n end\n end",
"def try_with_encoding(string, encoding); end",
"def try_with_encoding(string, encoding); end",
"def to_kanji(dd)\n d1, d2 = dd.length == 1 ? ['0', dd[0]-48] : [dd[0]-48, dd[1]-48]\n case d1 when 0 then ''\n when 1 then 'JUU'\n else to_kanji_single(d1.to_i) ;end \\\n + to_kanji_single(d2.to_s)\nend",
"def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend",
"def to_arabic(string_with_kansuji, type = nil)\n string_with_kansuji.gsub(kansuji_regxep) do |matched|\n case type\n when :mixed_arabic\n Kansuji.to_kansuji(to_i(matched), :mixed_arabic)\n else\n to_i(matched).to_s\n end\n end\n end",
"def force_to_ascii s\n out = \"\"\n s.each_byte do |b|\n if (b & 128) != 0\n out << \"\\\\x#{b.to_s 16}\"\n else\n out << b.chr\n end\n end\n #out.force_encoding Encoding::UTF_8 if in_ruby19_hell? # not necessary?\n out\n end",
"def decode_string(str)\n\nend",
"def found_encoding; end",
"def found_encoding; end"
] |
[
"0.72155315",
"0.6884079",
"0.6802869",
"0.6474498",
"0.64476514",
"0.6105865",
"0.6050587",
"0.6046315",
"0.5992964",
"0.59074646",
"0.5477976",
"0.5462061",
"0.54438055",
"0.5395735",
"0.5376171",
"0.5365735",
"0.53073335",
"0.52386487",
"0.5180197",
"0.51758",
"0.5140072",
"0.5123241",
"0.5112454",
"0.5101578",
"0.50910324",
"0.5090333",
"0.508847",
"0.506101",
"0.50389236",
"0.5037148",
"0.49887627",
"0.49782947",
"0.49772725",
"0.49651802",
"0.49486047",
"0.4934704",
"0.49282074",
"0.49281532",
"0.49223286",
"0.4912175",
"0.48965734",
"0.48952848",
"0.4877043",
"0.48727882",
"0.48713148",
"0.48635012",
"0.4861188",
"0.48559535",
"0.48557156",
"0.4851262",
"0.4831962",
"0.4828185",
"0.48249096",
"0.48042125",
"0.48026472",
"0.48021",
"0.4801361",
"0.48006636",
"0.4795531",
"0.47864962",
"0.47819915",
"0.47791603",
"0.47690952",
"0.47678593",
"0.47569436",
"0.4756191",
"0.47359428",
"0.47251862",
"0.4723187",
"0.47222483",
"0.47211826",
"0.47211826",
"0.47211826",
"0.47211826",
"0.47211826",
"0.47207046",
"0.47207046",
"0.47056627",
"0.4703927",
"0.4679097",
"0.46584788",
"0.46522096",
"0.4646946",
"0.4641816",
"0.461986",
"0.46121994",
"0.4611342",
"0.46072483",
"0.46006012",
"0.45935255",
"0.45896265",
"0.45852265",
"0.45852265",
"0.45847243",
"0.45750445",
"0.45741916",
"0.4573891",
"0.45723507",
"0.45691133",
"0.45691133"
] |
0.6861021
|
2
|
callseq: Stringtoutf8 > string Convert self to UTF8 Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('wxm0', str).
|
def toutf8; Kconv.toutf8(self) end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend",
"def utf8(string)\n string.force_encoding(Encoding::UTF_8)\n end",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def to_utf8!; replace(to_utf8); end",
"def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end",
"def utf8(string)\n string.force_encoding('utf-8') unless string.nil?\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def force_to_utf8(text)\n ActiveSupport::Multibyte::Unicode.tidy_bytes(text)\n end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def to_utf8(text)\n replaced = text\n unless replaced.nil?\n replaced = replaced.force_encoding(\"UTF-8\") if is_ascii_8bit?(replaced)\n replaced = cleanup_utf8(replaced)\n end\n replaced\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end",
"def to_utf8(s)\n return nil if s.nil?\n\n # Attempt to politely transcode the string.\n s.encode(\"UTF-8\").scrub\n rescue\n # If that doesn't work, then overwrite the existing encoding and\n # clobber any strange characters.\n s.force_encoding(\"UTF-8\").scrub\n end",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def unicode(str)\n\t\tRex::Text.to_unicode(str)\n\tend",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def _encode_string(string)\n return string unless string.kind_of? String\n string.encode(\"UTF-8\", :undef => :replace, :invalid => :replace, :replace => \"?\")\n end",
"def to_utf8(raw_text)\n if raw_text.platform_id == 1 && raw_text.encoding_id == 0\n return raw_text\n else\n begin\n raw_text.encode(\"UTF-8\", \"UTF-16BE\")\n rescue\n raw_text\n end\n end\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def normalize string\r\n begin\r\n string.dup.force_encoding('UTF-8')\r\n rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e\r\n # @todo Improve error handling\r\n Solargraph::Logging.logger.warn \"Normalize error: #{e.message}\"\r\n string\r\n end\r\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def to_utf8(v)\n return v unless v.is_a?(String)\n return v if (enc = v.encoding) == (utf = Encoding::UTF_8)\n Encoding::Converter.new(enc, utf).convert(v) rescue v.dup.force_encoding(utf)\nend",
"def unicode_filter_encode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_encode(str) : str\n end",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def reencode_string(input); end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def utf8_safe\n encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def encode(string); end",
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def convert_to_utf8(input)\n if input.is_a?(Hash)\n record = {}\n input.each do |key, value|\n record[convert_to_utf8(key)] = convert_to_utf8(value)\n end\n\n return record\n end\n return input.map { |value| convert_to_utf8(value) } if input.is_a?(Array)\n return input unless input.respond_to?(:encode)\n\n if @coerce_to_utf8\n input.encode(\n 'utf-8',\n invalid: :replace,\n undef: :replace,\n replace: @non_utf8_replacement_string)\n else\n begin\n input.encode('utf-8')\n rescue EncodingError\n @log.error 'Encountered encoding issues potentially due to non ' \\\n 'UTF-8 characters. To allow non-UTF-8 characters and ' \\\n 'replace them with spaces, please set \"coerce_to_utf8\" ' \\\n 'to true.'\n raise\n end\n end\n end",
"def encode_string; end",
"def try_utf8!(string, encoding = ::Encoding::UTF_8)\n return nil unless string\n string.force_encoding(::Encoding::ASCII_8BIT) unless string.force_encoding(encoding).valid_encoding?\n string\n end",
"def to_unicode(string)\n SimpleIDN.to_unicode(string)\n end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def to_utf8(mixed)\n if mixed.kind_of? Array\n mixed.each {|elem| to_utf8(elem)}\n else mixed.kind_of? String\n charset = NKF.guess(mixed).name\n charset == \"UTF-8\" ? mixed : mixed.encode!(\"UTF-8\", charset)\n end\n mixed\n end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def string\n str = basic_string\n if str.respond_to? :force_encoding\n str.force_encoding InternalEncoding\n end\n\n convert(str, @encoding)\n end",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def encode_string(str)\n str = str.to_s.encode('UTF-8')\n\n # Force to binary, when assembling the packet\n str.force_encoding('ASCII-8BIT')\n encode_short(str.bytesize) + str\n end",
"def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end",
"def safe_encode_utf8(text)\n text.force_encoding('ASCII-8BIT').encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :universal_newline => true)\nend",
"def fix_encoding(str)\n str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)\n str\nend",
"def do_encoding(string)\n ## removing newline (needed for pty/expect newlines)\n string[0, 2] = '' if string.start_with? \"\\r\\n\"\n string[0, 3] = '' if string.start_with? \"\\r\\r\\n\"\n string.gsub!(\"\\r\\n\", \"\\n\")\n # string.chomp!\n string\n end",
"def decode_string(str)\n\nend",
"def encode(s)\n return s if s.nil?\n return s if s.valid_encoding?\n if s.force_encoding(\"iso-8859-1\").valid_encoding?\n return s.encode('utf-8', 'iso-8859-1')\n end\n s\n end",
"def utf8safe(text)\n require 'iconv'\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n return ic.iconv(text + ' ')[0..-2]\nend",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def params_toutf8\n all_toutf8!(params)\n end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding\n Encoding::UTF_8\n end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def clean_string_for_json(str)\n str.to_s.force_encoding(UTF8)\n end",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\nend",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\n rescue StandardError\n nil\n end",
"def encode(input)\n return '' if input.nil?\n input.to_s.encode(Encoding::UTF_8)\n rescue Encoding::UndefinedConversionError\n input.dup.force_encoding(Encoding::UTF_8)\n end",
"def mime_decode(str, charset = \"UTF-8\")\n decstr = \"\"\n items = str.split(/\\s/).collect{|c| c.strip}\n items.each_with_index do |item, i|\n if item.empty?\n decstr += \" \"\n next\n end\n decstr += \" \" unless decstr.empty?\n mis = item.scan(/^=\\?(UTF-8|utf-8)\\?(B|b)\\?(.+)\\?=$/).flatten\n if mis.empty?\n decstr += item\n else\n decstr += Base64.decode64(mis[-1])\n end\n end\n return msg_decode(decstr, charset)\n end",
"def to_utf7(s)\n return force_encoding(force_encoding(s, 'UTF-8').gsub(/(&)|([^\\x20-\\x7e]+)/u) {\n if $1\n \"&-\"\n else\n base64 = [$&.unpack(\"U*\").pack(\"n*\")].pack(\"m\")\n \"&\" + base64.delete(\"=\\n\").tr(\"/\", \",\") + \"-\"\n end\n }, \"ASCII-8BIT\")\n end",
"def mb_charify(text)\n if RUBY_VERSION >= '1.9'\n text.dup\n elsif text.respond_to?(:mb_chars)\n text.frozen? ? text.dup.mb_chars : text.mb_chars\n else\n raise \"StringUtils: No unicode support for strings\"\n end\n end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def to_ascii(string)\n require 'unidecode'\n\n begin\n #string.unpack(\"U*\").map{|c|c.chr}.join\n #Iconv.iconv(\"US-ASCII//TRANSLIT\", \"UTF-8\", string).first\n Unidecoder.decode(string).gsub(\"[?]\", \"\").gsub(/`/, \"'\").strip\n \n \n rescue => errmsg\n p errmsg\n string\n end\n end",
"def z_fix_charset\n Iconv.iconv('UTF-8', 'UTF-8', self).first.to_s\n end",
"def convert_string string\n return string unless @in_b or @in_em\n chars = if @in_b then\n string.chars.map do |char| \"#{char}\\b#{char}\" end\n elsif @in_em then\n string.chars.map do |char| \"_\\b#{char}\" end\n end\n\n chars.join\n end",
"def encode_string_ex; end",
"def clean(str)\n st = str.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')\n return st.encode('UTF-8', 'UTF-16')\nend",
"def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end",
"def to_utf\n begin\n Iconv.new(\"utf-8\", \"cp1251\").iconv(self)\n rescue Iconv::IllegalSequence => e\n STDERR << \"!! Failed converting from UTF-8 -> cp1251 (#{self}). Already the right charset?\"\n self\n end\n end",
"def convert_string string\n string\n end",
"def convert_encoding(content); end"
] |
[
"0.75941664",
"0.7314398",
"0.70990163",
"0.7065679",
"0.6982743",
"0.69763625",
"0.6861917",
"0.676637",
"0.67141926",
"0.6713495",
"0.6670982",
"0.66073817",
"0.66073817",
"0.6589444",
"0.6526584",
"0.6509584",
"0.6489961",
"0.6470899",
"0.6459954",
"0.6458987",
"0.63925165",
"0.6374679",
"0.6359125",
"0.6356071",
"0.6354741",
"0.6345093",
"0.6345093",
"0.63259196",
"0.63236445",
"0.6320805",
"0.6291744",
"0.6232935",
"0.62263316",
"0.62107813",
"0.61893845",
"0.61875516",
"0.6159864",
"0.61488867",
"0.61453277",
"0.6143401",
"0.6141594",
"0.6125755",
"0.61232316",
"0.6117755",
"0.6090049",
"0.60738367",
"0.6070938",
"0.60637844",
"0.6030411",
"0.6014454",
"0.5995069",
"0.599378",
"0.5990335",
"0.59732604",
"0.59216994",
"0.5913822",
"0.58762",
"0.58509016",
"0.58392525",
"0.5836367",
"0.5833678",
"0.5810641",
"0.5793177",
"0.57918525",
"0.5787022",
"0.57857907",
"0.57825154",
"0.578005",
"0.5759253",
"0.5753047",
"0.57528764",
"0.57515484",
"0.57483256",
"0.5740634",
"0.5714172",
"0.5713431",
"0.57115555",
"0.5709331",
"0.5701705",
"0.569338",
"0.56884325",
"0.56884325",
"0.56845075",
"0.56336117",
"0.56305605",
"0.5625077",
"0.562149",
"0.5608671",
"0.56071085",
"0.5603335",
"0.56030184",
"0.55854315",
"0.5576114",
"0.55707186",
"0.5570309",
"0.5556937",
"0.5528698",
"0.5497628",
"0.5489189",
"0.5485515"
] |
0.7179808
|
2
|
callseq: Stringtoutf16 > string Convert self to UTF16 Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('w16xm0', str).
|
def toutf16; Kconv.toutf16(self) end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end",
"def to_utf16(str)\n if str.respond_to?(:encode)\n str.encode('UTF-16BE')\n else\n Iconv.conv('UTF-16BE', 'UTF-8', str)\n end\n end",
"def to_utf16\r\n Iconv.iconv(\"utf-16LE\", \"utf-8\", self).first + \"\\x00\\x00\"\r\n end",
"def get_utf16_of(character)\n character.encode('UTF-16BE').unpack('H*').first.upcase\nend",
"def from_utf16\r\n ret = Iconv.iconv(\"utf-8\", \"utf-16le\", self).first\r\n if ret[-1] == 0\r\n ret = ret[0..-2]\r\n end\r\n end",
"def clean(str)\n st = str.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')\n return st.encode('UTF-8', 'UTF-16')\nend",
"def wide_string(str)\n # if given a nil string, assume caller wants to pass a nil pointer to win32\n return nil if str.nil?\n\n str.encode('UTF-16LE')\n end",
"def str_to_uni_z(str)\n enc = str.encode('UTF-16LE').force_encoding('binary')\n enc += \"\\x00\\x00\"\n return enc\n end",
"def from_utf16_buffer\r\n self[0..index(\"\\0\\0\\0\")+2].from_utf16\r\n end",
"def unicode_text(pdf, str, options={})\n pdf.text(e(\"\\xfe\\xff#{str}\", :encoding => 'UTF-16BE'), options) # start Unicode UTF-16BE encoding\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def uC\n self.force_encoding('UTF-16LE').encode('UTF-8').strip\n end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end",
"def read_string(data, offset, length, encoding)\n if \"UTF-16\".casecmp(encoding) == 0\n out = data[offset, length].unpack('v*').pack('U*')\n else\n out = data[offset, length].unpack('C*').pack('U*')\n end\n return out\n end",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def write_utf16be_string(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return -1 if (args.size < 3) # Check the number of args\n\n record = 0x00FD # Record identifier\n length = 0x000A # Bytes to follow\n\n row = args[0] # Zero indexed row\n col = args[1] # Zero indexed column\n strlen = args[2].length\n str = args[2]\n xf = xf_record_index(row, col, args[3]) # The cell format\n encoding = 0x1\n str_error = 0\n\n # Check that row and col are valid and store max and min values\n return -2 if check_dimensions(row, col) != 0\n\n # Limit the utf16 string to the max number of chars (not bytes).\n if strlen > 32767* 2\n str = str[0..32767*2]\n str_error = -3\n end\n\n num_bytes = str.length\n num_chars = (num_bytes / 2).to_i\n\n # Check for a valid 2-byte char string.\n raise \"Uneven number of bytes in Unicode string\" if num_bytes % 2 != 0\n\n # Change from UTF16 big-endian to little endian\n str = str.unpack('n*').pack('v*')\n\n # Add the encoding and length header to the string.\n str_header = [num_chars, encoding].pack(\"vC\")\n str = str_header + str\n\n unless @str_table[str]\n @str_table[str] = str_unique\n add_str_unique(1)\n end\n\n add_str_total(1)\n \n header = [record, length].pack(\"vv\")\n data = [row, col, xf, @str_table[str]].pack(\"vvvV\")\n\n # Store the data or write immediately depending on the compatibility mode.\n if @compatibility != 0\n tmp = []\n tmp[col] = header + data\n @table[row] = tmp\n else\n append(header, data)\n end\n\n return str_error\n end",
"def trans_kana!(vstring)\n vstring.tr!('ア-ン', 'ア-ン')\n vstring.tr!('ア-ンヴヵヶ', 'あ-んぶかが')\n end",
"def uC\n NWRFCLib::Cutf16le_to_utf8.iconv(self).strip\n end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def toutf8(str)\n ::NKF::nkf('-wm', str)\n end",
"def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def uniz_to_str(uniz)\n uniz.force_encoding('UTF-16LE').encode('UTF-8')\n end",
"def fix_utf_errors\n self.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')\n end",
"def to_utf8(raw_text)\n if raw_text.platform_id == 1 && raw_text.encoding_id == 0\n return raw_text\n else\n begin\n raw_text.encode(\"UTF-8\", \"UTF-16BE\")\n rescue\n raw_text\n end\n end\n end",
"def unicode(str)\n\t\tRex::Text.to_unicode(str)\n\tend",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def set(string)\n self.data = string.encode(Encoding::UTF_16BE)\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def sanitize_string(string)\n return string.encode(\"UTF-16BE\", :invalid=>:replace, :undef => :replace, :replace=>\"?\")\n .encode(\"UTF-8\")\n .gsub(/[\\u0080-\\u009F]/) {|x| x.getbyte(1).chr.force_encoding('windows-1252').encode('utf-8') }\n .gsub(/\\\"/, \"\\\\\\\"\") # escape double quotes in string\n end",
"def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend",
"def clean_text(text)\n if RUBY_VERSION >= \"1.9\"\n\n # First, force to UTF-8 encoding\n if text.encoding.name != \"UTF-8\" \n text = text.force_encoding('UTF-8')\n end\n\n # If we still don't have a valid string, re-encode\n if !text.valid_encoding?\n text = text.encode('UTF-16', invalid: :replace, undef: :replace).encode('UTF-8')\n end\n\n end\n text\n end",
"def toutf8; Kconv.toutf8(self) end",
"def read_binary_unicode_string(fname,fd,length)\n # The problem is: we get the length of the string IN CHARACTERS;\n # since a char in UTF-16 can be 16 or 32 bit long, we don't really know\n # how long the string is in bytes\n buff = fd.read(2*length)\n\n @unique_table[buff] = true unless @unique_table.has_key?(buff)\n return CFString.new(Binary.charset_convert(buff,\"UTF-16BE\",\"UTF-8\"))\n end",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def convert(str)\n\t\t@result=convert_han(convert_words(str))\n\t\t# @result=convert_words(str)\n\t\t@result.gsub!(\" #%\",\"\")\n\t\t@result.gsub!(\"%# \",\"\")\n\t\t@result\n\tend",
"def iconv() end",
"def convert_to_unicode(char)\n \n if char =~ /\\A\\\\/\n char = char.gsub(\"\\\\\",\"\") # Fix double escaping\n char = [char[0..-1].to_i(16)].pack(\"U\")\n end\n \n raise ArgumentError, \"You can only pass one character\" if char.size > 1\n \n char\n end",
"def decode(base16_string)\n base16_string.to_i(BASE)\n end",
"def codepoint(str)\n return str.gsub(/\\\\u[\\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }\n end",
"def convert_string string\n string\n end",
"def get\n self.data.force_encoding(Encoding::UTF_16BE).encode(Encoding::UTF_8)\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def convert(string)\n\t# Adding space to handle words that end in a unicode character\n\tstring += \" \"\n\n\tword = \"\"\n\tunicode = false\n\tuni_string = \"\"\n\n\t# puts \"Starting each char...\"\n\tstring.each_char do |char|\n\t\t\n\t\t# puts \"char: #{char}\"\n\n\t\tif char != \"\\\\\" and !unicode\n\t\t\t# puts \"Adding #{char} to word\"\n\t\t\tword += convert_char(char)\n\n\t\telsif char == \"\\\\\"\n\t\t\t# puts \"Starting unicode string\"\n\t\t\tuni_string = \"\\\\\"\n\t\t\tunicode = true\n\n\t\telsif char != \" \" and unicode\n\t\t\t# puts \"Putting #{char} in unicode string: #{uni_string}\"\n\t\t\tuni_string += char\n\n\t\telsif unicode and char == \" \"\n\t\t\t# puts \"Found end of unicode string: #{uni_string}\"\n\t\t\tword += convert_char(uni_string)\n\t\t\tuni_string = \"\"\n\t\t\tunicode = false\n\t\telse\n\t\t\tputs \"Not sure what to do with #{char}\"\n\t\tend\n\tend\n\n\t# Strip to remove extra spaces\n\treturn word.strip\n\nend",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def encode_string(str)\n str = str.to_s.encode('UTF-8')\n\n # Force to binary, when assembling the packet\n str.force_encoding('ASCII-8BIT')\n encode_short(str.bytesize) + str\n end",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def get_unicode_of(character)\n character.unpack('U*').first.to_s(16).rjust(4, '0').upcase\nend",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def normalize string\r\n begin\r\n string.dup.force_encoding('UTF-8')\r\n rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e\r\n # @todo Improve error handling\r\n Solargraph::Logging.logger.warn \"Normalize error: #{e.message}\"\r\n string\r\n end\r\n end",
"def convert_string string\n return string unless @in_b or @in_em\n chars = if @in_b then\n string.chars.map do |char| \"#{char}\\b#{char}\" end\n elsif @in_em then\n string.chars.map do |char| \"_\\b#{char}\" end\n end\n\n chars.join\n end",
"def write_utf16le_string(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return -1 if (args.size < 3) # Check the number of args\n\n record = 0x00FD # Record identifier\n length = 0x000A # Bytes to follow\n\n row = args[0] # Zero indexed row\n col = args[1] # Zero indexed column\n str = args[2]\n format = args[3] # The cell format\n\n # Change from UTF16 big-endian to little endian\n str = str.unpack('n*').pack(\"v*\")\n\n return write_utf16be_string(row, col, str, format)\n end",
"def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end",
"def encode(unicode)\n unicode.gsub!('U+', '\\u')\n\n unicode.gsub(/\\\\u[\\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def shortxlunicodestring(io)\n cch, flags = io.read(2).unpack('CC')\n _read_unicodestring(io, cch, flags)\n end",
"def string(str)\n TYPE_STRING +\n word(str.length) +\n str.encode!(\"ASCII\")\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def pack_dv_string(string = nil, max_length = 0) #:nodoc:\n str_length = 0\n encoding = 0\n\n # The default empty string is \"\\0\".\n if string.nil? || string == ''\n string = \"\\0\"\n end\n\n # Excel limits DV captions to 32 chars and messages to 255.\n if string.length > max_length\n string = string[0 .. max_length-1]\n end\n\n str_length = string.length\n\n # Handle utf8 strings\n if string =~ NonAscii\n require 'jcode'\n $KCODE = 'u'\n str_length = string.jlength\n string = NKF.nkf('-w16L0 -m0 -W', string)\n encoding = 1\n end\n\n return [str_length, encoding].pack('vC') + string\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def string\n str = basic_string\n if str.respond_to? :force_encoding\n str.force_encoding InternalEncoding\n end\n\n convert(str, @encoding)\n end",
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ::NKF::JIS\n opt << 'j'\n when ::NKF::EUC\n opt << 'e'\n when ::NKF::SJIS\n opt << 's'\n when ::NKF::UTF8\n opt << 'w'\n when ::NKF::UTF16\n opt << 'w16'\n when ::NKF::NOCONV\n return str\n end\n\n opt = '' if opt == '-'\n\n ::NKF::nkf(opt, str)\n end",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def unicode_normalize!(form = :nfc)\n require 'unicode_normalize/normalize.rb' unless defined? UnicodeNormalize\n # String.send(:define_method, :unicode_normalize!, ->(form = :nfc) { replace(unicode_normalize(form)) } )\n replace(unicode_normalize(form))\n end",
"def to_unicode(string)\n SimpleIDN.to_unicode(string)\n end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def normalize_utf8(string)\n codepoints = string.unpack(\"U*\")\n new = []\n until codepoints.empty? do\n if Mappings::COMPOSITION[codepoints[0..1]]\n new << Mappings::COMPOSITION[codepoints.slice!(0,2)]\n else\n new << codepoints.shift\n end\n end\n new.compact.flatten.pack(\"U*\")\n end",
"def energetic_encoding(str, hash)\n output = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n output += hash[char]\n elsif char != \" \"\n output += \"?\"\n else\n output += char\n end\n end\n output\nend",
"def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n # Escape all the things\n str.gsub(/\\\\(?:([#{chars.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\'\n then '\\\\'\n else\n chars[$1]\n end\n elsif $2\n [\"#$2\".hex].pack('U*')\n elsif $3\n [$3].pack('H2')\n end\n }\n end",
"def convert_text!(text, error_handler)\n text = AnselToUnicode.new(error_handler, true).convert(text) if convert_marc8_to_utf8?\n\n # Turn Horizon's weird escaping into UTF8: <U+nnnn> where nnnn is a hex unicode\n # codepoint, turn it UTF8 for that codepoint\n if settings[\"horizon.destination_encoding\"] == \"UTF8\" &&\n (settings[\"horizon.codepoint_translate\"].to_s == \"true\" ||\n settings[\"horizon.character_reference_translate\"].to_s == \"true\")\n\n regexp = if settings[\"horizon.codepoint_translate\"].to_s == \"true\" && settings[\"horizon.character_reference_translate\"].to_s == \"true\"\n # unicode codepoint in either HTML char reference form OR\n # weird horizon form. \n /(?:\\<U\\+|&#x)([0-9A-Fa-f]{4})(?:\\>|;)/\n elsif settings[\"horizon.codepoint_translate\"].to_s == \"true\"\n # just weird horizon form\n /\\<U\\+([0-9A-Fa-f]{4})\\>/\n else # just character references\n /&#x([0-9A-Fa-f]{4});/\n end\n \n text.gsub!(regexp) do\n [$1.hex].pack(\"U\")\n end\n end\n\n # eliminate illegal control chars. All ASCII less than 0x20\n # _except_ for four legal ones (including MARC delimiters). \n # http://www.loc.gov/marc/specifications/specchargeneral.html#controlfunction\n # this is all bytes from 0x00 to 0x19 except for the allowed 1B, 1D, 1E, 1F. \n text.gsub!(/[\\x00-\\x1A\\x1C]/, '')\n\n return text\n end",
"def decode_string(str)\n\nend",
"def energetic_encoding(str, hash)\n new_str = []\n arr = str.split(' ')\n\n arr.each do |word|\n new_word = ''\n word.each_char do |char|\n if hash.has_key?(char)\n new_word += hash[char]\n else\n new_word += '?'\n end\n end\n new_str << new_word\n end\n\n new_str.join(' ')\nend",
"def escape_string(str)\n replacement = {\n ':)' => \"\\n\", ':>' => \"\\t\", ':o' => \"\\a\", ':\"' => '\"', '::' => ':'\n }\n str\n .gsub(/:[\\)>o\":]/, replacement)\n .gsub(/:\\(([0-9a-fA-F]+)\\)/) do |match|\n $1.to_i(16).chr(Encoding::UTF_8)\n end\n .gsub(/:\\[(.+?)\\]/) do |match|\n code = Unicode::DATA[$1]\n if code\n code.chr(Encoding::UTF_8)\n else\n $stderr.puts(\"Unknown Unicode normative name: #{$1}\")\n match\n end\n end\n end",
"def unencode_javascript_unicode_escape(str)\n if str.respond_to?(:gsub!)\n str.gsub!(/\\\\u([0-9a-fA-F]{4})/) do |s| \n int = $1.to_i(16)\n if int.zero? && s != \"0000\"\n s\n else\n [int].pack(\"U\")\n end\n end\n end\n str\n end",
"def get_U16_field(field_name)\n\t\tend",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def force_twilio_ucs2_encoding(message)\n punctuation_space = \"\\u{2008}\"\n \"#{message}#{punctuation_space}\"\n end",
"def force_to_utf8(text)\n ActiveSupport::Multibyte::Unicode.tidy_bytes(text)\n end",
"def reencode_string(input); end",
"def decode_word(text)\n return text unless text =~ /=\\?([^?]+)\\?(.)\\?([^?]*)\\?=/\n \n charset, method, encoded_string = $1, $2, $3\n \n # Strip out the RFC2231 language specification if there is one.\n charset = $1 if charset =~ /^([^\\*]+)\\*?(.*)$/\n \n # Quoted-printable in RFC2047 substitutes spaces with underscores.\n encoded_string.tr!('_', ' ') if method.downcase == 'q'\n \n encoded_string.decode_mime(method).iconv('utf-8', charset)\n end",
"def iconv\n @iconv ||= Iconv.new(vk_charset, 'UTF-8')\n end",
"def normalize_string str\n str.to_s.encode(\n invalid: :replace,\n undef: :replace,\n universal_newline: true\n )\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def unescape(str)\n # Escape all the things\n str.gsub(/\\\\(?:([#{UNESCAPES.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\' then '\\\\' else UNESCAPES[$1] end\n elsif $2 # escape \\u0000 unicode\n [\"#$2\".hex].pack('U*')\n elsif $3 # escape \\0xff or \\xff\n [$3].pack('H2')\n end\n }\n end",
"def utf8safe(text)\n require 'iconv'\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n return ic.iconv(text + ' ')[0..-2]\nend",
"def sterilize(str)\n str.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n str.gsub!(0x00.chr,'[NUL]')\n str.gsub!(0x01.chr,'[SOH]')\n str.gsub!(0x02.chr,'[STX]')\n str.gsub!(0x03.chr,'[ETX]')\n str.gsub!(0x04.chr,'[EOT]')\n str.gsub!(0x05.chr,'[ENQ]')\n str.gsub!(0x06.chr,'[ACK]')\n str.gsub!(0x07.chr,'[BEL]')\n # 0x08 is backspace\n # 0x09 is TAB\n # 0x10 is line feed\n str.gsub!(0x0B.chr,'[VT]')\n # 0x0c is form feed\n # 0x0d is carriage return\n str.gsub!(0x0E.chr,'[SO]')\n str.gsub!(0x0F.chr,'[SI]')\n str.gsub!(0x10.chr,'[DLE]')\n str.gsub!(0x11.chr,'[DC1]')\n str.gsub!(0x12.chr,'[DC2]')\n str.gsub!(0x13.chr,'[DC3]')\n str.gsub!(0x14.chr,'[DC4]')\n str.gsub!(0x15.chr,'[NAK]')\n str.gsub!(0x16.chr,'[SYN]')\n str.gsub!(0x17.chr,'[ETB]')\n str.gsub!(0x18.chr,'[CAN]')\n str.gsub!(0x19.chr,'[EM]')\n str.gsub!(0x1a.chr,'[SUB]')\n str.gsub!(0x1C.chr,'[FS]')\n str.gsub!(0x1D.chr,'[GS]')\n str.gsub!(0x1E.chr,'[RS]')\n str.gsub!(0x1F.chr,'[US]')\n str\n end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def energetic_encoding(str, hash)\n energetic = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n energetic << hash[char]\n elsif char == \" \"\n energetic << \" \"\n else \n energetic << \"?\"\n end\n end\n energetic\nend"
] |
[
"0.8252426",
"0.7897078",
"0.7360288",
"0.71693677",
"0.68734056",
"0.65230435",
"0.6292066",
"0.62168086",
"0.620718",
"0.59250987",
"0.58182025",
"0.5809964",
"0.5806715",
"0.5794393",
"0.5748428",
"0.5742194",
"0.5692082",
"0.56716526",
"0.5657539",
"0.56498486",
"0.5637093",
"0.552924",
"0.55100673",
"0.5461735",
"0.5460779",
"0.5443651",
"0.54370093",
"0.543381",
"0.54284674",
"0.5426062",
"0.5425705",
"0.53713804",
"0.53700036",
"0.53556293",
"0.5343425",
"0.53411096",
"0.5337106",
"0.52985",
"0.5192465",
"0.5186985",
"0.518625",
"0.51345396",
"0.5133433",
"0.5113702",
"0.50999385",
"0.5069807",
"0.50526273",
"0.5050594",
"0.50158125",
"0.5011283",
"0.5000966",
"0.49852765",
"0.4976233",
"0.4975716",
"0.49750564",
"0.49713272",
"0.49576628",
"0.49490997",
"0.49480096",
"0.49414286",
"0.49389657",
"0.4920533",
"0.49132624",
"0.49132624",
"0.49085176",
"0.48969108",
"0.48818114",
"0.48769665",
"0.48747545",
"0.48724982",
"0.48479173",
"0.4845245",
"0.48448876",
"0.48444688",
"0.48360598",
"0.4826291",
"0.48255563",
"0.4823637",
"0.4820166",
"0.47997257",
"0.47944197",
"0.47898883",
"0.4786549",
"0.47688258",
"0.4763798",
"0.47549775",
"0.47462538",
"0.47445136",
"0.4720699",
"0.47109917",
"0.4708464",
"0.46871614",
"0.46865374",
"0.4679852",
"0.46796313",
"0.46744078",
"0.465916",
"0.46564707",
"0.46531433",
"0.4651847"
] |
0.7502621
|
2
|
is Encoding callseq: Stringiseuc > obj or nil Returns whether self's encoding is EUCJP or not. Note don't expect this return value is MatchData.
|
def iseuc; Kconv.iseuc(self) end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def isutf8;\tKconv.isutf8(self) end",
"def encoding_found; end",
"def encoding_found; end",
"def found_encoding; end",
"def found_encoding; end",
"def is_utf8?\n ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end",
"def find_encoding(encoding); end",
"def valid_utf8?(str)\n valid_utf8_bson?(str)\n end",
"def have_encoding?\n Object.const_defined? :Encoding\n end",
"def encoding\n # noop?\n end",
"def external_encoding; @_external_encoding || _external_encoding; end",
"def check_utf8_encoding\n return nil if self.encoding != Encoding.find('utf-8')\n state = :s0\n n_of_chars = 0\n self.bytes.each do |byte|\n case state\n when :s0\n n_of_chars += 1\n if (0x00..0x7F).include?(byte) then state = :s0\n elsif (0xC2..0xDF).include?(byte) then state = :s1\n elsif 0xE0 == byte then state = :s2\n elsif (0xE1..0xEC).include?(byte) || (0xEE..0xEF).include?(byte) then state = :s3\n elsif 0xED == byte then state = :s4\n elsif 0xF0 == byte then state = :s5\n elsif (0xF1..0xF3).include?(byte) then state = :s7\n elsif 0xF4 == byte then state = :s8\n else return nil end\n when :s1\n if (0x80..0xBF).include?(byte) then state = :s0 \n else return nil end\n when :s2\n if (0xA0..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s3\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s4\n if (0x80..0x9F).include?(byte) then state = :s1\n else return nil end\n when :s5\n if (0x90..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s6\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s7\n if (0x80..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s8\n if (0x80..0x8F).include?(byte) then state = :s6\n else return nil end\n end # case\n end # self.bytes.each\n if state == :s0 then return n_of_chars\n else return nil end\n end",
"def valid_utf8?(str)\n @connection.valid_utf8?(str)\n end",
"def encoded?\n self.encoded.not_nil?\n end",
"def is_ustring?(); @type == GRT_USTRING; end",
"def enc_utf8\n\n @@enc_utf8 ||= \n ( Encoding.find( \"utf-8\" ) or raise \"No utf-8 encoding found (?!)\" )\nend",
"def check_utf8(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"utf-8\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end",
"def try_with_encoding(string, encoding); end",
"def try_with_encoding(string, encoding); end",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message.scrub =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def valid_value?\n if ape_type == 'utf8' || ape_type == 'external'\n # :nocov:\n if RUBY_VERSION >= '1.9'\n # :nocov:\n begin\n map!{|v| v.to_s.encode('UTF-8')}\n rescue EncodingError\n return false\n end\n end\n string_value.unpack('U*')\n end\n rescue ArgumentError\n false\n else\n true\n end",
"def meta_encoding; end",
"def meta_encoding; end",
"def encodings; end",
"def encoding_error?(parser = T.unsafe(nil)); end",
"def isutf8(str)\n RegexpUtf8.match( str )\n end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding(encoding); end",
"def ascii?\n ASCII_ENCODINGS.include?(encoding)\n end",
"def iseuc(str)\n RegexpEucjp.match( str )\n end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def is_nikkud(c)\n self.class.is_nikkud_by_encoding(c, self.encoding) # delegate to class method based on instance encoding\n end",
"def ascii?\n ! self.unicode?\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def encoding\n @content[pn(:Encoding)]\n end",
"def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end",
"def should_encode?\n !@raw\n end",
"def determine_encodings!(*)\n @encoding ||= super\n end",
"def internal_encoding()\n #This is a stub, used for indexing\n end",
"def encoded?\n self.status == 'Convertido' ? true : false\n end",
"def is_equal_to_utf8cstring(a,b)\n JavaScriptCore::Lib.JSStringIsEqualToUTF8CString(a,b)\n end",
"def external_encoding()\n #This is a stub, used for indexing\n end",
"def can_encode?(str)\n str.nil? || !(GSM_REGEX =~ str).nil?\n end",
"def encode_string_ex; end",
"def try_utf8!(string, encoding = ::Encoding::UTF_8)\n return nil unless string\n string.force_encoding(::Encoding::ASCII_8BIT) unless string.force_encoding(encoding).valid_encoding?\n string\n end",
"def can_encode?\n !@encoding_map.empty?\n end",
"def mobile_encoding\n\t'ISO-8859-1'\nend",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding\n Encoding::UTF_8\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def can_encode?(str, charset: BASIC_CHARSET)\n !str || !!(regex(charset) =~ str)\n end",
"def valid_utf_8_bytes?(string)\n original_encoding = string.encoding\n valid = string.force_encoding(Encoding::UTF_8).valid_encoding?\n string.force_encoding(original_encoding)\n valid\n end",
"def encode_as_utf8(obj)\n if obj.is_a? Hash\n obj.each_pair do |key, val|\n encode_as_utf8(val)\n end\n elsif obj.is_a?(Array)\n obj.each do |val|\n encode_as_utf8(val)\n end\n elsif obj.is_a?(String) && obj.encoding != Encoding::UTF_8\n if !obj.force_encoding(\"UTF-8\").valid_encoding?\n obj.force_encoding(\"ISO-8859-1\").encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end\n obj\n end",
"def unicode?\n self.local =~ /[^\\p{InBasicLatin}]/ ? true : false\n end",
"def fix_charset(object)\n return nil if object.nil?\n\n if object.charset\n object.body.decoded.force_encoding(object.charset.gsub(/utf8/i, \"UTF-8\")).encode(\"UTF-8\").to_s\n else\n object.body.to_s\n end\n rescue\n nil\n end",
"def encoding(value = nil)\n value ? @encoding = value : @encoding\n end",
"def encoding\n @external_encoding\n end",
"def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend",
"def encoding_from_feed_data\n if @encoding_from_feed_data.blank?\n raw_data = self.feed_data\n return nil if raw_data.nil?\n encoding_from_xml_instruct = \n raw_data.scan(\n /^<\\?xml [^>]*encoding=\"([^\\\"]*)\"[^>]*\\?>/\n ).flatten.first\n unless encoding_from_xml_instruct.blank?\n encoding_from_xml_instruct.downcase!\n end\n if encoding_from_xml_instruct.blank?\n begin\n doc = REXML::Document.new(raw_data)\n encoding_from_xml_instruct = doc.encoding.downcase\n if encoding_from_xml_instruct == \"utf-8\"\n # REXML has a tendency to report utf-8 overzealously, take with\n # grain of salt\n encoding_from_xml_instruct = nil\n end\n rescue\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if encoding_from_xml_instruct.blank?\n sniff_table = {\n \"Lo\\247\\224\" => \"ebcdic-cp-us\",\n \"<?xm\" => \"utf-8\"\n }\n sniff = self.feed_data[0..3]\n if sniff_table[sniff] != nil\n @encoding_from_feed_data = sniff_table[sniff].downcase\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if @encoding_from_feed_data.blank?\n # Safest assumption\n @encoding_from_feed_data = \"utf-8\"\n end\n end\n return @encoding_from_feed_data\n end",
"def toutf8; Kconv.toutf8(self) end",
"def encoding()\n #This is a stub, used for indexing\n end",
"def _utf8\n\n _save = self.pos\n while true # choice\n _tmp = scan(/\\A(?-mix:[\\t\\n\\r\\40-\\176])/)\n break if _tmp\n self.pos = _save\n\n _save1 = self.pos\n while true # sequence\n _tmp = scan(/\\A(?-mix:[\\302-\\337])/)\n unless _tmp\n self.pos = _save1\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save1\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save\n\n _save2 = self.pos\n while true # sequence\n _tmp = scan(/\\A(?-mix:[\\340-\\357])/)\n unless _tmp\n self.pos = _save2\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save2\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save2\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save\n\n _save3 = self.pos\n while true # sequence\n _tmp = scan(/\\A(?-mix:[\\360-\\364])/)\n unless _tmp\n self.pos = _save3\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save3\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save3\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save3\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_utf8 unless _tmp\n return _tmp\n end",
"def test_default_internal_is_honored\n before_enc = Encoding.default_internal\n\n str = \"壁に耳あり、障子に目あり\"\n bson = BSON::BSON_CODER.serialize(\"x\" => str)\n\n silently { Encoding.default_internal = 'EUC-JP' }\n out = BSON::BSON_CODER.deserialize(bson)[\"x\"]\n\n assert_equal Encoding.default_internal, out.encoding\n assert_equal str.encode('EUC-JP'), out\n assert_equal str, out.encode(str.encoding)\n ensure\n silently { Encoding.default_internal = before_enc }\n end",
"def issjis;\tKconv.issjis(self) end",
"def encoding\n\t'ISO-8859-1'\nend",
"def ignore_encoding_error; end",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\n rescue StandardError\n nil\n end",
"def clean\n self.encode!('UTF-8', :invalid => :replace, :undef => :replace, replace: '')\n end",
"def utf8(string)\n string.force_encoding('utf-8') unless string.nil?\n end",
"def force_encoding(*); self; end",
"def meta_encoding=(encoding); end"
] |
[
"0.69117785",
"0.6713687",
"0.6713687",
"0.67017657",
"0.67017657",
"0.6518641",
"0.6391397",
"0.6391397",
"0.622906",
"0.622906",
"0.6096197",
"0.605986",
"0.60394746",
"0.5907816",
"0.5902572",
"0.5824572",
"0.5808337",
"0.57507926",
"0.57357484",
"0.57344484",
"0.57199407",
"0.56955266",
"0.568601",
"0.5675426",
"0.566939",
"0.566939",
"0.56570816",
"0.56505483",
"0.5643246",
"0.5641167",
"0.5641167",
"0.561409",
"0.5594122",
"0.5588374",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5583916",
"0.5578402",
"0.55423814",
"0.55141586",
"0.55063117",
"0.55063117",
"0.5506059",
"0.5506059",
"0.5506059",
"0.5506059",
"0.5506059",
"0.54985976",
"0.5494619",
"0.54758203",
"0.54522115",
"0.54347044",
"0.54105145",
"0.5403568",
"0.5391315",
"0.5389536",
"0.5386982",
"0.5385611",
"0.5385221",
"0.5384524",
"0.5373973",
"0.53715295",
"0.5367628",
"0.5365422",
"0.53620666",
"0.5356139",
"0.5356139",
"0.5355899",
"0.5351479",
"0.5340031",
"0.5338278",
"0.5326242",
"0.53207684",
"0.530964",
"0.5296506",
"0.5293402",
"0.52740157",
"0.5262953",
"0.5262684",
"0.5239621",
"0.5218493",
"0.520711",
"0.51996815",
"0.51734644",
"0.514968",
"0.51402855",
"0.51402736",
"0.5130188",
"0.51296943"
] |
0.0
|
-1
|
callseq: Stringissjis > obj or nil Returns whether self's encoding is Shift_JIS or not. Note don't expect this return value is MatchData.
|
def issjis; Kconv.issjis(self) end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def issjis(str)\n RegexpShiftjis.match( str )\n end",
"def sjis_to_jis(sjis)\n hi = (sjis >> 8) & 0xff\n lo = sjis & 0xff\n return lo if hi == 0\n hi -= (hi<=0x9f) ? 0x71 : 0xb1\n hi = hi * 2 + 1\n lo -= (lo > 0x7f) ? 1 : 0\n hi += (lo >= 0x9e) ? 1 : 0\n lo -= (lo >= 0x9e) ? 0x7d : 0x1f\n return hi << 8 | lo\nend",
"def tosjis; Kconv.tosjis(self) end",
"def tojis; Kconv.tojis(self) end",
"def tojis(str)\n ::NKF::nkf('-jm', str)\n end",
"def tosjis(str)\n ::NKF::nkf('-sm', str)\n end",
"def found_encoding; end",
"def found_encoding; end",
"def japanese?\n !!(self =~ /\\p{Katakana}|\\p{Hiragana}/)\n end",
"def isutf8;\tKconv.isutf8(self) end",
"def encoding_found; end",
"def encoding_found; end",
"def iseuc(str)\n RegexpEucjp.match( str )\n end",
"def encode_for_excel(s)\n s.encode(default_encoding, invalid: :replace, undef: :replace)\n end",
"def check_utf8_encoding\n return nil if self.encoding != Encoding.find('utf-8')\n state = :s0\n n_of_chars = 0\n self.bytes.each do |byte|\n case state\n when :s0\n n_of_chars += 1\n if (0x00..0x7F).include?(byte) then state = :s0\n elsif (0xC2..0xDF).include?(byte) then state = :s1\n elsif 0xE0 == byte then state = :s2\n elsif (0xE1..0xEC).include?(byte) || (0xEE..0xEF).include?(byte) then state = :s3\n elsif 0xED == byte then state = :s4\n elsif 0xF0 == byte then state = :s5\n elsif (0xF1..0xF3).include?(byte) then state = :s7\n elsif 0xF4 == byte then state = :s8\n else return nil end\n when :s1\n if (0x80..0xBF).include?(byte) then state = :s0 \n else return nil end\n when :s2\n if (0xA0..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s3\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s4\n if (0x80..0x9F).include?(byte) then state = :s1\n else return nil end\n when :s5\n if (0x90..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s6\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s7\n if (0x80..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s8\n if (0x80..0x8F).include?(byte) then state = :s6\n else return nil end\n end # case\n end # self.bytes.each\n if state == :s0 then return n_of_chars\n else return nil end\n end",
"def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end",
"def to_chinese_text!\n possible = SUPPORTED_CHINESE_ENCODINGS.select do |encoding|\n begin\n self.force_encoding(encoding)\n self.valid_encoding?\n rescue\n false\n end\n end\n raise \"Couldn't guess correct string encoding\" if possible.empty?\n if possible.one?\n self.force_encoding(possible.first)\n return self\n end\n\n # if there is more than 1 possible encoding,\n # guess the one which has the highest frequency of 的\n best_guess = possible.max_by do |encoding|\n self.force_encoding(encoding)\n look_for = \"的\".encode(encoding)\n self.chars.count { |c| c == look_for }.tap { |x| puts \"found #{x} for #{encoding}\" }\n end\n self.force_encoding(best_guess)\n self\n end",
"def is_utf8?\n ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)\n end",
"def sierra_code\n match = SierraCodeZcodeMatch.find_by_zcode(code)\n return nil if !match\n\n return match.sierra_code\n end",
"def find_encoding(encoding); end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def issn\n suffix.scan(/^(?:(?:j\\.|issn\\.)|S|\\(ISSN\\))?(\\d{4}-\\d{3}[\\dx])\\b/i).flatten.first\n end",
"def can_encode?(str)\n str.nil? || !(GSM_REGEX =~ str).nil?\n end",
"def single_issn\n return nil unless issn.present?\n return issn.first if issn.is_a?(Array)\n return JSON.parse(issn)&.first if issn.start_with?('[')\n\n issn\n end",
"def encoded?\n self.encoded.not_nil?\n end",
"def is_italicized()\n validate_worksheet\n if @workbook.fonts[font_id()][:font][:i].nil?\n false\n else\n true\n end\n end",
"def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end",
"def issn\n issn = @pubmed['IS'].strip\n if ! issn.blank?\n issn_array=issn.split(\"\\n\")\n issn = \"\"\n issn_array.each do |issn_item|\n if issn_item =~ /linking/i\n issn_item =~ /([0-9]+-[0-9]+[0-9X])/\n issn = $&\n break\n end\n end\n end\n issn\n end",
"def parse_ikkatsuline\n s0 = @scanner.pos\n if match_str('|') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s3 = parse_masu\n if s3 == :failed\n s2 = :failed\n else\n s2 = []\n while s3 != :failed\n s2 << s3\n s3 = parse_masu\n end\n end\n if s2 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif match_str('|') != :failed\n s4 = parse_nonls!\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n elsif parse_nl != :failed\n @reported_pos = s0\n s0 = s2\n else\n @scanner.pos = s0\n s0 = :failed\n end\n else\n @scanner.pos = s0\n s0 = :failed\n end\n end\n\n s0\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def is_s?\n true if String(self) rescue false\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def has_kanji_entry?(d)\n d.has_kind?(Rkanren::KANJI)\n end",
"def SmileyExist(smiley)\n uri = URI('http://www.emoji-cheat-sheet.com/graphics/emojis/'+smiley+'.png')\n res = Net::HTTP.get_response(uri)\n\n if res.code == '200'\n return true\n else\n return false\n end\n end",
"def html_encoding?(html)\n chunk = html[0..1024]\n\n charset = nil\n chunk.split(/\\n/).each do |l|\n m = /Content-Type.*\"(.*?)\"/i.match(l)\n if m && m[1]\n return encoding_from_content_type(m[1])\n end\n end\n nil\n end",
"def fallback?\n !@icon.respond_to?(:encode)\n end",
"def ascii?\n ! self.unicode?\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def check_utf8(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"utf-8\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end",
"def have_encoding?\n Object.const_defined? :Encoding\n end",
"def normalize_issn(input, options={})\n content = options[:content] || \"__content__\"\n\n issn = if input.blank?\n nil\n elsif input.is_a?(String) && options[:content].nil?\n input\n elsif input.is_a?(Hash)\n input.fetch(content, nil)\n elsif input.is_a?(Array)\n a = input.find { |a| a[\"media_type\"] == \"electronic\" } || input.first\n a.fetch(content, nil)\n end\n\n case issn.to_s.length\n when 9\n issn\n when 8\n issn[0..3] + \"-\" + issn[4..7]\n else\n nil\n end\n end",
"def set_kai2_ji7\n @kai2_ji7 = Kai2Ji7.find(params[:id])\n @kai2_ji7.無齊記號 = '!'+@kai2_ji7.無齊記號\n end",
"def ascii?\n ASCII_ENCODINGS.include?(encoding)\n end",
"def SmileyExist(smiley, animated = false)\n if animated\n uri = URI('http://' + Animated_Smiley_URI + '/images/Skype/'+ smiley + '.gif')\n else\n uri = URI('http://' + General_Smiley_URI + '/graphics/emojis/' + smiley + '.png')\n end\n\n res = Net::HTTP.get_response(uri)\n \n if res.code == '200'\n return true\n else\n return false\n end\n end",
"def multibyte?\n @multibyte\n end",
"def isutf8(str)\n RegexpUtf8.match( str )\n end",
"def is_nikkud(c)\n self.class.is_nikkud_by_encoding(c, self.encoding) # delegate to class method based on instance encoding\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end",
"def get_data(imei)\n unless valid?(imei)\n @errors << 'IMEI invalid'\n return false\n end\n begin\n content = open(\"https://selfsolve.apple.com/wcResults.do?sn=#{imei}&num=0\") { |f| f.read }.split(\"\\n\")\n rescue StandardError => e\n @errors << e.message\n return false\n end\n\n parse(content)\n end",
"def encoding_error?(parser = T.unsafe(nil)); end",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message.scrub =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def try_with_encoding(string, encoding); end",
"def try_with_encoding(string, encoding); end",
"def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend",
"def to_hijri\n self\n end",
"def jruby?; end",
"def encoding\n # noop?\n end",
"def isNiktoScan(payload)\n if payload.scan(/Nikto/i).length > 0\n return true\n elsif payload.scan(/\\x4E\\x69\\x6B\\x74\\x6F/).length > 0\n return true\n else\n return false\n end\nend",
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def wide_latin?\n codepoint.wide_latin?\n end",
"def issn\n generate_barcode('barcode.issn')\n end",
"def ascii_only?()\n #This is a stub, used for indexing\n end",
"def jruby?\n JRUBY\n end",
"def can_encode?(str, charset: BASIC_CHARSET)\n !str || !!(regex(charset) =~ str)\n end",
"def is_multibyte(charset)\n charset == 0x31\n end",
"def ===(s)\n if (s.is_a?(StringScanner))\n s.scan(self)\n else\n super(s)\n end\n end",
"def saisoku?\n !!title.first_channel.match(channel_name)\n end",
"def is_sticker_code?\n self.scan(/^\\[\\[[0-9]{4,}\\]\\]$/).any?\n end",
"def from_native_charset(s, code, ignore_encoding_error = T.unsafe(nil), log = T.unsafe(nil)); end",
"def is_roman?\n @input.is_a? String\n end",
"def is_si_unit?\n self.is_a? SI\n end",
"def fix_charset(object)\n return nil if object.nil?\n\n if object.charset\n object.body.decoded.force_encoding(object.charset.gsub(/utf8/i, \"UTF-8\")).encode(\"UTF-8\").to_s\n else\n object.body.to_s\n end\n rescue\n nil\n end",
"def handle_encoding str\n str = str.dup\n has_enc = str.respond_to? :encoding # TODO: remove\n encoding = nil\n\n header = str.each_line.first(2)\n header.map! { |s| s.force_encoding \"ASCII-8BIT\" } if has_enc\n\n first = header.first || \"\"\n encoding, str = +\"utf-8\", str.b[3..-1] if first =~ /\\A\\xEF\\xBB\\xBF/\n\n encoding = $1.strip if header.find { |s|\n s[/^#.*?-\\*-.*?coding:\\s*([^ ;]+).*?-\\*-/, 1] ||\n s[/^#.*(?:en)?coding(?:\\s*[:=])\\s*([\\w-]+)/, 1]\n }\n\n if encoding then\n if has_enc then\n encoding.sub!(/utf-8-.+$/, \"utf-8\") # HACK for stupid emacs formats\n hack_encoding str, encoding\n else\n warn \"Skipping magic encoding comment\"\n end\n else\n # nothing specified... ugh. try to encode as utf-8\n hack_encoding str if has_enc\n end\n\n str\n end",
"def encodings; end",
"def unspsc_title?\n return 'No results found' unless to_str.length == 8\n unparsed_page = scrape_data()\n unparsed_page != nil ? (\n parsed_page = Nokogiri::HTML(unparsed_page)\n td_elements = parsed_page.css('td')\n title = td_elements.last.children.children.text \n # indicates empty td element\n return title unless title.include? \"\\r\"\n return 'No results found'\n ) : (\n return 'API call failed'\n )\n end",
"def _nil\n\n _save = self.pos\n while true # sequence\n _tmp = match_string(\"nil\")\n unless _tmp\n self.pos = _save\n break\n end\n _save1 = self.pos\n _tmp = apply(:_utfw)\n _tmp = _tmp ? nil : true\n self.pos = _save1\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_nil unless _tmp\n return _tmp\n end",
"def issn_array\n return nil unless issn.present?\n return issn if issn.is_a?(Array)\n return JSON.parse(issn) if issn.start_with?('[')\n\n [issn]\n end",
"def sic_code; end",
"def icon(s)\n if self['iconset'] && self['iconset'].has_key?(s) then self['iconset'][s] else s end\n end",
"def can_encode?\n !@encoding_map.empty?\n end",
"def inki_icon\n\t\t\t@inki_icon\n\t\tend",
"def is_solaris?\n return !!@name.match(/^solaris-.*$/)\n end",
"def set_syoji\n @syoji = Syoji.find(params[:id])\n end",
"def guess_encoding\n if @mime_type && !@mime_type.binary?\n \"7bit\"\n else\n \"binary\"\n end\n end",
"def encode_as_utf8(obj)\n if obj.is_a? Hash\n obj.each_pair do |key, val|\n encode_as_utf8(val)\n end\n elsif obj.is_a?(Array)\n obj.each do |val|\n encode_as_utf8(val)\n end\n elsif obj.is_a?(String) && obj.encoding != Encoding::UTF_8\n if !obj.force_encoding(\"UTF-8\").valid_encoding?\n obj.force_encoding(\"ISO-8859-1\").encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end\n obj\n end",
"def store_japanese_string(string)\n string = string.gsub(/[\\n\\r\\t ]+/, \" \")\n\n string.each_char do |c|\n w = if c.ascii_only? then 1 else 2 end\n\n @elements << Box.new(width: w, value: c)\n @elements << Glue.new(width: 1, shrink: 1, stretch: 1)\n end\n\n @elements.pop # Remove last glue element\n # Add unconditional break at the end of paragraph\n @elements << Glue(width: 0, shrink: Infinity, stretch: 0)\n @elements << Penaty(width: 0, penalty: -Infinity, flagged: 1)\n end",
"def fix_encoding!(try_encodings: PRIORITY_ENCODINGS)\n if encoding.to_s =~ /^iso-8859-/i\n force_encoding(DEFAULT_ENCODING) if dup.force_encoding(DEFAULT_ENCODING).valid_encoding?\n elsif !valid_encoding?\n is_valid_encoding = try_encodings.find do |enc|\n force_encoding enc\n valid_encoding?\n end\n force_encoding CharDet.detect(self).encoding unless is_valid_encoding\n end\n self\n end",
"def meta_encoding; end",
"def meta_encoding; end",
"def is_ustring?(); @type == GRT_USTRING; end",
"def ignore_encoding_error; end",
"def encode_string_ex; end",
"def internal_encoding()\n #This is a stub, used for indexing\n end",
"def get_encoding_from_headers(type_header)\n return nil unless type_header\n\n content_type, params = cgi_parse_header(type_header)\n\n if params.include?('charset')\n return params.fetch('charset').gsub(/(\\A[\"']*)|([\"']*\\z)/, '')\n end\n\n nil\n end"
] |
[
"0.78617245",
"0.63576937",
"0.6075019",
"0.5898598",
"0.5733153",
"0.5017433",
"0.4953141",
"0.4953141",
"0.4833311",
"0.4797285",
"0.47745046",
"0.47745046",
"0.4661776",
"0.46436983",
"0.46217874",
"0.45365956",
"0.44326475",
"0.44192865",
"0.43909281",
"0.43902507",
"0.43625808",
"0.43503937",
"0.43071637",
"0.4279831",
"0.42758662",
"0.4196913",
"0.41896668",
"0.4167942",
"0.41633135",
"0.41545558",
"0.41544706",
"0.41544706",
"0.40803805",
"0.4066159",
"0.4066159",
"0.40657544",
"0.40441173",
"0.4036404",
"0.40210274",
"0.40091276",
"0.4005737",
"0.39975578",
"0.39836627",
"0.39601323",
"0.3960081",
"0.39600033",
"0.39592484",
"0.39584425",
"0.3954801",
"0.39414722",
"0.39401722",
"0.39365745",
"0.3918078",
"0.39137065",
"0.39011726",
"0.38951468",
"0.38851836",
"0.38830742",
"0.38830742",
"0.38625732",
"0.38411453",
"0.3835047",
"0.38333908",
"0.3832025",
"0.38302222",
"0.38267377",
"0.38162348",
"0.38071534",
"0.38032973",
"0.38018206",
"0.37974682",
"0.37897635",
"0.37852606",
"0.3759212",
"0.37550104",
"0.37438384",
"0.373557",
"0.37343055",
"0.37316716",
"0.37131533",
"0.37122178",
"0.37111935",
"0.37080258",
"0.37073678",
"0.37057346",
"0.3702115",
"0.36812884",
"0.3675816",
"0.36711994",
"0.36597872",
"0.36587363",
"0.36518845",
"0.36518782",
"0.36515033",
"0.36515033",
"0.36485642",
"0.36471885",
"0.36463174",
"0.36448526",
"0.3636197"
] |
0.7414598
|
1
|
callseq: Stringisutf8 > obj or nil Returns whether self's encoding is UTF8 or not. Note don't expect this return value is MatchData.
|
def isutf8; Kconv.isutf8(self) end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_utf8?\n ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end",
"def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end",
"def valid_utf8?(str)\n valid_utf8_bson?(str)\n end",
"def isutf8(str)\n RegexpUtf8.match( str )\n end",
"def valid_utf8?(str)\n @connection.valid_utf8?(str)\n end",
"def valid_utf_8_bytes?(string)\n original_encoding = string.encoding\n valid = string.force_encoding(Encoding::UTF_8).valid_encoding?\n string.force_encoding(original_encoding)\n valid\n end",
"def check_utf8(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"utf-8\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def try_utf8!(string, encoding = ::Encoding::UTF_8)\n return nil unless string\n string.force_encoding(::Encoding::ASCII_8BIT) unless string.force_encoding(encoding).valid_encoding?\n string\n end",
"def utf8(string)\n string.force_encoding('utf-8') unless string.nil?\n end",
"def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend",
"def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end",
"def check_utf8_encoding\n return nil if self.encoding != Encoding.find('utf-8')\n state = :s0\n n_of_chars = 0\n self.bytes.each do |byte|\n case state\n when :s0\n n_of_chars += 1\n if (0x00..0x7F).include?(byte) then state = :s0\n elsif (0xC2..0xDF).include?(byte) then state = :s1\n elsif 0xE0 == byte then state = :s2\n elsif (0xE1..0xEC).include?(byte) || (0xEE..0xEF).include?(byte) then state = :s3\n elsif 0xED == byte then state = :s4\n elsif 0xF0 == byte then state = :s5\n elsif (0xF1..0xF3).include?(byte) then state = :s7\n elsif 0xF4 == byte then state = :s8\n else return nil end\n when :s1\n if (0x80..0xBF).include?(byte) then state = :s0 \n else return nil end\n when :s2\n if (0xA0..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s3\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s4\n if (0x80..0x9F).include?(byte) then state = :s1\n else return nil end\n when :s5\n if (0x90..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s6\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s7\n if (0x80..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s8\n if (0x80..0x8F).include?(byte) then state = :s6\n else return nil end\n end # case\n end # self.bytes.each\n if state == :s0 then return n_of_chars\n else return nil end\n end",
"def enc_utf8\n\n @@enc_utf8 ||= \n ( Encoding.find( \"utf-8\" ) or raise \"No utf-8 encoding found (?!)\" )\nend",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def to_utf8(s)\n return nil if s.nil?\n\n # Attempt to politely transcode the string.\n s.encode(\"UTF-8\").scrub\n rescue\n # If that doesn't work, then overwrite the existing encoding and\n # clobber any strange characters.\n s.force_encoding(\"UTF-8\").scrub\n end",
"def utf8(string)\n string.force_encoding(Encoding::UTF_8)\n end",
"def is_equal_to_utf8cstring(a,b)\n JavaScriptCore::Lib.JSStringIsEqualToUTF8CString(a,b)\n end",
"def found_encoding; end",
"def found_encoding; end",
"def check_utf8\n if params.has_key? 'utf8' and params['utf8'] != '✓'\n render text: 'Bad Request', status: 400\n end\n end",
"def have_encoding?\n Object.const_defined? :Encoding\n end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def iso8859_1?\n encoding == \"ISO-8859-1\"\n end",
"def encode_as_utf8(obj)\n if obj.is_a? Hash\n obj.each_pair do |key, val|\n encode_as_utf8(val)\n end\n elsif obj.is_a?(Array)\n obj.each do |val|\n encode_as_utf8(val)\n end\n elsif obj.is_a?(String) && obj.encoding != Encoding::UTF_8\n if !obj.force_encoding(\"UTF-8\").valid_encoding?\n obj.force_encoding(\"ISO-8859-1\").encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end\n obj\n end",
"def is_ustring?(); @type == GRT_USTRING; end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding_found; end",
"def encoding_found; end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\n rescue StandardError\n nil\n end",
"def ascii?\n ! self.unicode?\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def to_utf8(v)\n return v unless v.is_a?(String)\n return v if (enc = v.encoding) == (utf = Encoding::UTF_8)\n Encoding::Converter.new(enc, utf).convert(v) rescue v.dup.force_encoding(utf)\nend",
"def unicode?\n self.local =~ /[^\\p{InBasicLatin}]/ ? true : false\n end",
"def can_encode?(str, charset: BASIC_CHARSET)\n !str || !!(regex(charset) =~ str)\n end",
"def to_utf8(str)\n if RUBY_VERSION == \"1.8.7\"\n str\n else\n str.force_encoding(Encoding::UTF_8.name)\n end\n end",
"def external_utf8_check?(safe_path)\n iconv = system('command -v iconv > /dev/null 2>&1')\n return false unless iconv\n\n path = SafeFile.safepath_to_string(safe_path)\n system(\"iconv -f UTF-8 #{Shellwords.escape(path)} > /dev/null 2>&1\")\n end",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def remove_utf8_bom!\n if self.encoding.eql?(Encoding.find('utf-8')) && self.bytes.first(3).eql?([0xEF, 0xBB, 0xBF])\n self.slice!(0,1)\n else\n nil\n end\n end",
"def find_encoding(encoding); end",
"def multibyte?\n @multibyte\n end",
"def process_encoding(source)\n source.force_encoding(Encoding::UTF_8)\n end",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\nend",
"def to_utf8(str)\n str.encode(Encoding::UTF_8)\n end",
"def default_encoding\n Encoding::UTF_8\n end",
"def force_utf8(buf)\n return buf if buf.valid_encoding?\n buf.force_encoding('ISO-8859-1').encode('UTF-8', 'UTF-8', replace: nil)\n end",
"def test_encoding\n assert_equal \"UTF-8\", @conn.encoding\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def convert_to_utf8(input)\n if input.is_a?(Hash)\n record = {}\n input.each do |key, value|\n record[convert_to_utf8(key)] = convert_to_utf8(value)\n end\n\n return record\n end\n return input.map { |value| convert_to_utf8(value) } if input.is_a?(Array)\n return input unless input.respond_to?(:encode)\n\n if @coerce_to_utf8\n input.encode(\n 'utf-8',\n invalid: :replace,\n undef: :replace,\n replace: @non_utf8_replacement_string)\n else\n begin\n input.encode('utf-8')\n rescue EncodingError\n @log.error 'Encountered encoding issues potentially due to non ' \\\n 'UTF-8 characters. To allow non-UTF-8 characters and ' \\\n 'replace them with spaces, please set \"coerce_to_utf8\" ' \\\n 'to true.'\n raise\n end\n end\n end",
"def test_encoding\n assert_equal 'UTF-8', @conn.encoding\n end",
"def toutf8; Kconv.toutf8(self) end",
"def to_utf8(str)\n str.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end",
"def encoding\n # noop?\n end",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def ascii?\n ASCII_ENCODINGS.include?(encoding)\n end",
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def fix_charset(object)\n return nil if object.nil?\n\n if object.charset\n object.body.decoded.force_encoding(object.charset.gsub(/utf8/i, \"UTF-8\")).encode(\"UTF-8\").to_s\n else\n object.body.to_s\n end\n rescue\n nil\n end",
"def try_with_encoding(string, encoding); end",
"def try_with_encoding(string, encoding); end",
"def string?\n data_type == String\n end",
"def force_utf8(buf) \n buf.force_encoding('ISO-8859-1').encode('UTF-8', 'UTF-8', replace: nil) \n end",
"def to_utf8!; replace(to_utf8); end",
"def utf8_character\n character.chr(Encoding::UTF_8)\n end",
"def feed_data_utf_8(force_encoding=nil)\n if @feed_data_utf_8.nil?\n raw_data = self.feed_data\n if force_encoding.nil?\n use_encoding = self.encoding\n else\n use_encoding = force_encoding\n end\n if use_encoding != \"utf-8\" && use_encoding != nil && raw_data != nil\n begin\n @feed_data_utf_8 =\n Iconv.new('utf-8', use_encoding).iconv(raw_data)\n rescue Exception => error\n return raw_data\n end\n else\n return self.feed_data\n end\n end\n return @feed_data_utf_8\n end",
"def charset\n 'UTF8'\n end",
"def valid_value?\n if ape_type == 'utf8' || ape_type == 'external'\n # :nocov:\n if RUBY_VERSION >= '1.9'\n # :nocov:\n begin\n map!{|v| v.to_s.encode('UTF-8')}\n rescue EncodingError\n return false\n end\n end\n string_value.unpack('U*')\n end\n rescue ArgumentError\n false\n else\n true\n end",
"def to_utf8(text)\n replaced = text\n unless replaced.nil?\n replaced = replaced.force_encoding(\"UTF-8\") if is_ascii_8bit?(replaced)\n replaced = cleanup_utf8(replaced)\n end\n replaced\n end",
"def force_to_utf8(text)\n ActiveSupport::Multibyte::Unicode.tidy_bytes(text)\n end",
"def validate_payload_encoding\n\t\t\tif self.opcode == :binary\n\t\t\t\tself.log.debug \"Binary payload: setting external encoding to ASCII-8BIT\"\n\t\t\t\tself.payload.set_encoding( Encoding::ASCII_8BIT )\n\t\t\telse\n\t\t\t\tself.log.debug \"Non-binary payload: setting external encoding to UTF-8\"\n\t\t\t\tself.payload.set_encoding( Encoding::UTF_8 )\n\t\t\t\t# :TODO: Is there a way to check that the data in a File or Socket will\n\t\t\t\t# transcode successfully? Probably not.\n\t\t\t\t# self.errors << \"Invalid UTF8 in payload\" unless self.payload.valid_encoding?\n\t\t\tend\n\t\tend",
"def clean\n self.encode!('UTF-8', :invalid => :replace, :undef => :replace, replace: '')\n end",
"def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end",
"def _utf8\n\n _save = self.pos\n while true # choice\n _tmp = scan(/\\A(?-mix:[\\t\\n\\r\\40-\\176])/)\n break if _tmp\n self.pos = _save\n\n _save1 = self.pos\n while true # sequence\n _tmp = scan(/\\A(?-mix:[\\302-\\337])/)\n unless _tmp\n self.pos = _save1\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save1\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save\n\n _save2 = self.pos\n while true # sequence\n _tmp = scan(/\\A(?-mix:[\\340-\\357])/)\n unless _tmp\n self.pos = _save2\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save2\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save2\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save\n\n _save3 = self.pos\n while true # sequence\n _tmp = scan(/\\A(?-mix:[\\360-\\364])/)\n unless _tmp\n self.pos = _save3\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save3\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save3\n break\n end\n _tmp = scan(/\\A(?-mix:[\\200-\\277])/)\n unless _tmp\n self.pos = _save3\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_utf8 unless _tmp\n return _tmp\n end",
"def is_ascii_character?\n dup.force_encoding(\"binary\")[0].ord < 128\n end",
"def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end",
"def add_utf8_bom!\n if self.encoding.eql?(Encoding.find('utf-8'))\n self.insert(0, \"\\xEF\\xBB\\xBF\".force_encoding(Encoding.find('utf-8')))\n else\n nil\n end\n end",
"def should_encode?\n !@raw\n end",
"def to_utf8(raw_text)\n if raw_text.platform_id == 1 && raw_text.encoding_id == 0\n return raw_text\n else\n begin\n raw_text.encode(\"UTF-8\", \"UTF-16BE\")\n rescue\n raw_text\n end\n end\n end",
"def safe_encode_utf8(text)\n text.force_encoding('ASCII-8BIT').encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :universal_newline => true)\nend",
"def html_encoding?(html)\n chunk = html[0..1024]\n\n charset = nil\n chunk.split(/\\n/).each do |l|\n m = /Content-Type.*\"(.*?)\"/i.match(l)\n if m && m[1]\n return encoding_from_content_type(m[1])\n end\n end\n nil\n end",
"def ascii_only?()\n #This is a stub, used for indexing\n end",
"def to_utf8(mixed)\n if mixed.kind_of? Array\n mixed.each {|elem| to_utf8(elem)}\n else mixed.kind_of? String\n charset = NKF.guess(mixed).name\n charset == \"UTF-8\" ? mixed : mixed.encode!(\"UTF-8\", charset)\n end\n mixed\n end",
"def encoding_error?(parser = T.unsafe(nil)); end",
"def check_binary(obj)\n return unless RUBY_VERSION >= \"1.9\"\n\n case obj\n when Array\n obj.each { |item| check_utf8(item) }\n when Hash\n obj.each { |key, value|\n check_utf8(key)\n check_utf8(value)\n }\n when String\n obj.encoding.should eql(Encoding.find(\"binary\"))\n obj.valid_encoding?.should be_true\n else\n return\n end\n end",
"def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend",
"def encoding_from_feed_data\n if @encoding_from_feed_data.blank?\n raw_data = self.feed_data\n return nil if raw_data.nil?\n encoding_from_xml_instruct = \n raw_data.scan(\n /^<\\?xml [^>]*encoding=\"([^\\\"]*)\"[^>]*\\?>/\n ).flatten.first\n unless encoding_from_xml_instruct.blank?\n encoding_from_xml_instruct.downcase!\n end\n if encoding_from_xml_instruct.blank?\n begin\n doc = REXML::Document.new(raw_data)\n encoding_from_xml_instruct = doc.encoding.downcase\n if encoding_from_xml_instruct == \"utf-8\"\n # REXML has a tendency to report utf-8 overzealously, take with\n # grain of salt\n encoding_from_xml_instruct = nil\n end\n rescue\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if encoding_from_xml_instruct.blank?\n sniff_table = {\n \"Lo\\247\\224\" => \"ebcdic-cp-us\",\n \"<?xm\" => \"utf-8\"\n }\n sniff = self.feed_data[0..3]\n if sniff_table[sniff] != nil\n @encoding_from_feed_data = sniff_table[sniff].downcase\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if @encoding_from_feed_data.blank?\n # Safest assumption\n @encoding_from_feed_data = \"utf-8\"\n end\n end\n return @encoding_from_feed_data\n end",
"def handle_encoding str\n str = str.dup\n has_enc = str.respond_to? :encoding # TODO: remove\n encoding = nil\n\n header = str.each_line.first(2)\n header.map! { |s| s.force_encoding \"ASCII-8BIT\" } if has_enc\n\n first = header.first || \"\"\n encoding, str = +\"utf-8\", str.b[3..-1] if first =~ /\\A\\xEF\\xBB\\xBF/\n\n encoding = $1.strip if header.find { |s|\n s[/^#.*?-\\*-.*?coding:\\s*([^ ;]+).*?-\\*-/, 1] ||\n s[/^#.*(?:en)?coding(?:\\s*[:=])\\s*([\\w-]+)/, 1]\n }\n\n if encoding then\n if has_enc then\n encoding.sub!(/utf-8-.+$/, \"utf-8\") # HACK for stupid emacs formats\n hack_encoding str, encoding\n else\n warn \"Skipping magic encoding comment\"\n end\n else\n # nothing specified... ugh. try to encode as utf-8\n hack_encoding str if has_enc\n end\n\n str\n end",
"def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end",
"def is_string?(); @type == GRT_STRING; end",
"def utf8_safe\n encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def set_encoding\n Regexp.new(source.force_encoding('UTF-8'), Regexp::FIXEDENCODING | options)\n end",
"def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message.scrub =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end"
] |
[
"0.7808475",
"0.77118534",
"0.77118534",
"0.7521071",
"0.73302364",
"0.7279393",
"0.7240737",
"0.692308",
"0.69070244",
"0.67988724",
"0.6774854",
"0.66129094",
"0.6494309",
"0.63954467",
"0.6335002",
"0.63066363",
"0.6240951",
"0.62139845",
"0.61998117",
"0.61885583",
"0.6171501",
"0.6171501",
"0.6166216",
"0.6158873",
"0.61296207",
"0.60782796",
"0.60744107",
"0.60744107",
"0.60579246",
"0.6048751",
"0.59999645",
"0.59999645",
"0.5983123",
"0.5983123",
"0.59640354",
"0.59640354",
"0.59562814",
"0.5849124",
"0.5771774",
"0.5759287",
"0.56787086",
"0.5675772",
"0.5640856",
"0.5638322",
"0.5619328",
"0.56147754",
"0.56129354",
"0.5591662",
"0.5579296",
"0.55768585",
"0.55717826",
"0.5568587",
"0.556014",
"0.5545055",
"0.55366856",
"0.5530581",
"0.5529837",
"0.55293685",
"0.5510433",
"0.5506584",
"0.5492487",
"0.54541194",
"0.54294074",
"0.5417731",
"0.5407456",
"0.5380639",
"0.5380639",
"0.53749293",
"0.5372367",
"0.53718215",
"0.5365383",
"0.53539294",
"0.53501403",
"0.53482616",
"0.53442496",
"0.53311116",
"0.53128666",
"0.5310605",
"0.530026",
"0.52976394",
"0.52867925",
"0.5286415",
"0.5283166",
"0.52808553",
"0.5268681",
"0.5258749",
"0.52552766",
"0.5254598",
"0.52443963",
"0.5242252",
"0.52332276",
"0.5201567",
"0.51889443",
"0.5183843",
"0.5183622",
"0.5169258",
"0.5167426",
"0.5153201",
"0.51411194",
"0.5134428"
] |
0.77797395
|
1
|
Use callbacks to share common setup or constraints between actions.
|
def set_subject
@subject = Subject.find params[:subject_id]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup_handler\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def before_dispatch(env); end",
"def process_action(...)\n send_action(...)\n end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def action\n end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def config(action, *args); end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def setup\n # override this if needed\n end",
"def matt_custom_action_begin(label); end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def setup_signals; end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def lookup_action; end",
"def around_hooks; end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def action_target()\n \n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def call\n setup_context\n super\n end",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def duas1(action)\n action.call\n action.call\nend"
] |
[
"0.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.5328757",
"0.5310255",
"0.5300339",
"0.5298796",
"0.5295774",
"0.5256034",
"0.5243039",
"0.5236007",
"0.5235239",
"0.5235239",
"0.5235239",
"0.5235239",
"0.5235239",
"0.52321917",
"0.5227032",
"0.52216744",
"0.5216349",
"0.52161187",
"0.5210265",
"0.5207244",
"0.5177388",
"0.5177142",
"0.51747334",
"0.516293",
"0.51629275",
"0.5155534",
"0.51540613",
"0.515197",
"0.5151636",
"0.5145279",
"0.51380795",
"0.5135777",
"0.5117378",
"0.5115066",
"0.5115066",
"0.5110235",
"0.5106418",
"0.50917816",
"0.50909185",
"0.50855017",
"0.5082105",
"0.506359",
"0.5055345",
"0.50546116",
"0.50523037",
"0.50523037",
"0.50327307",
"0.5024364",
"0.5021113",
"0.50174654",
"0.50163317",
"0.5000553",
"0.50002855",
"0.49991882",
"0.49905527",
"0.49905527",
"0.49849054",
"0.4982546",
"0.4980941",
"0.4979153",
"0.49693102",
"0.4967172",
"0.49594432",
"0.49564302",
"0.49552485",
"0.49533385",
"0.49506924",
"0.49452737",
"0.49442786",
"0.49347955",
"0.49341312",
"0.49295264",
"0.49261844",
"0.4925649",
"0.49251428",
"0.4920729",
"0.49177617",
"0.4916373",
"0.49158472",
"0.4915794",
"0.49156648"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def manual_params
params.require(:manual).permit(:name, :name_ukr, :subject, :file)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
TODO Implement me correctly
|
def opinion_poll(*args)
options = args.extract_options!.symbolize_keys
poll_identifier = args.pop
waiting_time = waiting_time()
Rails.logger.debug { "Poll identifier: #{poll_identifier.inspect}" }
Rails.logger.debug { "Other options: #{options.inspect}" }
Rails.logger.debug { "opinion_user: #{opinion_user.inspect}" }
if !waiting_time.nil? && waiting_time - Time.now > 0
Rails.logger.info { "NOT showing opinion-poll, because waiting time #{waiting_time.inspect} has not elapsed." }
render text: ''
elsif Opinion::Poll.active.empty?
Rails.logger.info { 'NOT showing opinion-poll, because no active poll is available' }
# TODO perhaps show whiny text when no active poll is seen / make this configurable
render text: ''
else
poll = Opinion::Poll.active.first
if poll.voted_by?(opinion_user)
Rails.logger.info { 'NOT showing opinion-poll, because user already voted for poll' }
render text: ''
else
# TODO Make modal configurable, maybe someone doesn't like pop-ups.
render :file => 'opinion/polls/_poll_modal.html.erb', :locals => {:poll => poll}
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def suivre; end",
"def formation; end",
"def refutal()\n end",
"def verdi; end",
"def operations; end",
"def operations; end",
"def identify; end",
"def terpene; end",
"def custom; end",
"def custom; end",
"def stderrs; end",
"def berlioz; end",
"def implementation; end",
"def implementation; end",
"def weber; end",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def zuruecksetzen()\n end",
"def who_we_are\r\n end",
"def trd; end",
"def offences_by; end",
"def villian; end",
"def intensifier; end",
"def anchored; end",
"def sitemaps; end",
"def processor; end",
"def schumann; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def relatorios\n end",
"def strategy; end",
"def malts; end",
"def r; end",
"def r; end",
"def eplore\n end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def feruchemist; end",
"def operation; end",
"def bs; end",
"def parts; end",
"def parts; end",
"def parts; end",
"def transformations; end",
"def celebration; end",
"def hd\n \n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def isolated; end",
"def isolated; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def original_result; end",
"def handle; end",
"def extra; end",
"def wrapper; end",
"def next() end",
"def next() end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def returns; end",
"def reflector; end",
"def reflector; end",
"def order; end",
"def order; end"
] |
[
"0.748555",
"0.66358423",
"0.65836436",
"0.63902575",
"0.63902575",
"0.63902575",
"0.63902575",
"0.6268702",
"0.622426",
"0.61125827",
"0.6030002",
"0.5969891",
"0.5969891",
"0.5967723",
"0.591067",
"0.58784556",
"0.58784556",
"0.58782244",
"0.5856519",
"0.5846037",
"0.5846037",
"0.5822818",
"0.5812101",
"0.5812101",
"0.5791537",
"0.5774744",
"0.5750774",
"0.5749298",
"0.57343924",
"0.5696796",
"0.56621236",
"0.56285655",
"0.56259555",
"0.56181663",
"0.5610097",
"0.5610097",
"0.5610097",
"0.5610097",
"0.5610097",
"0.5610097",
"0.5610097",
"0.5610097",
"0.5610097",
"0.55838645",
"0.5573085",
"0.55698466",
"0.5568875",
"0.5568875",
"0.55614406",
"0.5549015",
"0.5549015",
"0.5549015",
"0.5549015",
"0.5549015",
"0.5549015",
"0.5549015",
"0.5549015",
"0.5547938",
"0.55473286",
"0.5543072",
"0.55396336",
"0.55396336",
"0.55396336",
"0.55395013",
"0.55297095",
"0.55245054",
"0.5507203",
"0.5507203",
"0.5507203",
"0.5507203",
"0.549962",
"0.549962",
"0.5496197",
"0.5496197",
"0.5496197",
"0.5496197",
"0.5496197",
"0.5496197",
"0.54947805",
"0.54947805",
"0.54947805",
"0.54947805",
"0.548902",
"0.54765683",
"0.54748654",
"0.5469758",
"0.54671824",
"0.54671824",
"0.54649323",
"0.54649323",
"0.54649323",
"0.54649323",
"0.54649323",
"0.54649323",
"0.54649323",
"0.54649323",
"0.5437497",
"0.54345423",
"0.54345423",
"0.54344225",
"0.54344225"
] |
0.0
|
-1
|
Whether the poll should be displayed.
|
def opinion_show_poll?
begin
!opinion_user.nil?
rescue NoMethodError
false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def none?\n self.display_on == \"none\"\n end",
"def displayed?; end",
"def visible?\n @visible\n end",
"def visible?\n @visible\n end",
"def visible?\n\t\t\t@visible\n\t\tend",
"def visible?\n end",
"def visible?; \n\t\t@visible = true if @visible == nil\n\t\t@visible\n\tend",
"def visible?\n true\n end",
"def show?\n true\n end",
"def display?\n @document_self and not @ignored and\n (documented? or not @suppressed)\n end",
"def show?\n return true\n end",
"def displayed?\n return (self.d_publish <= Time.zone.today) && (self.d_remove > Time.zone.today)\n end",
"def show?\n true\n end",
"def show?\n true\n end",
"def show?\n true\n end",
"def show?\n true\n end",
"def visible?\n !value.nil?\n end",
"def is_visible?\n setup.show_all? || Date.today >= start_at\n end",
"def frontend?\n self.display_on != \"back_end\" && !none?\n end",
"def screening?\n self.tip == \"screening\"\n end",
"def is_showable\n return true unless self.is_hidden or self.is_deleted or self.status == \"tmp\"\n end",
"def show_only?\n now = Time.now.to_i\n now >= end_time && now <= close_time\n end",
"def display_operational\n self.operational ? \"Yes\" : \"No\"\n end",
"def frontend?\n self.display_on != \"back_end\"\n end",
"def display_show_in_api\n self.show_in_api ? \"Yes\" : \"No\"\n end",
"def on_display?\n is_sold && ( !discontinued? || has_stock? ) && ( has_stock? || Spree::Config[:show_zero_stock_products] )\n end",
"def visible?\n @dialog ? true : false\n end",
"def visible?\n @style.display != 'none'\n end",
"def helpDisplayed?\n @helpDisplayed\n end",
"def cvv_help_displayed?\n cvv_help_div.visible?\n end",
"def is_visible?\n visibility && ( visibility > 0 )\n end",
"def poll_readable?\n false\n end",
"def splayed?\n splayed\n end",
"def show\n if(@poll.has_been_voted_on_by current_user)\n render action: 'show_results' \n end\n end",
"def should_render_facet? display_facet\n # display when show is nil or true\n facet_config = facet_configuration_for_field(display_facet.name)\n\n display = case facet_config.show\n when Symbol\n arity = method(facet_config.show).arity\n\n if arity == 0\n send(facet_config.show)\n else \n send(facet_config.show, display_facet)\n end\n when Proc\n facet_config.show.call self, facet_config, display_facet\n else\n facet_config.show\n end\n\n return display && display_facet.items.present?\n end",
"def beta_question?\n !display_timer?\n end",
"def visibility_allowed?\n value=(self.num_answered_questions().to_f/self.num_questions()*100).round(2)\n !self.is_test? && value >= Rails.application.config.default_plan_percentage_answered\n end",
"def display_checked?(_preferences, _value)\n false\n end",
"def showable?\n hidden? && hidden_origin.blank?\n end",
"def showable?\n hidden? && hidden_origin.blank?\n end",
"def include_in_menu?\n menu_options[:display] != false\n end",
"def hide?\n @hide\n end",
"def shown_in_menu?\n false\n end",
"def full_display?(flat_answer_data)\n true\n end",
"def display?(flat_answer_data)\n true\n end",
"def just_shown_results?\n return true if get[just_shown_key]\n end",
"def poll_readable?\n true\n end",
"def display?\n visible && (conditions.blank? || ((!conditions.blank?) && (eval(conditions))))\n end",
"def display?\n text? and super\n end",
"def displayed?\n static_module.displayed?\n end",
"def visibility?\n @visibility || true\n end",
"def visible?\n if ta_visible || peer_visible\n true\n else\n errors.add(:base, I18n.t('activerecord.errors.models.criterion.visibility_error'))\n false\n end\n end",
"def visible?\n el.displayed?\n end",
"def chosen_baptized_catholic?\n show_empty_radio == 2\n end",
"def visible?\n wd_element.displayed?\n end",
"def display_message?\n if play? || seconds - @last_time_value < 6 && @last_time_value >= @level_num\n true\n else\n false\n end\n end",
"def show_prf?\n bathing_water['latestProfile.pollutionRiskForecasting'].val == 'true'\n end",
"def show?\n return true if user.admin? || is_in_company?(record)\n\n record.information_complete? ? true : false\n end",
"def display_featured_researcher?\n Flipflop.show_featured_researcher?\n end",
"def is_public?\n !@@hide_status_choices.include?(self.status)\n end",
"def scores_enabled?\n session[:show_scores] != false\n end",
"def show?\n !@proposal.nil?\n end",
"def schedule_visible?\n schedule_public? || params[:preview]\n end",
"def active_calls_show_did?\n Confline.active_calls_show_did?\n end",
"def is_hidden?\n\t\tself.hidden\n\tend",
"def display_featured_works?\n Flipflop.show_featured_works?\n end",
"def visible?\n !(self.created? || self.suspended? || self.deleted?)\n end",
"def visible?\n !(self.created? || self.suspended? || self.deleted?)\n end",
"def visible?\n !(self.created? || self.suspended? || self.deleted?)\n end",
"def show?\n end",
"def should_render_show_field? document, field_config\n should_render_field?(field_config, document) && document_has_value?(document, field_config)\n end",
"def show_wait_for_trip_confirmation_form?\n self.persisted? && !self.wtg_to_clear_pickup? && !self.wtg_for_driver_dispatch?\n end",
"def show_in_menu?\n true\n end",
"def hidden?\n false\n end",
"def show_perc?\n @perc\n end",
"def hidden?\n false\n end",
"def hidden?\n false\n end",
"def display_bar?\n !@options['debug'] && !@options['silent']\n end",
"def hidden?\n not visible\n end",
"def help_always?\n @show_help =~ /always/i\n end",
"def show_results_tip?\n # Logged-in user who has the tip hidden?\n return false if current_user&.hide_results_tip\n\n setting = session[:hide_results_tip]\n\n return true unless setting\n return false if setting == :all\n\n setting != Current.setting.api_session_id\n end",
"def chosen_baptized_at_home_parish?\n show_empty_radio == 1 || show_empty_radio == 2\n end",
"def invisible?\n false\n end",
"def display_boolean(value:)\n return 'Unspecified' if value.nil?\n\n value ? 'Yes' : 'No'\n end",
"def invisible?\n false\n end",
"def invisible?\n false\n end",
"def in_use?\n published? || has_answers? || has_choices?\n end",
"def displayed?\n as_page_class.displayed?\n end",
"def open_popup?\n return self.popup != nil\n end",
"def preferred?\n self.preferred\n end",
"def interactive?\n val = @gapi.configuration.query.priority\n return true if val.nil?\n val == \"INTERACTIVE\"\n end",
"def should_render_facet? display_facet\n # display when show is nil or true\n facet_config = facet_configuration_for_field(display_facet.name)\n # CF - Allow for the restriction of certain facets to certain users\n return false if facet_config.restricted_to_roles && hide_restricted_facet?(facet_config.restricted_to_roles)\n display = should_render_field?(facet_config, display_facet)\n return display && display_facet.items.present?\n end",
"def rendered?\n end",
"def display_header?\n !@request.hide_title?\n end",
"def button?\n\t\tcan_button? and show_button\n\tend",
"def enabled?; end",
"def enabled?; end",
"def should_render_facet?(display_facet)\n # display when show is nil or true\n facet_config = facet_configuration_for_field(display_facet.name)\n display = should_render_field?(facet_config, display_facet)\n display_facet.items.reject! { |item| item.value.blank? }\n display && display_facet.items.present? # && !display_facet.items.empty?\n end",
"def show_prize_ui?\n false\n end",
"def visa_check?\n schengen_overstay? == false && visa_overstay? == false\n end"
] |
[
"0.6828312",
"0.6826389",
"0.67114335",
"0.67114335",
"0.6707115",
"0.66168153",
"0.65816414",
"0.6580757",
"0.6567434",
"0.6566592",
"0.654277",
"0.6489286",
"0.64805996",
"0.64805996",
"0.64805996",
"0.64805996",
"0.64422774",
"0.6438991",
"0.6374206",
"0.6372065",
"0.6367294",
"0.6354693",
"0.6345235",
"0.6341713",
"0.6334727",
"0.63110554",
"0.6308157",
"0.6302468",
"0.6296462",
"0.62932664",
"0.6274627",
"0.62602156",
"0.62529063",
"0.6246083",
"0.6220145",
"0.62198126",
"0.6211993",
"0.6208147",
"0.6193989",
"0.6193989",
"0.6187638",
"0.6185757",
"0.61840916",
"0.61770755",
"0.61750746",
"0.61682326",
"0.6154085",
"0.6140211",
"0.61370814",
"0.6130527",
"0.6121179",
"0.60927546",
"0.60893667",
"0.608758",
"0.6086159",
"0.6079235",
"0.6079166",
"0.60501254",
"0.6048951",
"0.60477877",
"0.60464746",
"0.6034628",
"0.60311115",
"0.60289866",
"0.60245776",
"0.60196793",
"0.6018098",
"0.6018098",
"0.6018098",
"0.6017859",
"0.6014545",
"0.6010615",
"0.6003131",
"0.600154",
"0.5992711",
"0.5989793",
"0.5989793",
"0.5974826",
"0.59724",
"0.59693956",
"0.59672374",
"0.5965768",
"0.5963719",
"0.5962401",
"0.5944064",
"0.5944064",
"0.5942683",
"0.59232837",
"0.5922091",
"0.59213036",
"0.59198976",
"0.59071386",
"0.5906154",
"0.58954334",
"0.58949125",
"0.5882691",
"0.5882691",
"0.58823144",
"0.5879289",
"0.5872252"
] |
0.7540485
|
0
|
Create new favorite for current customer
|
def create
fav_params = params.require(:favorite).permit(:content_id, :content_type)
@favorite = Favorite.new(fav_params)
@favorite.customer_id = current_person.user.id
@favorite.save
redirect_to request.referer
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def favorite\n\t\tclient = Client.find(params[:client_id])\n\t\tfavorite = Favorite.new(client_id: params[:client_id])\n\t\tcurrent_user.customer.favorites ||= []\n\t\tcurrent_user.customer.favorites << favorite\n\t\tredirect_to root_path, notice: \"Company added to favorites\"\n\tend",
"def add_favorite options={}\n\t options[:comic_id] = self.comic\n\t self.favorites.create!(options)\n\tend",
"def create\n @customer = Customer.new(customer_params)\n\n respond_to do |format|\n if @customer.save\n set_favorite\n format.html { redirect_to @customer,\n notice: I18n.t('saved') }\n format.json { render action: 'show',\n status: :created, location: @customer }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = user.favorites.new(favorite_params)\n\n if @favorite.save\n render :show, status: :ok\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def create\n @book = Book.find(params[:book_id])\n @user = current_user\n @favorite = current_user.favorites.new(book_id: @book.id)\n @favorite.save\n end",
"def create\n session[:return_to] ||= request.referer\n @favourites = Favourite.new(favourite_params)\n\n\n respond_to do |format|\n if @favourites.save\n format.html { redirect_to session.delete(:return_to), notice: 'Favourite was successfully created.' }\n format.json { render action: 'show', status: :created, location: data_show_path }\n else\n format.html { render action: 'new' }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n recipe = Recipe.find(params[:id])\n @favorite = current_user.add_to_favorite(recipe.id)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to :back, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(params[:favorite])\n @favorite.user = current_user\n \n respond_to do |format|\n if @favorite.save\n format.html { redirect_to(favorites_url, :notice => 'Favorite was successfully created.') }\n format.xml { render :xml => @favorite, :status => :created, :location => @favorite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @favorite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n Favorite.create favorite_params\n show_all\n end",
"def create\n fav = params[:favorite]\n fav[:user_id] = current_user.id\n fav[:name] = fav[:note]\n @favorite = Favorite.new(fav)\n @favorite.save\n render 'toggle'\n end",
"def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end",
"def create\n @favorite = current_user.favoritables.build(favorite_params)\n\n if @favorite.save\n render json: @favorite, status: :created\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end",
"def create\n sign_user_in(identified_user, given_password)\n\n if current_user\n image_file = open(params[:favorite][:url])\n attributes = params[:favorite].merge(image: image_file)\n @favorite = current_user.favorites.build(attributes)\n @favorite.save!\n render inline: '<script>window.close();</script>'\n else\n @url = params[:favorite][:url]\n @page_url = params[:favorite][:page_url]\n render :new\n end\n end",
"def create_favorites(brewery_id)\n Favorite.create(user_id: current_user.id,brewery_id:brewery_id)\n end",
"def create_favorites(brewery_id)\n Favorite.create(user_id: current_user.id,brewery_id:brewery_id)\n end",
"def create\n favory = current_user.favories.create(product_id: params[:id], user_id: current_user.id)\n redirect_to products_path()\n end",
"def create\n @favorite = current_user.favorites.build(params[:favorite])\n if @favorite.save\n flash[:notice] = \"Favorite saved!\"\n end\n # redirect_to root_path\n respond_with(@favorite)\n end",
"def favorite!(travel)\n favorites.find_or_create_by!(travel_id: travel.id)\n end",
"def create\n @favorite = current_user.favorites.create(favorited_id:params[:favorited_id], favorited_type: params[:favorited_type])\n logger.debug \"FAV \" + @favorite.to_s\n respond_to do |format|\n format.js\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite\n if current_user\n info = params[:recipe_id]\n @found = Favorite.find_by(recipe_id: info, user_id: current_user.id)\n if !@found\n @favorite = Favorite.new\n @favorite.recipe_id = info\n @favorite.user_id = current_user.id\n @favorite.save!\n head :ok\n end\n else\n redirect_to '/'\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n format.html { redirect_to @favourite, notice: \"Favourite was successfully created.\" }\n format.json { render :show, status: :created, location: @favourite }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n format.html { redirect_back notice: 'Favourite was successfully created.', fallback_location: root_path }\n format.json { render :show, status: :created, location: @favourite }\n else\n format.html { render :new }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(params[:favorite])\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render json: @favorite, status: :created, location: @favorite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favourites = Favourite.new()\n @favourites.user_id = current_user.id;\n @favourites.army_list_id = params[:favourite][:army_list_id]\n \n respond_to do |format|\n if @favourites.save\n flash[:notice] = 'Favourites was successfully created.'\n format.html { redirect_back_or_default(user_favourites_url(current_user)) }\n format.xml { render :xml => @favourites, :status => :created, :location => @favourites }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @favourites.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_favourite(user_id, favourite_name)\n @favourites_store.create(user_id, favourite_name)\n end",
"def set_favourite\n if user_signed_in?\n @favourite = Favourite.where(user_id: current_user.id, product_id: set_product()).first\n end\n end",
"def set_favorite\n @favorite = current_user.favorites.find(params[:id])\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n if @favourite.save\n render text: 'ok'\n else\n render text: 'fail'\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n if @favorite.save\n render json: FavoriteSerializer.new(@favorite), status: :created\n else\n render json: @favorite.errors.full_messages.to_sentence, status: :unprocessable_entity\n end\n end",
"def create\n @favoriten = Favoriten.new(favoriten_params)\n\n respond_to do |format|\n if @favoriten.save\n format.html { redirect_to @favoriten, notice: 'Favoriten was successfully created.' }\n format.json { render :show, status: :created, location: @favoriten }\n else\n format.html { render :new }\n format.json { render json: @favoriten.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(client_id: current_user.id, route_id: params[:route_id])\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sync_to_favorite\n user.user_inviters.map do |user_inviter|\n favorite = favorites.build(user_id: user_inviter.id)\n favorite.save\n favorite\n end\n end",
"def create\n\n @favourite_details = Hash.new\n\n @favourite_details[:user_id] = params[:user_id]\n @favourite_details[:job_posting_id] = params[:job_posting_id]\n @favourite_details[:status_flag] = params[:status_flag]\n @favourite = Favourite.new(@favourite_details)\n\n respond_to do |format|\n if @favourite.save\n flash[:notice] = 'Favourite was successfully created.'\n format.html { redirect_to(@favourite) }\n format.xml { render :xml => @favourite, :status => :created, :location => @favourite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @favourite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_to_favourites\n \n #pull out whichever recipe you are clicking on\n yummly_id = params[:yummly_id]\n recipe = Yummly.find(yummly_id)\n\n # make new instance of that recipe\n r = Recipe.find_or_create_by(name: recipe.name, thumbnail: recipe.thumbnail)\n\n UserFavouriteRecipe.create(recipe_id: r.id, user_id: current_user.id, yummly_id: yummly_id)\n\n redirect_to recipes_url, notice: \"Added recipe from your list of favourite recipes\"\n\n end",
"def create\n favourite=current_user.add_favourite(params[:key])\n if favourite\n respond_to do |format|\n format.json { render :json => jsonp(favourites_to_json([favourite])) }\n format.xml { render :xml => favourites_to_xml([favourite]) }\n format.text { render :text => text_not_supported }\n end\n else\n render_error('Favourite not found', 404)\n end\n end",
"def create\n shop = Shop.find(params[:id])\n @shop_favorite = user_session.get_logged_in_user.shop_favorites.build(shop: shop)\n respond_to do |format|\n if @shop_favorite.save\n format.html { restore_last_request(notice: 'Shop favorite was successfully created.') }\n format.json { render :show, status: :created, location: @shop_favorite }\n else\n format.html { render :new }\n format.json { render json: @shop_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def correct_customer\n @favorite = Favorite.find(params[:id])\n current_person.user == @favorite.customer\n end",
"def add_favorite(court)\n self.favorites.find_or_create_by(court:court)\n end",
"def add_to_favorites(new_fav)\n @fav_list << new_fav \n end",
"def set_favourite\n @favourite = Favourite.find(params[:id])\n end",
"def set_favourite\n @favourite = Favourite.find(params[:id])\n end",
"def set_favourite\n @favourite = Favourite.find(params[:id])\n end",
"def create\n check_favourite = Search::Favourite.check_if_already_favourite(params[:show_id].to_i, current_user.id)\n if check_favourite\n flash[:notice] = 'Favourite already Created.'\n redirect_to root_path\n else\n @favourite = Favourite.new(show_id: favourite_params)\n @favourite.user_id = current_user.id\n show_detail = ShowService.get_show_and_channel_detail(@favourite.show_id)\n respond_to do |format|\n if @favourite.save\n FavouriteMailer.delay(run_at: show_detail[:show_time].to_time - 30.minutes).send_reminder(current_user.email, show_detail)\n format.html { redirect_to root_path, notice: 'Favourite was successfully created.' }\n format.json { render :show, status: :created, location: @favourite }\n else\n format.html { render :new }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n #I have the quote id from params and I have the @user instamce\n already_there = Favorite.find_by(user:@user,quote_id:params[:id])\n if already_there\n render json: {error_message:\"You already have this quote in your favorites\"}\n else\n new_favorite = Favorite.create(user:@user,quote_id:params[:id])\n render json: new_favorite\n end\n end",
"def add_cars_to_favourite\n\n @car = User.find(params[:savedcar])\n current_user.saved_cars.build(savedcar_id: @car.id)\n\n if current_user.save\n flash[:notice] = 'car was successfully added'\n else\n flash[:danger] = 'There was something wrong with the car saving'\n end\n # redirect to the same page\n redirect_back(fallback_location:\"/\")\n end",
"def create\n @favoritepizza = Favoritepizza.new(favoritepizza_params)\n\n @favoritepizza = Favoritepizza.new params.require(:favoritepizza).permit(:pizza_id)\n if @favoritepizza.save\n current_user.favoritepizzas << @favoritepizza\n redirect_to user_path current_user\n else\n render :back\n end\n end",
"def create_favorites\n @user = self\n playlist = Playlist.create(:title => \"Favorites\", :user_id => @user.id, :favorite => true)\n end",
"def set_favourite\n @favourite = Favourite.find(params[:id])\n end",
"def user_favorite\r\n\t\t\tif params[:is_add] == '1'\r\n\t\t\t\trender json: UsersFavoriteProject.add_favorite(params[:id])\r\n\t\t\telse\r\n\t\t\t\trender json: UsersFavoriteProject.remove_favorite(params[:id])\r\n\t\t\tend\r\n\t\tend",
"def create\n build_resource\n if resource.valid?\n if resource.favorited_user.present? && is_valid_favorite(resource.favorited_user)\n resource.save\n render json: resource, serializer: Api::V1::FavoriteSerializer\n else\n render json: [{'error':'Unable to favorite this user'}], status: :unprocessable_entity\n end\n else\n render json: resource.errors, status: :unprocessable_entity\n end\n end",
"def show\n @favoritepizza = Favoritepizza.new\n if not (current_user.nil?)\n @favoritepizza.user = current_user\n end\n end",
"def favorite_restaurant\n Favorite.favorite_restaurant(current_user,Restaurant.find(params[:restaurant]), \"true\")\n redirect_to restaurants_url\n end",
"def create\n favorite_image = current_user.favorite_images.new(create_params)\n if favorite_image.save\n render json: { id: favorite_image.id }, status: :ok\n else\n render json: { error: favorite_image.errors.full_messages.to_sentence }, status: :bad_request\n end\n end",
"def favorite\n type = params[:type] # get the type from the url (fav/unfav)\n ass = params[:controller] # get the current controller name\n clazz = params[:controller].classify.constantize # get the controllers class in with big upper letter\n obj = clazz.find_by tiss_id: params[:tiss_id] # find the object with the tiss_id\n obj = clazz.create tiss_id: params[:tiss_id] if obj.nil? # create if not exists\n alreadyfav = current_user.send(ass).exists?(obj.id) # is it already fav?\n if type == 'favorite' && !alreadyfav # if not already fav and we want to fav\n current_user.send(ass) << obj # fav it\n flash[:success] = \"Favorite successful\" # success msg\n elsif type == 'unfavorite' && alreadyfav # else\n current_user.send(ass).delete(obj) # unfav\n flash[:success] = \"Unfavorite successful\" # success msg\n else\n flash[:danger] = \"Nothing happened\" # nothing happened msg\n end\n redirect_back fallback_location: root_path # return\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n sync_update @favourite.fav_post\n format.html { redirect_to :my_favourites, notice: 'Favourite was successfully created.' }\n format.json { render json: @favourite }\n else\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favor = Favor.new(params[:favor])\n @favor.user = current_user\n @favor.status = 'open'\n\n respond_to do |format|\n if @favor.save\n # Decrement the points from the current user's points total.\n current_user.points = current_user.points - @favor.points\n current_user.save\n format.html { redirect_to @favor, notice: 'Favor was successfully created.' }\n format.json { render json: @favor, status: :created, location: @favor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n my_facility = MyFacility.find(params[:my_facility_id])\n current_user.add_favorite(my_facility)\n flash[:success] = \"お気に入りに追加しました\"\n redirect_back(fallback_location: root_path)\n end",
"def favorite!(wallpaper)\n self.favorites.create!(wallpaper_id: wallpaper.id)\n end",
"def create\n @favorite_item = current_user.favorite_items.new(favorite_item_params)\n\n respond_to do |format|\n if @favorite_item.save\n format.html { redirect_to @favorite_item, notice: t('.notice') }\n format.js\n format.json { render :show, status: :created, location: @favorite_item }\n else\n format.html { render :new }\n format.json { render json: @favorite_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n note = Note.active.find(params[:note_id])\n fav = current_user.favorites.find_by_note_id(note)\n params[:point] = 1 unless params[:point].to_i > 0\n if fav\n Favorite.update_counters(fav.id, point: params[:point].to_i)\n else\n current_user.favorites.create(note: note, point: params[:point].to_i)\n end\n head :no_content\n end",
"def has_favorite( favorite_obj )\n favorite = get_favorite( favorite_obj )\n if favorite.nil?\n favorite = Favorite.create( :user_id => self.id,\n :favorable_type => favorite_obj.class.to_s, \n :favorable_id => favorite_obj.id )\n end\n favorite\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def create\n @favorecido = Favorecido.new(favorecido_params)\n @favorecido = @favorecido\n respond_to do |format|\n if @favorecido.save\n format.html { redirect_to favorecidos_url, notice: 'Favorecido criado com sucesso.' }\n format.json { render :show, status: :created, location: @favorecido }\n else\n format.html { render :new }\n format.json { render json: @favorecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fav\n @job = Job.find(params[:id])\n\n\t\t@favorite = Favorite.new(:person_id => current_user.id, :job_id => @job.id)\n\t\t@favorite.save\n\t\tflash[:notice] = 'Job successfully marked as Favorite.'\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(:back) }\n\t\t\tformat.xml { head :ok }\n\t\t\tformat.js\n\t\tend\n end",
"def create\n favorite = Favorite.new\n # associate the user and post with the favorites\n favorite.user = current_user\n # post is defined as a method below, found via a find of post_id\n favorite.post = post\n\n respond_to do |format|\n if favorite.save\n format.html { redirect_to post_path(post), notice: \"Favorited!\" }\n format.js { render } # favorites/create.js.erb\n else\n format.html { redirect_to post_path(post), notice: \"You have already favorited!\" }\n format.js { render js: \"alert('Can\\'t favorite, please refresh the page!')\"; }\n end\n end\n\n end",
"def add_favorite\n FavoritePhoto.create(user: current_user, photo_id: params[:id])\n redirect_to @photo\n end",
"def add_favorite_beer\n begin\n #Check current user have a favorite beer\n favorite = @current_user.favorite_beer\n\n #Have favorite beer ? update : create\n if favorite\n favorite.update!(beer_id: params[:id])\n else\n favorite = FavoriteBeer.new\n favorite.user_id = @current_user.id\n favorite.beer_id = params[:id]\n favorite.save!\n end\n\n render json: FavoriteBeerSerializer.new(favorite).data\n rescue StandardError => e\n message = e.message\n end\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id]) \n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def create\n @fav = Fav.new(params[:fav])\n\n respond_to do |format|\n if @fav.save\n format.html { redirect_to @fav, notice: 'Fav was successfully created.' }\n format.json { render json: @fav, status: :created, location: @fav }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fav.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favor = Favor.new(params[:favor])\n\n respond_to do |format|\n if @favor.save\n format.html { redirect_to @favor, notice: 'Favor was successfully created.' }\n format.json { render json: @favor, status: :created, location: @favor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorito = Favorito.new(params[:favorito])\n\n respond_to do |format|\n if @favorito.save\n format.html { redirect_to @favorito, notice: 'Favorito was successfully created.' }\n format.json { render json: @favorito, status: :created, location: @favorito }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favorito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user\n @favorite_movie = @user.favorite_movies.build(favorite_movie_params)\n if @user.save\n render json: @favorite_movie\n end\n end",
"def create\n @auction_favorite = Auction::Favorite.new(auction_favorite_params)\n\n respond_to do |format|\n if @auction_favorite.save\n format.html { redirect_to @auction_favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @auction_favorite }\n else\n format.html { render :new }\n format.json { render json: @auction_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mark_favourite\n @favourite_artist = FavouriteArtist.where(spotify_id: params[:spotify_id]).first_or_create(_params)\n render :json => @favourite_artist.to_json\n end",
"def create\n # @favourite_listing = FavouriteListing.new(params[:favourite_listing])\n #@favourite_listing.user = current_user\n #@favourite_listing.listing = Listing.find(params[:listing_id])\n\n @favourite_listing= current_user.add_to_favourites(params[:listing_id])\n\n if @favourite_listing.save\n redirect_to favourite_listings_url, :notice => \"Current listening was added to your favourites\"\n else\n redirect_to favourite_listings_url, :alert => \"Listing has already been added\"\n end\n end",
"def favorite_for(user)\n favs.find_by(user_id: user)\n end",
"def create\n @favo = Favo.new(favo_params)\n\n respond_to do |format|\n if @favo.save\n format.html { redirect_to @favo, notice: 'Favo was successfully created.' }\n format.json { render :show, status: :created, location: @favo }\n else\n format.html { render :new }\n format.json { render json: @favo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_favorite\n @json = Punk::API.one_beer!(params[:id])\n @json = @json&.first\n if FavoriteBeer.where(punk_id: @json[:punk_id], user_id: @current_user.id).empty?\n @fav_beer = FavoriteBeer.new(@json)\n @fav_beer.user_id = @current_user.id.to_i\n @fav_beer.save!\n end\n\n @json[:favorite] = true\n render json: {\n favorite_beer_set: @json\n }\n end",
"def select_favorite\n Favorite.update_favorite(1,params[:id],current_user.id)\n redirect_back(fallback_location: restaurants_url)\n end",
"def favorite_customer\n cust = Customer.joins(invoices: [:transactions])\n .where(\"transactions.result = ?\", \"success\")\n .select(\"customers.*, count(transactions.id) as sales\")\n .group(:id)\n .order(\"sales desc\")\n .limit(1)\n\n cust.to_a.shift\n end",
"def mark_item_as_favorite(product_id, item_number)\n self.client.post(\"products/#{product_id}/items/#{item_number}/favorites\")\n end",
"def set_favorecido\n @favorecido = Favorecido.find(params[:id])\n end",
"def set_favorite_item\n @favorite_item = FavoriteItem.find(params[:id])\n end",
"def favourites\n\t\t\t\t@user = User.find_by(:facebook_id => params[:id_facebook])\n\t\t\t\t@favourites = Favourite.where(\"user_id = #{@user.id}\")\n\t\t\tend",
"def create\n @favourites_recipe = FavouritesRecipe.new\n @favourites_recipe.user_id = current_user.id\n @favourites_recipe.recipe_id = params[:recipe_id]\n respond_to do |format|\n if @favourites_recipe.save\n format.html { redirect_to @favourites_recipe, notice: 'Favourites recipe was successfully created.' }\n format.json { render :show, status: :created, location: @favourites_recipe }\n else\n format.html { render :new }\n format.json { render json: @favourites_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @list_favorite = ListFavorite.new(list_favorite_params)\n\n respond_to do |format|\n if @list_favorite.save\n format.html { redirect_to @list_favorite, notice: 'Lista foi adicionada aos favoritos!' }\n format.json { render :show, status: :created, location: @list_favorite }\n else\n format.html { render :new }\n format.json { render json: @list_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kf_course_user_fav = Kf::CourseUserFav.new(params[:kf_course_user_fav])\n\n respond_to do |format|\n if @kf_course_user_fav.save\n format.html { redirect_to kf_course_user_favs_url({:page => params[:page]}), notice: 'Course user fav was successfully created.' }\n format.json { render json: @kf_course_user_fav, status: :created, location: @kf_course_user_fav }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kf_course_user_fav.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favor_user = FavorUser.new(favor_user_params)\n\n respond_to do |format|\n if @favor_user.save\n format.html { redirect_to @favor_user, notice: 'Favor user was successfully created.' }\n format.json { render :show, status: :created, location: @favor_user }\n else\n format.html { render :new }\n format.json { render json: @favor_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favour = Favour.new(favour_params)\n\n respond_to do |format|\n if @favour.save\n format.html { redirect_to @favour, notice: 'Favour was successfully created.' }\n format.json { render :show, status: :created, location: @favour }\n else\n format.html { render :new }\n format.json { render json: @favour.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.8271767",
"0.7489527",
"0.7459689",
"0.7435058",
"0.7305186",
"0.72869235",
"0.7279919",
"0.7273035",
"0.7238405",
"0.72163254",
"0.71911955",
"0.71271384",
"0.70735866",
"0.7070294",
"0.70605356",
"0.70605356",
"0.70395124",
"0.70105875",
"0.70036817",
"0.69478494",
"0.6939991",
"0.6939991",
"0.69352496",
"0.6932247",
"0.6924136",
"0.68924624",
"0.6857496",
"0.6847814",
"0.68422705",
"0.6803792",
"0.67703074",
"0.67666477",
"0.6762538",
"0.67527777",
"0.6721698",
"0.66811085",
"0.6677317",
"0.66731906",
"0.66722655",
"0.66688293",
"0.6666092",
"0.66444045",
"0.66415316",
"0.66415316",
"0.66415316",
"0.6631546",
"0.66268086",
"0.66253495",
"0.6605845",
"0.6602439",
"0.6593919",
"0.65787643",
"0.6578357",
"0.65705657",
"0.6566518",
"0.65585434",
"0.655563",
"0.65398693",
"0.653745",
"0.6531787",
"0.6531575",
"0.65236235",
"0.6521405",
"0.65053463",
"0.65010005",
"0.65010005",
"0.6500447",
"0.6500447",
"0.6500447",
"0.6500447",
"0.6500447",
"0.6500447",
"0.65001845",
"0.6497378",
"0.64856756",
"0.64850163",
"0.64820063",
"0.6481908",
"0.64735544",
"0.6465685",
"0.6457665",
"0.6452961",
"0.6449129",
"0.6448101",
"0.64144695",
"0.6398457",
"0.6396216",
"0.6385552",
"0.63400316",
"0.63376176",
"0.633566",
"0.6328223",
"0.63138896",
"0.631012",
"0.63065094",
"0.6291635",
"0.62848246",
"0.62627727",
"0.62569034",
"0.6255942"
] |
0.78577256
|
1
|
Check favorite belongs to current user
|
def correct_customer
@favorite = Favorite.find(params[:id])
current_person.user == @favorite.customer
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def favorite?\n\t is_favorite_of User.current_user\n\tend",
"def favorite_check user, img\n user.favorites.each do |fav|\n if fav.image_id == img.id\n return true\n end\n end\n\n return false\n end",
"def favorited_by?(user)\n favorites.where(user_id: user.id).exists?\n end",
"def is_favorite? (user_id)\n\t\tself.favorite_opportunities.find_by user_id: user_id\n\tend",
"def favorited_by?(user)\n Favorite.where('object_id = ? AND object_type = ? AND user_id = ?', self.id, self.class.to_s, user.id).count > 0\n end",
"def is_fav?(user)\n user.favs.find_by(post_id: self.id)\n end",
"def is_favorite_of user\n\t fave = get_favorite_for user\n\t fave ? true : false\n\tend",
"def user_favourites(current_user, product)\n Favourite.where(user_id: current_user, product_id: product) > 0\n end",
"def favored?(user_id)\n return self.favorites.exists?(user_id: user_id)\n end",
"def show\n @favorite_exists = Favorite.where(post: @post, user: current_user) == [] ? false : true\n\n end",
"def users_favorite?(user)\n votes.any? { |v| v.user_id == user.id && v.favorite }\n end",
"def favorited?(user, coffeeshop)\n coffeeshop.users.each do |coffeeshop_user|\n return true if coffeeshop_user == user\n end\n return false\n end",
"def user_has_favorite(image_id)\n if self.favorites.find_by(image_id: image_id)\n return true \n else \n return false\n end\n end",
"def has_favorite( favorite_obj )\n favorite = get_favorite( favorite_obj )\n if favorite.nil?\n favorite = Favorite.create( :user_id => self.id,\n :favorable_type => favorite_obj.class.to_s, \n :favorable_id => favorite_obj.id )\n end\n favorite\n end",
"def favorite_for(user)\n favs.find_by(user_id: user)\n end",
"def favorite_check\n @check = @fav_list.include?(@selected_activity.last)\n \n end",
"def favorite?\n @favorite\n end",
"def favourite_for(user)\n favourites.find_by_user_id user\n end",
"def show\n @userID = (current_user.blank?) ? 0 : current_user.id\n @isUserFavourite = Favourite.where(user_id: @userID, movie_id: @movie.id).count > 0 ? true : false\n end",
"def has_favorite?( favorite_obj )\n favorite = get_favorite( favorite_obj )\n favorite ? self.favorites.exists?( favorite.id ) : false\n end",
"def showFavorites\n if current_user\n @favorites = Favorite.where(user_id: current_user.id)\n else\n redirect_to '/'\n end\n end",
"def has_favourited_post?(post_id)\n Favourite.where(:post_id => post_id, :user_id => self.id).any?\n end",
"def favorite?\n @favorite\n end",
"def favorite?\n @favorite\n end",
"def set_favourite\n if user_signed_in?\n @favourite = Favourite.where(user_id: current_user.id, product_id: set_product()).first\n end\n end",
"def get_favorite_for user\n\t user.favorites.find_by_page_id(self)\n end",
"def set_favorite\n @favorite = current_user.favorites.find(params[:id])\n end",
"def show\n\n @favoritepet_exists = Favoritepet.where(petprofile: @petprofile, user: current_user) == [] ? false : true\n end",
"def toggle_favorite_for user\n\t fave = user.favorites.find_by_page_id(self)\n\t if fave\n\t fave.destroy\n\t else\n\t fave = add_favorite(:created_by => user)\n\t end\n\t fave\n\tend",
"def user_favorite_moves\n FavoriteMove.all.select do |fav|\n fav.user == self \n end \n end",
"def is_favorite?\n\t favorite?\n\tend",
"def favorite\n if current_user\n info = params[:recipe_id]\n @found = Favorite.find_by(recipe_id: info, user_id: current_user.id)\n if !@found\n @favorite = Favorite.new\n @favorite.recipe_id = info\n @favorite.user_id = current_user.id\n @favorite.save!\n head :ok\n end\n else\n redirect_to '/'\n end\n end",
"def show\n @favorite = current_user.favorites.find_by(session_login_id: @session_login.id)\n end",
"def has_favorite?(vanue_or_venue_id)\n v_id = (vanue_or_venue_id.kind_of?(Venue)) ? vanue_or_venue_id.id : vanue_or_venue_id\n self.favorites.select {|f| f.favorite_id == v_id }.size > 0\n end",
"def toggle_favorite\n\t toggle_favorite_for User.current_user\n\tend",
"def has_fav?(game_id)\n\t FavouriteGame.where(:user_id => self.id, :game_id => game_id).empty?\n end",
"def favourites\n\t\t\t\t@user = User.find_by(:facebook_id => params[:id_facebook])\n\t\t\t\t@favourites = Favourite.where(\"user_id = #{@user.id}\")\n\t\t\tend",
"def favorited?(wallpaper)\n self.favorites.find_by_wallpaper_id(wallpaper.id)\n end",
"def show\n @favorite = current_user.favorites.find_by(recipe_id: @recipe.id)\n end",
"def user_favorite_wrestlers\n FavoriteWrestler.all.select do |fav|\n fav.user == self \n end \n end",
"def already_favourite?(user_id, place_id)\n not where(:user_id => user_id, :place_id => place_id).empty?\n end",
"def favorited?(test_image)\n favorites.where(image_id: test_image.id).any?\n end",
"def toggle_favorite\n return if current_user.nil?\n\n if current_user.favorite?(params[:university_id])\n current_user.remove_favorite(params[:university_id])\n else\n current_user.add_favorite(params[:university_id])\n end\n\n flash[:success] = 'Favorites list updated!'\n redirect_to request.referer || root_url\n end",
"def index\n if user_signed_in?\n @favorites = current_user.favorites\n\n end\n end",
"def favorite?(movie)\n favorite = favorites.find_by(movie_id: movie.id)\n if favorite.nil?\n return false\n else\n return true\n end\n #favorites.include?(movie)\n end",
"def has_favourite_recipe?(user_id, yummly_id)\n return self.user_favourite_recipes.has_user_favourites_for_recipe?(user_id, yummly_id)\n end",
"def favoriter?\n true\n end",
"def has_favourite_shop?(shop_id)\n return self.user_favourite_shops.find_by(shop_id: shop_id)\n end",
"def favorites\n if params[:id]\n if params[:id].to_i.to_s == params[:id]\n\t@user = User.find(params[:id])\n else\n\t@user = User.find(:first, :conditions => [\"username=?\", params[:id]])\n end\n else\n @user = @current_user\n end\n\n @beu = @user.following_by_type('Beu')\n end",
"def user_favorite\r\n\t\t\tif params[:is_add] == '1'\r\n\t\t\t\trender json: UsersFavoriteProject.add_favorite(params[:id])\r\n\t\t\telse\r\n\t\t\t\trender json: UsersFavoriteProject.remove_favorite(params[:id])\r\n\t\t\tend\r\n\t\tend",
"def favorite\n type = params[:type] # get the type from the url (fav/unfav)\n ass = params[:controller] # get the current controller name\n clazz = params[:controller].classify.constantize # get the controllers class in with big upper letter\n obj = clazz.find_by tiss_id: params[:tiss_id] # find the object with the tiss_id\n obj = clazz.create tiss_id: params[:tiss_id] if obj.nil? # create if not exists\n alreadyfav = current_user.send(ass).exists?(obj.id) # is it already fav?\n if type == 'favorite' && !alreadyfav # if not already fav and we want to fav\n current_user.send(ass) << obj # fav it\n flash[:success] = \"Favorite successful\" # success msg\n elsif type == 'unfavorite' && alreadyfav # else\n current_user.send(ass).delete(obj) # unfav\n flash[:success] = \"Unfavorite successful\" # success msg\n else\n flash[:danger] = \"Nothing happened\" # nothing happened msg\n end\n redirect_back fallback_location: root_path # return\n end",
"def has_faved?(favable)\n if favable.is_a?(Journal)\n return favorites.journals.pluck(:favable_id).include?(favable.id)\n elsif favable.is_a?(Submission)\n return favorites.submissions.pluck(:favable_id).include?(favable.id)\n elsif favable.is_a?(Stream)\n return favorites.streams.pluck(:favable_id).include?(favable.id)\n end\n end",
"def list_favourites(user_id)\n @favourites_store.where(user_id)\n end",
"def has_favorited(link_id)\n return self.favorites.include? link_id\n end",
"def is_favoritable?\n true\n end",
"def check_favorite username, password, slideshow_id\n do_request 'check_favorite', username: username, password: password, slideshow_id: slideshow_id\n end",
"def favourite\n if session[:user_id] == nil\n render json: {code: 401}\n else\n url_id = params[:id]\n url = Url.find_by(id: url_id)\n current_user = User.find_by(id: session[:user_id])\n if current_user.urls.exists?(url_id)\n current_user.urls.delete(url)\n favourite = false\n else\n current_user.urls << url\n favourite = true\n end\n users = url.users\n render json: {code: 200, favourite: favourite, users: users}\n end\n end",
"def users_favorite?(naming, user)\n lookup_naming(naming).users_favorite?(user)\n end",
"def index\n # @favorites = Favorite.all\n if user_signed_in?\n @favorites = current_user.favorites\n else\n redirect_to new_user_session_path\n end\n end",
"def favourite_action (thing, current_user)\n if thing.favourited_by_user?(current_user.id)\n unless (f = thing.favourite_by_user(current_user)).nil?\n (link_to image_tag(icon_filename_for(:favourite)) + content_tag(\n :span, \" Unfavourite\"),\n favourite_path(f),\n :method => :delete,\n :style => \"text-decoration:none\")\n\n end\n else\n link_to image_tag(icon_filename_for(:favourite)) + content_tag(\n :span, \" Favourite\"),\n favourites_url(:favouritable_type => thing.class.name, :favouritable_id => thing.id),\n :method => :post,\n :style => \"text-decoration:none\"\n end\n end",
"def favorited\r\n Favorite.find(:all, :conditions => {:favorable_type => self.class.to_s, :favorable_id => self.id})\r\n end",
"def favourite\n if Favourite.where(user_id: current_user.id, link_id: @link.id).present?\n @favourite = Favourite.where(user_id: current_user.id, link_id: @link.id)\n @favourite.first.delete\n else\n @favourite = @link.favourites.new(user: current_user)\n @favourite.save\n end \n end",
"def owners_favorite?(naming)\n lookup_naming(naming).users_favorite?(user)\n end",
"def view_favorites\n #current_user will call favorites method to see the list of favorites table in database\n favorite_array = Favorite.where(user_id:current_user.id)\n \n favorite_array.each do |favorite|\n puts Brewery.find(favorite.brewery_id).name\n puts Brewery.find(favorite.brewery_id).street\n puts Brewery.find(favorite.brewery_id).city\n puts Brewery.find(favorite.brewery_id).state\n end \n # current_user.favorites\n end",
"def index\n @favorites = user.favorites\n end",
"def toggle_favorite\n if user_signed_in?\n \t@user = current_user\n \t\n \t# toggle. so, if it's there, remove it\n \tif @user.favorite_listings.include?(params[:listing_id]) then\n \t\t\t@user.favorite_listings.delete(params[:listing_id])\n \t\t\tmessage = 'removed'\n \t\telse\n \t\t\t# else, we'll add it\n \t\t\t@user.favorite_listings << params[:listing_id] unless @user.favorite_listings.include?(params[:listing_id])\n \t\t\tmessage = 'added'\t\t\n \t\tend\n \t\t\n \t\t@user.save\n \tend\n\t\n\trender :text => message\n \n end",
"def show\n @stock = Stock.find(params[:id])\n @buyers = @stock.buyers\n if current_user\n @current_favorite = current_user.favorites.find_by(stock_id: @stock.id)\n end\n end",
"def favoring?(article)\n favorites.include?(article)\n end",
"def show\n @favoritepizza = Favoritepizza.new\n if not (current_user.nil?)\n @favoritepizza.user = current_user\n end\n end",
"def favorited_tweet?(tweet)\n favorite_tweets.include? tweet\n end",
"def favorited? subject\n has_event? 'favorite', subject\n end",
"def favor\n favorites_count = 0\n ActiveRecord::Base.transaction do\n if params[:cancel]\n # cancel favorite\n favorites_count = Favorite.delete(params[:article_id], current_user.id)\n logger.info \"ユーザ #{current_user.id} が記事 #{params[:article_id]} に対するブックマークをキャンセルしました。\"\n else\n # commit favorite\n favorites_count = Favorite.add(params[:article_id], current_user.id)\n logger.info \"ユーザ #{current_user.id} が記事 #{params[:article_id]} に対してブックマークしました。\"\n end\n respond_to do |format|\n # toggle favorite button\n format.js { render locals: { article: Article.find(params[:article_id]) } }\n end\n end\n end",
"def set_favorite\n file = session[:user].x_files.get(params[:id])\n file = session[:user].x_files_shared_to_me.get(params[:id]) unless file\n raise RequestError.new(:file_not_found, \"File not found\") unless file\n raise RequestError.new(:bad_param, \"File not uploaded\") if !file.folder && !file.uploaded\n raise RequestError.new(:bad_param, \"Can not set the root folder as favorite\") if file.id == session[:user].root_folder.id\n\n if params[:favorite] == \"true\" then \n file.favorite_users << session[:user]\n elsif params[:favorite] == \"false\" then\n file.favorite_users.delete session[:user]\n end\n \n file.save\n @result = { file: file.description(session[:user]), success: true }\n end",
"def remove_favorite\n\t remove_favorite_of User.current_user\n\tend",
"def create\n @favorite = user.favorites.new(favorite_params)\n\n if @favorite.save\n render :show, status: :ok\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def favorite\n\t\t@venues = []\n\n\t\tuser = User.find(current_user.id)\n\t\tuser_fav = user.favorite_venue_ids\n\t\t\tuser_fav.each do |venue_id|\n\t\t\t\tvenue = Venue.find(venue_id)\n\t\t\t\t@venues << venue\n\t\t\tend\n\n\tend",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id]) \n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end",
"def favorite\n\t\tclient = Client.find(params[:client_id])\n\t\tfavorite = Favorite.new(client_id: params[:client_id])\n\t\tcurrent_user.customer.favorites ||= []\n\t\tcurrent_user.customer.favorites << favorite\n\t\tredirect_to root_path, notice: \"Company added to favorites\"\n\tend",
"def toggle_fav\n @property = Property.find(params[:id])\n current_usertemp.favorited?(@property) ? current_usertemp.unfavorite(@property) : current_usertemp.favorite(@property)\n end",
"def favorite\n \t\t\tbyebug\n \ttype = params[:type]\n \t@recipe = current_user.recipes.find(params[:id])\n \tif type == \"favorite\"\n \t\tif FavoriteRecipe.where(:recipe_id => @recipe.id).present?\n\t\t\t\tredirect_to recipe_path(@recipe), notice: \"Already favorited #{@recipe.name}\"\n \t\telse\n \t\t\tcurrent_user.favorites << @recipe\n \t\t\tredirect_to recipe_path(@recipe), notice: \"You favorited #{@recipe.name}\"\n \t\tend\n \t\t#redirect_to :back, notice: 'You favorited #{@recipe.name}'\n\n \telsif type == \"unfavorite\"\n \t\tcurrent_user.favorites.delete(@recipe)\n \t\tredirect_to recipe_path(@recipe), notice: \"You Unfavorited #{@recipe.name}\"\n \t\t#redirect_to :back, notice: 'Unfavorited #{@recipe.name}'\n\n \telse\n \t# Type missing, nothing happens\n \t\tredirect_to recipe_path(@recipe), notice: \"Issue with favorite!\"\n \tend\n \t\tend",
"def city_not_in_favorite?(user_name, city_name)\n user = User.find_by(name: user_name.downcase)\n user_id = user.id\n real_city_name = return_city_name(city_name)\n city = City.find_by(name: real_city_name)\n city_id = city.id\n favorite = Favorite.where(user_id: user_id, city_id: city_id)\n favorite == []\n end",
"def favorite\n current_user.favorite_topic(@topic.id)\n render json: {ok: 1}\n end",
"def favor\n is_supporter = @post.has_supporter? @p\n is_opponent = @post.has_opponent? @p\n if is_supporter\n #flash[:notice] = 'You have supported this post already.' \n favor_response false\n else \n if is_opponent\n @favor = @post.unfavors.find(:first, :conditions => {:owner_id => @p})\n @post.decrement!(:unfavor_count)\n else\n @favor = Favor.create(:post_id => @post.id, :owner_id => @p.id, :liked => true)\n end\n @post.increment!(:favor_count)\n favor_response @favor.update_attribute(:liked, true)\n end\n end",
"def create\n #I have the quote id from params and I have the @user instamce\n already_there = Favorite.find_by(user:@user,quote_id:params[:id])\n if already_there\n render json: {error_message:\"You already have this quote in your favorites\"}\n else\n new_favorite = Favorite.create(user:@user,quote_id:params[:id])\n render json: new_favorite\n end\n end",
"def favorite\n authorize @shelter\n current_user.favorite_shelter(@shelter)\n\n redirect_to shelter_path(@shelter)\n end",
"def delete_favourite\n Favorite.find(:first, :conditions => [\"user_id =? AND favorable_id =?\", session[:user_id], params[:id]]).destroy\n flash[:notice] = \"Favourite removed\"\n redirect_to(:action => 'index')\n end",
"def favorited(stack)\n self.favorites.where(stack_id: stack.id).first\n end",
"def show\n @snippet.snippet_content = CodeRay.scan(@snippet.snippet_content, :ruby).div(:line_numbers => :table)\n\n @snippetuser = User.find_by(email: session[:current_user_email])\n @hasFavorite = @snippetuser.favorites.find_by(snippet_id: @snippet.id)\n puts \"Getting user favorite\"\n puts @hasFavorite.blank?\n end",
"def show\n @listing = Listing.find(params[:id])\n @favorite = current_user.favorites.find_by_listing_id(params[:id])\n if @favorite != nil\n @favorite.mark_read\n end\n render :layout => false\n end",
"def add_to_favorites\n \tif user_signed_in?\n \t\t@user = current_user\n \t\t@user.favorite_listings << params[:listing_id] unless @user.favorite_listings.include?(params[:listing_id])\n \t\t@user.save\n \t\t\n \t\trender :nothing => true\n \tend\n end"
] |
[
"0.8453774",
"0.82673335",
"0.8195808",
"0.81470245",
"0.8144753",
"0.81447154",
"0.80925196",
"0.80844986",
"0.8079686",
"0.80769765",
"0.80205786",
"0.7855721",
"0.78540003",
"0.78469074",
"0.78279215",
"0.77443",
"0.7705194",
"0.7701029",
"0.76561046",
"0.7635864",
"0.76068807",
"0.7506293",
"0.7477812",
"0.7477812",
"0.7466364",
"0.74466574",
"0.74361277",
"0.73699826",
"0.73393565",
"0.7323463",
"0.73132557",
"0.7305113",
"0.7295275",
"0.72703",
"0.7220179",
"0.7215886",
"0.719465",
"0.71805346",
"0.7170848",
"0.7163509",
"0.7136069",
"0.7128126",
"0.71122265",
"0.7072573",
"0.7054324",
"0.70158696",
"0.70095724",
"0.69948334",
"0.6982264",
"0.6959909",
"0.69411397",
"0.69145566",
"0.6912374",
"0.69066066",
"0.68680674",
"0.68632865",
"0.6861639",
"0.68526185",
"0.68400955",
"0.6830581",
"0.68047893",
"0.68029404",
"0.66872275",
"0.6674824",
"0.6665428",
"0.66623867",
"0.6642359",
"0.6635926",
"0.66312104",
"0.66272557",
"0.66250366",
"0.66214824",
"0.6616533",
"0.661163",
"0.6608605",
"0.66042",
"0.6594154",
"0.6594154",
"0.6594154",
"0.6594154",
"0.6594154",
"0.6594154",
"0.6591042",
"0.6590056",
"0.658887",
"0.658887",
"0.6581421",
"0.6569579",
"0.6562998",
"0.656084",
"0.65522563",
"0.654123",
"0.6533912",
"0.6529928",
"0.65212286",
"0.65135676",
"0.6485902",
"0.64855325",
"0.64842904",
"0.6475993"
] |
0.66795194
|
63
|
Reduce the land mass images generated from the Google Map tiles into tiles comprising of the square 2x2 of the parent tile. For example, 4 tiles from zoom level 2 will be used to create one tile at zoom level 1 This script assumes that all tiles at the maximum zoom level exist Option hash :limit_to => allows maximum number of tiles to be processed. Default process all tiles :overwrite => overwrite existing images by setting this to any value
|
def start(*options)
limit_to = options[0][:limit_to].to_s if ( (options.length > 0) && (options[0].instance_of?(Hash)) )
overwrite = options[0].keys.include?(:overwrite) if ( (options.length > 0) && (options[0].instance_of?(Hash)) )
update_log_every = 100
tiles_processed = 0
tiles_limit = limit_to && limit_to.match(/^\d+$/) ? limit_to.to_i : nil
get_tiles.each do |tile|
tiles_processed += 1 if build_reduced_land_mass_image(tile.x, tile.y, tile.zoom, tile.accuracy_pixels, overwrite)
SLogger.info("Update, processed #{update_log_every} items") if (tiles_processed % update_log_every == update_log_every-1)
break if (!tiles_limit.nil? && tiles_limit <= tiles_processed)
end
SLogger.info("\nDone. Processed #{tiles_processed} tiles. ")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def build_reduced_land_mass_image(x, y, zoom, accuracy_pixels, overwrite = false)\n land_mass_tile_path = LandMassTile.tile_path(x, y, zoom, accuracy_pixels)\n \n # exit if file already exists\n return false if (!overwrite && File.exists?(land_mass_tile_path))\n \n begin\n # build up square of 4 children tiles\n child_tiles = (0..1).map { |this_x| (0..1).map { |this_y| OpenStruct.new(:x => this_x+x*2, :offset_x => this_x, :y => this_y+y*2, :offset_y => this_y, :zoom => zoom+1) } }.flatten(1)\n \n reduce_tiles = child_tiles.select do |tile| \n tile.accuracy_pixels = accuracy_pixels \n tile.path = LandMassTile.tile_path(tile.x, tile.y, tile.zoom, tile.accuracy_pixels)\n tile.exists = File.exists?(tile.path)\n tile.img = Magick::Image.read(tile.path).first if tile.exists\n tile.exists # remove image if tile does not exist\n end\n \n stitch_tiles = child_tiles.select do |tile| \n tile.accuracy_pixels = accuracy_pixels * 2\n tile.path = LandMassTile.tile_path(tile.x, tile.y, tile.zoom, tile.accuracy_pixels)\n tile.exists = File.exists?(tile.path)\n tile.img = Magick::Image.read(tile.path).first if tile.exists\n tile.exists # remove image if tile does not exist\n end unless reduce_tiles.length == 4\n \n if (reduce_tiles.length == 4)\n # We are building a land mass tile from children with the same number of pixels in the tile\n # which means we need to \"squeeze\" 4 tiles into 1\n new_tile = Magick::Image.new(AppConfig.gmap_tile_size / accuracy_pixels * 2, AppConfig.gmap_tile_size / accuracy_pixels * 2) do\n self.background_color = \"transparent\"\n end\n \n child_tile_size = new_tile.columns / 2\n reduce_tiles.each do |tile|\n raise \"Tile#{tile.path} is incorrectly #{tile.img.columns} wide / high\" if ( (tile.img.columns != child_tile_size) || (tile.img.rows != child_tile_size) ) \n pixels = tile.img.export_pixels(0, 0, tile.img.columns, tile.img.rows, \"RGBA\")\n new_tile.import_pixels(tile.offset_x * child_tile_size, tile.offset_y * child_tile_size, tile.img.columns, tile.img.rows, \"RGBA\", pixels)\n end\n \n # now resize down to single tile size\n reduced_tile = new_tile.resize(AppConfig.gmap_tile_size / accuracy_pixels, AppConfig.gmap_tile_size / accuracy_pixels)\n \n reduced_tile.write land_mass_tile_path\n elsif (stitch_tiles.length == 4)\n # We are building a land mass tile from children with a lower accuracy level i.e. we need to \n # build up this tile by stitching 4 children tiles together\n \n new_tile = Magick::Image.new(AppConfig.gmap_tile_size / accuracy_pixels, AppConfig.gmap_tile_size / accuracy_pixels) do\n self.background_color = \"transparent\"\n end\n \n child_tile_size = new_tile.columns / 2\n stitch_tiles.each do |tile|\n raise \"Tile#{tile.path} is incorrectly #{tile.img.columns} wide / high\" if ( (tile.img.columns != child_tile_size) || (tile.img.rows != child_tile_size) ) \n pixels = tile.img.export_pixels(0, 0, tile.img.columns, tile.img.rows, \"RGBA\")\n new_tile.import_pixels(tile.offset_x * child_tile_size, tile.offset_y * child_tile_size, tile.img.columns, tile.img.rows, \"RGBA\", pixels)\n end\n \n new_tile.write land_mass_tile_path\n else\n reduce_tiles_info = reduce_tiles.map{|c| \"#{c.x}:#{c.y} zm #{c.zoom}\" }.join(',')\n stitch_tiles_info = stitch_tiles.map{|c| \"#{c.x}:#{c.y} zm #{c.zoom}\" }.join(',')\n SLogger.warn(\"Could not reduce land mass image for position as not all children tiles exist. Tile #{x}:#{y} (zoom #{zoom}). Reduce tiles: #{reduce_tiles_info}. Stitch tiles: #{stitch_tiles_info}\")\n false\n end\n \n rescue Exception => e\n SLogger.warn(\"Could not save reduced land mass image for position #{x}:#{y} (zoom #{zoom}). Error '#{e.message}'\")\n false\n end\n end",
"def get_tiles\n tiles = []\n accuracy_pixels_config = AppConfig.gmap_accuracy\n (0...AppConfig.gmap_max_zoom).reverse_each do |zoom|\n tiles_across = 2**zoom\n # the accuracy will go down by half at each zoom level with a floor of 1 i.e. 8 => 4, 7 => 2, 6 => 1, 5 => 1, 4 => 1\n accuracy_pixels = (accuracy_pixels_config.to_f / 2**(AppConfig.gmap_max_zoom - zoom).to_f ).ceil\n tiles_at_zoom = (0...tiles_across).map { |x| (0...tiles_across).map { |y| OpenStruct.new(:x => x, :y => y, :zoom => zoom, :accuracy_pixels => accuracy_pixels) } }.flatten(1)\n tiles.concat tiles_at_zoom\n end\n tiles\n end",
"def split_tile_set_into_tiles\n number_of_tiles = @tile_set[0].columns/32\n\n number_of_tiles.times do |i|\n image = @tile_set[0].crop((i*32), 0, 32, 32)\n image.write(\"media/tmp/tile#{i}.png\")\n end\n end",
"def slice!(&block)\n if ! @overwrite && File.directory?(@destination) && ! Dir[\"@{@destination}/*\"].empty?\n raise \"Output directory #{@destination} already exists!\"\n @overwrite ? Rails.logger.warn(msg) : raise(msg)\n end\n\n image = @tile_source.dup\n orig_width, orig_height = image.columns, image.rows\n\n # iterate over all levels (= zoom stages)\n max_level(orig_width, orig_height).downto(0) do |level|\n width, height = image.columns, image.rows\n\n current_level_dir = File.join(@destination, level.to_s)\n FileUtils.mkdir_p(current_level_dir)\n\n if block_given?\n yield current_level_dir\n end\n\n # iterate over columns\n x, col_count = 0, 0\n while x < width\n # iterate over rows\n y, row_count = 0, 0\n while y < height\n dest_path = File.join(current_level_dir, \"#{col_count}_#{row_count}.#{@tile_format}\")\n tile_width, tile_height = tile_dimensions(x, y, @tile_size, @tile_overlap)\n\n save_cropped_image(image, dest_path, x, y, tile_width, tile_height, @tile_quality)\n\n y += (tile_height - (2 * @tile_overlap))\n row_count += 1\n end\n x += (tile_width - (2 * @tile_overlap))\n col_count += 1\n end\n\n image.resize!(0.5)\n end\n\n image.destroy!\n end",
"def make_tiles(image_source, opts={})\n\n\t\t# initializing and setting options and stuff\n\t\timage = get_image(image_source)\n\t\topts.each_pair do |key,value|\n instance_variable_set \"@#{key}\", value\n end\n\n\t\tif @autocreate_dirs\n\t\t\tcreate_dir(output_dir)\n\t\tend\n\n\t\t# pad image with background color so image is square\n\t\timage_sq = pad_image(image)\n\t\timage_length = image_sq.columns\n\n\t\t# the actual tiling part!\n\t\tzoom_levels.each do |zoom|\n\t\t\t# get the number of tiles in each column and row\n\t\t\tfactor = 2 ** zoom\n\n\t\t\t# get length of tiles for current zoom\n\t\t\ttile_length = image_length / factor\n\n\t\t\t0.upto(factor-1) do |col|\n\t\t\t\t0.upto(factor-1) do |row|\n\n\t\t\t\t\tputs \"Cutting tiles for zoom level #{zoom}\"\n\n\t\t\t\t\t# cut tile\n\t\t\t\t\t# Image.crop(x,y,width,height,toss offset information)\n\t\t\t\t\ttile = image_sq.crop(col*tile_length, row*tile_length,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t tile_length, tile_length, true)\n\t\t\t\t\ttile.resize!(TILE_SIZE,TILE_SIZE)\n\n\t\t\t\t\t# output tile\n\t\t\t\t\tfilename = File.join(@output_dir, \"#{prefix}_#{zoom}_#{col}_#{row}.#{@format}\")\n\t\t\t\t\ttile.write(filename)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def _minimap_autotile\n b = Bitmap.new(24, 32)\n c1 = Color.new(191, 191, 191)\n c2 = Color.new(255, 255, 255)\n b.fill_rect(2, 0, 4, 1, c2)\n b.set_pixel(1, 1, c2)\n b.fill_rect(2, 1, 4, 6, c1)\n b.set_pixel(6, 1, c2)\n b.fill_rect(0, 2, 1, 4, c2)\n b.fill_rect(1, 2, 1, 4, c1)\n b.fill_rect(6, 2, 1, 4, c1)\n b.fill_rect(7, 2, 1, 4, c2)\n b.set_pixel(1, 6, c2)\n b.set_pixel(6, 6, c2)\n b.fill_rect(2, 7, 4, 1, c2)\n b.fill_rect(7, 8, 10, 1, c2)\n b.set_pixel(6, 9, c2)\n b.fill_rect(7, 9, 10, 22, c1)\n b.set_pixel(17, 9, c2)\n b.set_pixel(5, 10, c2)\n b.fill_rect(6, 10, 1, 20, c1)\n b.fill_rect(17, 10, 1, 20, c1)\n b.set_pixel(18, 10, c2)\n b.set_pixel(4, 11, c2)\n b.fill_rect(5, 11, 1, 18, c1)\n b.fill_rect(18, 11, 1, 18, c1)\n b.set_pixel(19, 11, c2)\n b.set_pixel(3, 12, c2)\n b.fill_rect(4, 12, 1, 16, c1)\n b.fill_rect(19, 12, 1, 16, c1)\n b.set_pixel(20, 12, c2)\n b.set_pixel(2, 13, c2)\n b.fill_rect(3, 13, 1, 14, c1)\n b.fill_rect(20, 13, 1, 14, c1)\n b.set_pixel(21, 13, c2)\n b.set_pixel(1, 14, c2)\n b.fill_rect(2, 14, 1, 12, c1)\n b.fill_rect(21, 14, 1, 12, c1)\n b.set_pixel(22, 14, c2)\n b.fill_rect(0, 15, 1, 10, c2)\n b.fill_rect(1, 15, 1, 10, c1)\n b.fill_rect(22, 15, 1, 10, c1)\n b.fill_rect(23, 15, 1, 10, c2)\n b.set_pixel(1, 25, c2)\n b.set_pixel(22, 25, c2)\n b.set_pixel(2, 26, c2)\n b.set_pixel(21, 26, c2)\n b.set_pixel(3, 27, c2)\n b.set_pixel(20, 27, c2)\n b.set_pixel(4, 28, c2)\n b.set_pixel(19, 28, c2)\n b.set_pixel(5, 29, c2)\n b.set_pixel(18, 29, c2)\n b.set_pixel(6, 30, c2)\n b.set_pixel(17, 30, c2)\n b.fill_rect(7, 31, 10, 1, c2)\n return b\n end",
"def max_tile_dimensions\n lambda do |projection|\n projection.explicit_tile_dimensions(max_size(projection))\n end\n end",
"def init_tiles\n # Determine how many frames of animation this autotile has\n for i in 0..6\n bm = @autotiles[i]\n if bm.nil?\n @total_frames = 1\n elsif bm.height > 32\n @total_frames[i] = bm.width / 256\n else\n @total_frames[i] = bm.width / 32\n end\n @current_frame[i] = 0\n end\n # Turn on flag that the tilemap sprites have been initialized\n @tilemap_drawn = true\n \n @animating_tiles.clear\n # Create a sprite and viewport to use for each priority level.\n (0...((SCREEN[0]/32+2) * (SCREEN[1]/32+2))*3).each{|i|\n @tile_sprites[i/3] = [] if @tile_sprites[i/3].nil?\n @tile_sprites[i/3][i%3] = Sprite.new(@viewport) unless @tile_sprites[i/3][i%3].is_a?(Sprite)\n # Rename to something shorter and easier to work with for below\n tile = @tile_sprites[i/3][i%3]\n # Assign tile's respective ID value\n tile.tile_sprite_id = i\n # Draw sprite at index location (ex. ID 0 should always be the top-left sprite)\n tile.x = (i % ((SCREEN[0]/32+2)*3) / 3 * 32) - 32 + (@ox % 32)\n tile.y = (i / ((SCREEN[0]/32+2)*3) * 32) - 32 + (@oy % 32)\n\n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n @corner_tile_loc = [map_x, map_y] if i == 0\n # If the tile happens to be drawn along the outside borders of the map\n if map_x < 0 || map_x >= $game_map.width || map_y < 0 || map_y >= $game_map.height\n tile.z = 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n else # Tile is actually on the map\n tile_id = @map_data[map_x,map_y,i%3]\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = tile.y + @priorities[tile_id] * 32 + 32\n end\n # No tile exists here\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')#@tileset\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384 # non-autotile\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)\n else # autotile\n tile.bitmap = @autotiles[tile_id/48-1]\n tile.src_rect.set(((tile_id % 48) % 8)*32,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[i] = tile if tile.bitmap.width > 256\n end\n end\n }\n # Sprite ID located at top left corner (ranges from 0..map_width * map_height\n @corner_index = 0\n end",
"def generate_images width=500, height=350\n # Base image with all territories shaded\n canvas = Magick::Image.new(width, height, Magick::TextureFill.new(@@map_bg))\n canvas.format = 'jpg'\n gc = Magick::Draw.new\n Territory.all.each do |t|\n gc.fill(\"transparent\")\n if t.clan\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(0.25)\n end\n gc.stroke('rgb(64, 0, 0)')\n gc.stroke_width(1)\n if t.shape # uses svg-like shapes\n s = t.shape.split(',')\n path = \"M #{s[0]} #{s[1]} \"\n s[2..-1].each_slice(2) do |p|\n path << \"L #{p[0]} #{p[1]} \"\n end\n path << \"z\"\n gc.path(path)\n end\n\n if t.clan\n # draw the small icon for the clan if it exists\n if t.clan.image_filename 16\n gc.composite(t.position_x - 8, t.position_y - 8, 16, 16,\n Magick::Image.read(\"#{RAILS_ROOT}/public/images/#{t.clan.image_filename(16)}\").first)\n else # or draw a circle of their color\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(1);\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n else\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n end\n gc.draw(canvas)\n canvas.write(\"#{RAILS_ROOT}/public/images/map/base.jpg\"){ self.quality = 95 } # TODO tweak the quality\n\n true\n end",
"def zoom(factor = 5)\n upstream_slice = self.class.sketch.slices.select{|s| s.start_cumulative_bp < @start_cumulative_bp}.sort_by{|s| s.start_cumulative_bp}[-1]\n downstream_slice = self.class.sketch.slices.select{|s| s.start_cumulative_bp > @start_cumulative_bp}.sort_by{|s| s.start_cumulative_bp}[0]\n\n center_bp = (@start_cumulative_bp + @length_bp.to_f/2).round\n\n @length_bp = (@length_bp.to_f/factor).round\n @start_cumulative_bp = (center_bp - @length_bp.to_f/2).round\n @stop_cumulative_bp = (center_bp + @length_bp.to_f/2 - 1).round\n @resolution = @length_pixel.to_f/@length_bp\n self.fetch_sequence\n\n upstream_slice.stop_cumulative_bp = @start_cumulative_bp - 1\n downstream_slice.start_cumulative_bp = @stop_cumulative_bp + 1\n [upstream_slice, downstream_slice].each do |s|\n s.length_bp = s.stop_cumulative_bp - s.start_cumulative_bp + 1\n s.resolution = s.length_pixel.to_f/s.length_bp\n s.range_cumulative_bp = Range.new(s.start_cumulative_bp, s.stop_cumulative_bp)\n s.fetch_sequence\n end\n self.class.sketch.slices.each{|s| s.format_resolution}\n\n self.class.sketch.buffer_images[:zoomed] = self.class.sketch.draw_zoomed_buffer\n self.class.sketch.buffer_images[:information_panel] = self.class.sketch.draw_information_panel\n end",
"def load_tiles(zombie_setting)\n tiles = Gosu::Image.load_tiles(zombie_setting[\"image_tile_dir\"], 32, 32)\n tile_no = zombie_setting[\"tile_loc\"]\n \n start = (tile_no - 1) * 3\n\n @image_tiles = Array.new\n for x in 0..3 do\n for y in 0..2 do\n @image_tiles << tiles[start + y]\n end\n start +=12\n end \n end",
"def build_grid size\n self.tiles.clear\n size.to_i.times do |row|\n size.to_i.times do |column|\n self.tiles.build({\n x: column,\n y: row\n })\n end\n end\n end",
"def refresh_tiles\n return if empty?\n xdiff = @array[0].real_x.round / -32 - 1\n ydiff = @array[0].real_y.round / -32 - 1\n if ydiff > 0\n ydiff.times do\n move_up do |sprite|\n sprite.mapy += YSIZE\n sprite.real_y += 32 * YSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n elsif ydiff < 0\n ydiff.abs.times do\n move_down do |sprite|\n sprite.mapy -= YSIZE\n sprite.real_y -= 32 * YSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n end\n if xdiff > 0\n xdiff.times do\n move_left do |sprite|\n sprite.mapx += XSIZE\n sprite.real_x += 32 * XSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n elsif xdiff < 0\n xdiff.abs.times do\n move_right do |sprite|\n sprite.mapx -= XSIZE\n sprite.real_x -= 32 * XSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n temp_bitmaps = nil\n end\n end",
"def setup_region_tile_mapping\n @region_tile_mapping = {}\n (0..63).each {|i| @region_tile_mapping[i] = []}\n for x in 0..data.xsize\n for y in 0..data.ysize\n @region_tile_mapping[region_id(x, y)] << [x,y]\n end\n end\n end",
"def summon_areas(numbered_tile,size,all_areas=[[numbered_tile]],restricted_board)\n return all_areas.uniq if all_areas[0].count >= size\n new_areas = []\n all_areas.each do |area|\n area.each do |x,y|\n directions = MODIFIERS.map do |m|\n m_x = m[0] + x\n m_y = m[1] + y\n [m_x,m_y]\n end\n # Remove reached tile if outside of board\n directions.delete_if{|i,j| i < 0 || j < 0 || i > (@row_count-1) || j > (@col_count-1) || (restricted_board[i,j] != 0) }\n # directions.delete_if{|i,j| i < 0 || j < 0 || i > 9 || j > 9 }\n # Add each valid direction to the area\n directions.each do |a,b|\n next if area.include? [a,b]\n new_area = area + [[a,b]]\n (new_areas << new_area) if (@b_nl[a,b] == 0)\n end\n end\n end\n\n # recursive action\n summon_areas(numbered_tile,size,new_areas.uniq, restricted_board)\n end",
"def create_tilemap\n @tilemap = Tilemap.new(@viewport1)\n @tilemap2 = Tilemap.new(@viewport4)\n @tilemap.map_data = $game_map.data.clone\n @tilemap2.map_data = $game_map.data.clone\n result = []\n for i in 0..@tilemap2.map_data.xsize\n for j in 0..@tilemap2.map_data.ysize\n for k in 0..@tilemap2.map_data.zsize\n if ($game_map.region_id(i,j) - @etage) <= 1\n @tilemap2.map_data[i,j,k] = 0\n else\n unless Etage::MAP.include?($game_map.map_id)\n @tilemap2.map_data[i,j,k] = 0\n end\n end\n end\n end\n end\n load_tileset\n end",
"def import(root_path = Rails.root, folders = \"/public/\")\n map_file = File.open(\"#{root_path}#{folders}#{map_source}\", \"r\")\n map_array = map_file.readlines\n map_height = map_array.length\n layers_array = Array.new\n index = 0\n\n import_attributes(map_array)\n import_tileset(map_array)\n\n while index < map_height\n current_line = map_array[index].to_s.strip \n if assert_tag(\"layer\", current_line)\n default_values = [0,0,0,0,0,0]\n values = Map.extract_tag(\"layer\", current_line)\n (0...default_values.length).each do |i|\n unless values[i].nil?\n default_values[i] = values[i].to_i\n end\n end\n current_layer = extract_body(map_array[index...map_height],\"layer\")\n layer_string = \"\"\n current_layer.each do |line|\n layer_string = layer_string + line + \"-\"\n end\n is_scrolling = ((default_values[3] != 0 || default_values[4] != 0))\n new_layer = Layer.create(array: layer_string.chop, is_tile_layer: true, tileset_id: @tilesets[default_values[0]].id, is_static: (default_values[2] == 1), horizontal_speed: default_values[3], vertical_speed: default_values[4], is_tile_scroll: default_values[5], opacity: default_values[1], is_scrolling: is_scrolling )\n layers_array.push(new_layer)\n end\n\n if assert_tag(\"fill\", current_line)\n values = Map.extract_tag(\"fill\", current_line)\n new_layer = Layer.create(background_color: values[0], is_fill_layer: true, opacity: values[1].to_f)\n layers_array.push(new_layer)\n end\n\n if assert_tag(\"background_image\", current_line)\n values = Map.extract_tag(\"background_image\", current_line)\n new_layer = Layer.create(image: values[0], is_x_repeat: values[1], is_y_repeat: values[2], is_x_stretch: values[3], is_y_stretch: values[4], is_static: values[5])\n layers_array.push(new_layer)\n end\n index = index.next\n end\n return layers_array\n end",
"def display_tile_image\n generate_tile unless @i.nil?\n display_image = @i.scale(8.0)\n display_image.display\n end",
"def main\n\n\tOptionParser.accept(Range, /(\\d+)\\.\\.(\\d+)/) do |range,start,finish|\n\t\tRange.new(start.to_i,finish.to_i)\n\tend\n\n\tOptionParser.accept(Magick::Pixel,/(\\d+),(\\d+),(\\d+),(\\d+)/) do |pixel, r,g,b,a|\n\t\tMagick::Pixel.new(r.to_f,g.to_f,b.to_f,a.to_f)\n\tend\n\n\toptions = {}\n\n\topts = OptionParser.new do |opts|\n\t\topts.banner = \"Image Tiler for Google Maps\\nUsage: tile_image.rb [options] IMAGE_FILE \\nExample: tile_image.rb -o ./tiles -z 11..12 -p 602,768,11,78,112,1.91827348 ./input_files/map.jpg\"\n\t\topts.separator \"\" \n\t\topts.on(\"-o\",\"--output OUTPUT_DIR\",\"Directory where the tiles will be created\") do |dir| \n\t\t\toptions[:output_dir] = dir\n\t\tend\n\t\topts.on(\"-f\",\"--format FORMAT\",\"Image format in which to get the file (gif, jpeg, png...). Is jpg by default\") do |format|\n\t\t\toptions[:format] = format\n\t\tend\n\t\topts.on(\"-z\",\"--zoom_levels ZOOM_RANGE\",Range,\"Range of zoom values at which the tiles must be generated. Is 0..4 by default\") do |range|\n\t\t\toptions[:zoom_levels] = range\n\t\tend\n\t\topts.on(\"-b\",\"--background COLOR\",Magick::Pixel,\"Background color components. Is fully transparent par default\") do |bg|\n\t\t\toptions[:bg_color] = bg\n\t\tend\n\t\topts.on(\"-p\",\"--prefix PREFIX\",\"Prefix to file output. Is 'tile' by default\") do |prefix|\n\t\t\toptions[:prefix] = prefix\n\t\tend\n\t\topts.on_tail(\"-h\", \"--help\", \"Show this message\") do\n\t\t\tputs opts\n\t\t\texit\n\t\tend\n\tend\n\n\topts.parse!(ARGV)\n\n\t#test the presence of all the options and exit with an error message\n\terror = []\n\terror << \"No output directory defined (-o,--output)\" if options[:output_dir].nil?\n\terror << \"No input files defined\" if ARGV.empty?\n\n\tunless error.empty?\n\t\tputs error * \"\\n\" + \"\\n\\n\"\n\t\tputs opts\n\t\texit\n\tend\n\n\tt = Tiler.new\n\tt.make_tiles(ARGV[0], options) # ignore all input files but first\n\nend",
"def all_tiles\n\t\t@entities.sort!\n\t\t\n\t\tall_tiles = @map_tiles + @entities\n\t\tall_tiles\n\tend",
"def tile_bounds\n tile = tile_number\n zoom = zoom_level\n sw = ::GeoMonitor::LatLngPoint.from_number(tile[:x], tile[:y], zoom).to_3857\n ne = ::GeoMonitor::LatLngPoint.from_number(tile[:x] + 1, tile[:y] - 1, zoom).to_3857\n self.class.new(\n north: ne.lat,\n east: ne.lng,\n south: sw.lat,\n west: sw.lng\n )\n end",
"def meters_to_tile(mx, my, zoom)\n px, py = meters_to_pixels(mx, my, zoom)\n pixels_to_tile(px, py)\n end",
"def create_tiles\n # Screen fits exactly 15x10 tiles (for 480x320), but it has a buffer around it\n # so the game has time to refresh without showing a black border during movement.\n tiles = []\n (TOTALSIZE).times { tiles << TileSprite.new($visuals.viewport) }\n @array = tiles\n startx = $visuals.map.real_x / -32 - 1\n starty = $visuals.map.real_y / -32 - 1\n for y in 0...YSIZE\n for x in 0...XSIZE\n mapx = startx + x\n mapy = starty + y\n idx = x + y * XSIZE\n @array[idx].real_x = $visuals.map.real_x + mapx * 32\n @array[idx].real_y = $visuals.map.real_y + mapy * 32\n draw_tile(@array[idx], mapx, mapy)\n end\n end\n $temp_bitmaps = nil\n # Don't dispose the bitmaps hash because tiles reference these instances; they're not clones.\n end",
"def create_background_image\n split_tile_set_into_tiles\n create_image_list\n\n montage_cmd = \"montage #{@image_list.join(' ')} \"\n montage_cmd += \"-tile #{@maps[:background][0].size}x \"\n montage_cmd += \"-geometry 32x32+0+0 media/grid_one/full_map_image.png\"\n\n system(\"#{montage_cmd}\")\n\n @background_image = Gosu::Image.new(@window,\n 'media/grid_one/full_map_image.png',\n false)\n\n FileUtils.rm_r Dir.glob('media/tmp/*')\n end",
"def draw_map game_map\r\n tiles = game_map.tiles # 2d array of the tiles set!\r\n wooden_plank_image = game_map.wooden_plank # image of the wooden plank \r\n i = 0\r\n j = 0\r\n unit_width = 20\r\n unit_height = 20\r\n\r\n # drawing the background image of the game map\r\n #game_map.background.draw(0,0,0) # 0: for x position, 0: for y position, 0: for ZOrder\r\n\r\n height = tiles.length\r\n width = tiles[0].length\r\n\r\n while i < height\r\n j = 0\r\n while j < width\r\n if(tiles[i][j]==1 || tiles[i][j]==3)\r\n x = j * unit_width\r\n y = i * unit_height\r\n draw_plank(x, y, wooden_plank_image)\r\n j+=4 # increment the value of the j by 4 to skip the next 4 blocks\r\n end\r\n j+=1\r\n end\r\n i+=1\r\n end\r\n\r\nend",
"def generate_map(tiles: [], objects: [], type: \"new\")\r\n case type\r\n when \"new\"\r\n tile_data = tiles.flatten.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join\r\n object_counts = \"\"\r\n object_data = \"\"\r\n OBJECTS.sort_by{ |id, entity| id }.each{ |id, entity|\r\n if ![7,9].include?(id) # ignore door switches for counting\r\n object_counts << objects.select{ |o| o[0] == id }.size.to_s(16).rjust(4,\"0\").scan(/../).reverse.map{ |b| [b].pack('H*')[0] }.join\r\n else\r\n object_counts << \"\\x00\\x00\"\r\n end\r\n if ![6,7,8,9].include?(id) # doors must once again be treated differently\r\n object_data << objects.select{ |o| o[0] == id }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }.join\r\n elsif [6,8].include?(id)\r\n doors = objects.select{ |o| o[0] == id }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }\r\n switches = objects.select{ |o| o[0] == id + 1 }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }\r\n object_data << doors.zip(switches).flatten.join\r\n end\r\n }\r\n map_data = tile_data + object_counts.ljust(80, \"\\x00\") + object_data\r\n when \"old\"\r\n header = \"00000000\"\r\n tile_data = tiles.flatten.map{ |t| t.to_s(16).rjust(2,\"0\").reverse }.join\r\n objs = objects.reject{ |o| !OBJECTS.key?(o[0]) }.map{ |o| o.dup }\r\n doors_exit = objs.select{ |o| o[0] == 3 }.zip(objs.select{ |o| o[0] == 4 }).map{ |p| [3, p[0][1], p[0][2], p[1][1], p[1][2]] }\r\n doors_lock = objs.select{ |o| o[0] == 6 }.zip(objs.select{ |o| o[0] == 7 }).map{ |p| [6, p[0][1], p[0][2], p[0][3], p[1][1], p[1][2]] }\r\n doors_trap = objs.select{ |o| o[0] == 8 }.zip(objs.select{ |o| o[0] == 9 }).map{ |p| [8, p[0][1], p[0][2], p[0][3], p[1][1], p[1][2]] }\r\n objs = objs.select{ |o| ![3,4,6,7,8,9].include?(o[0]) }.+(doors_exit).+(doors_lock).+(doors_trap).stable_sort_by{ |o| o[0] }\r\n entities = (0..25).to_a.map{ |id| [id, []] }.to_h\r\n objs.each{ |o|\r\n next if !entities.key?(OBJECTS[o[0]][:old])\r\n s = o[1..OBJECTS[o[0]][:att]].map{ |a| a.to_s(16).rjust(2, \"0\").reverse }.join\r\n entities[OBJECTS[o[0]][:old]].push(s)\r\n }\r\n object_data = entities.map{ |k, v| v.size.to_s(16).rjust(4, \"0\").scan(/../m).map(&:reverse).join + v.join }.join\r\n footer = \"00000000\"\r\n map_data = header + tile_data + object_data + footer\r\n else\r\n print(\"ERROR: Incorrect type (new, old).\")\r\n return 0\r\n end\r\n map_data\r\nend",
"def draw_tiles(num)\n if num <= tiles_remaining\n our_tiles = display_all_tiles.sample(num)\n tile_removal(our_tiles)\n return our_tiles\n else\n print \"Sorry, there are only #{tiles_remaining} left.\"\n our_tiles = display_all_tiles.sample(tiles_remaining)\n tile_removal(our_tiles)\n return our_tiles\n end\n end",
"def import_map_chunks\n puts 'Importing map chunks...'\n\n puts \"-> Identifying tiled maps...\"\n\n tiled_maps = Map.target(target).where(tiled: true).all\n\n tiled_maps.each do |map|\n next if map.chunks_loaded?\n\n puts \"-> Seeding chunks for map: #{map.name} (#{map.directory})\"\n\n map.tiles.extant.each do |tile|\n next if tile.chunks_loaded?\n\n tile_adt_path = \"#{map_path_for(map.directory)}/#{map.directory}_#{tile.tile_x}_#{tile.tile_y}.adt\"\n tile_adt_hash = file_hash(tile_adt_path)\n\n seed_map_tile_adt(map, tile, tile_adt_path)\n\n GC.start\n end\n end\n end",
"def initialize(width, height, tile_width, tile_height)\n @max_tile_x = width/tile_width\n @max_tile_y = height/tile_height\n @max_subgrid_x = (width/tile_width)*3\n @max_subgrid_y = (height/tile_height)*3\n @tiles = Array.new(max_tile_y) {|i| Array.new(max_tile_x)}\n end",
"def render_all_cuts gcode\n gcode.preamble :feed => @config[:cut_feed]\n @config[:repeat][1].times do |ytile|\n @config[:repeat][0].times do |xtile|\n render_cut gcode, x_inches(xtile, 0), y_inches(ytile, 0)\n end\n end\n gcode.epilogue\n end",
"def render_all_cuts gcode\n gcode.preamble :feed => @config[:cut_feed]\n @config[:repeat][1].times do |ytile|\n @config[:repeat][0].times do |xtile|\n render_cut gcode, x_inches(xtile, 0), y_inches(ytile, 0)\n end\n end\n gcode.epilogue\n end",
"def create_region_display_tilemap\n # Create Region Tileset\n Cache.create_region_tileset_bitmap \n # Create Region Tilemap\n @region_tilemap = Tilemap.new(@viewport1)\n @region_tilemap.map_data = $game_map.data.dup\n @region_tilemap.flags = Table.new(8192)\n # Make Region Tilemap Invisible\n @region_tilemap.visible = false\n # Set Region Tilemap Flags (Over Character [?])\n 64.upto(128) {|n| @region_tilemap.flags[n] = 0x10} \n # Go Through Game Map Tiles\n $game_map.data.xsize.times {|x|\n $game_map.data.ysize.times {|y|\n # Clear Region Tilemap Info\n 4.times {|z| @region_tilemap.map_data[x, y, z] = 0}\n # Get Region ID\n region_id = $game_map.region_id(x, y)\n # Get Passability Flags\n flag1 = $game_map.tileset.flags[$game_map.data[x, y, 2]] \n # If Region ID is 0 or more\n if region_id > 0\n next @region_tilemap.map_data[x, y, 2] = 64 + region_id if flag1 > 16 and flag1 & 0x10 != 0\n @region_tilemap.map_data[x, y, 2] = region_id \n else \n next @region_tilemap.map_data[x, y, 2] = 64 if flag1 > 16 and flag1 & 0x10 != 0\n next @region_tilemap.map_data[x, y, 1] = 64 \n end \n }\n }\n # Set Region Tilemap Bitmap (Tile B)\n @region_tilemap.bitmaps[5] = Cache.region_tileset_bitmap\n # Update Region Tilemap\n update_region_tilemap\n end",
"def generate_tile()\n @i = do_generate_tile(@i)\n end",
"def set_tiles\n if @game_state_model::game_type == :classic\n @tiles = @tilesClassic\n elsif @game_state_model::game_type == :otto\n @tiles = @tilesOtto\n end\n end",
"def generate_map(tiles: [], objects: [], type: \"new\")\n case type\n when \"new\"\n tile_data = tiles.flatten.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join\n object_counts = \"\"\n object_data = \"\"\n OBJECTS.sort_by{ |id, entity| id }.each{ |id, entity|\n if ![7,9].include?(id) # ignore door switches for counting\n object_counts << objects.select{ |o| o[0] == id }.size.to_s(16).rjust(4,\"0\").scan(/../).reverse.map{ |b| [b].pack('H*')[0] }.join\n else\n object_counts << \"\\x00\\x00\"\n end\n if ![6,7,8,9].include?(id) # doors must once again be treated differently\n object_data << objects.select{ |o| o[0] == id }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }.join\n elsif [6,8].include?(id)\n doors = objects.select{ |o| o[0] == id }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }\n switches = objects.select{ |o| o[0] == id + 1 }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }\n object_data << doors.zip(switches).flatten.join\n end\n }\n map_data = tile_data + object_counts.ljust(80, \"\\x00\") + object_data\n when \"old\"\n header = \"00000000\"\n tile_data = tiles.flatten.map{ |t| t.to_s(16).rjust(2,\"0\").reverse }.join\n objs = objects.map{ |o| o.dup }\n doors_exit = objs.select{ |o| o[0] == 3 }.zip(objs.select{ |o| o[0] == 4 }).map{ |p| [3, p[0][1], p[0][2], p[1][1], p[1][2]] }\n doors_lock = objs.select{ |o| o[0] == 6 }.zip(objs.select{ |o| o[0] == 7 }).map{ |p| [6, p[0][1], p[0][2], p[0][3], p[1][1], p[1][2]] }\n doors_trap = objs.select{ |o| o[0] == 8 }.zip(objs.select{ |o| o[0] == 9 }).map{ |p| [8, p[0][1], p[0][2], p[0][3], p[1][1], p[1][2]] }\n objs = objs.select{ |o| ![3,4,6,7,8,9].include?(o[0]) }.+(doors_exit).+(doors_lock).+(doors_trap).sort_by{ |o| o[0] }\n entities = (0..25).to_a.map{ |id| [id, []] }.to_h\n objs.each{ |o|\n s = o[1..OBJECTS[o[0]][:att]].map{ |a| a.to_s(16).rjust(2, \"0\").reverse }.join\n entities[OBJECTS[o[0]][:old]].push(s)\n }\n object_data = entities.map{ |k, v| v.size.to_s(16).rjust(4, \"0\").scan(/../m).map(&:reverse).join + v.join }.join\n footer = \"00000000\"\n map_data = header + tile_data + object_data + footer\n else\n print(\"ERROR: Incorrect type (new, old).\")\n return 0\n end\n map_data\nend",
"def resize_to_limit(new_width, new_height)\n manipulate! do |image|\n image = resize_image(image,new_width,new_height) if new_width < image.x_size || new_height < image.y_size\n image\n end\n end",
"def initialize_tiles\n return if @ready\n\n cur_y, cur_x = @progress.divmod @map.logical_width\n puts \"Game#initialize_tiles: #{@progress}/#{@finished_at} = #{(initialization_percent * 100).floor}%\"\n\n start_t = Time.now\n\n cur_y.upto(@map.logical_height - 1) do |y|\n cur_x.upto(@map.logical_width - 1) do |x|\n cur_tile = @tileset.sprite_for(@tileset.random_floor)\n\n # Let's give them a little color\n cur_tile.merge!(\n {\n r: rand(35) + 220 * (x / @map.logical_width),\n g: rand(35) + 220 * (y / @map.logical_height),\n b: rand(35) + 220 * (x / @map.logical_width) * (y / @map.logical_height)\n }\n )\n\n @map.add_tile(x, y, cur_tile)\n @progress += 1\n\n # Allow this to execute for 8ms (half a tick at 60fps).\n return if (Time.now - start_t) >= 0.008 # rubocop:disable Lint/NonLocalExitFromIterator\n end\n cur_x = 0\n end\n finish_initialization\n end",
"def generate_initial_map\n for _ in 0...@height\n temp = []\n for _ in 0...@width\n temp.push(@WALL)\n end\n @map.push(temp)\n end\n end",
"def do_mill\r\n # - - - - - - - - - - - - -\r\n mill.retract()\r\n target_depth = @depth\r\n print \"(polygon do_mill target_depth=\", target_depth, \" mill.cut_depth_inc_curr=\", mill.cut_depth_inc_curr, \")\\n\"\r\n if target_depth.abs <= mill.cut_depth_inc_curr.abs\r\n print \"(polygon do_mill single pass cut )\\n\"\r\n do_mill_s(target_depth)\r\n else\r\n # Need multiple passes\r\n print \"(polygon do_mill single pass cut )\\n\"\r\n tdepth = 0 - mill.cut_depth_inc_curr.abs\r\n print \"(polygon do_mill tdepth=\", tdepth, \")\\n\"\r\n while true\r\n print \"(L121: tdepth=\", tdepth, \")\\n\"\r\n do_mill_s(tdepth)\r\n if (tdepth == target_depth)\r\n break # have reached target depth\r\n end #if\r\n tdepth -= mill.cut_depth_inc_curr.abs\r\n if (tdepth.abs > target_depth.abs)\r\n # want to make sure final cut doesn't\r\n # go past tarteget.\r\n tdepth = target_depth\r\n end #if\r\n end #while\r\n end #else\r\n\r\n end",
"def tile_image(image, dpi)\n tilex = @field['tilex']*dpi\n tiley = @field['tiley']*dpi\n\n tiledImage = ImageList.new\n\n temp = image.scale(tilex, tiley)\n\n timesX = (@field['sizex'].to_f/@field['tilex']).ceil\n timesY = (@field['sizey'].to_f/@field['tiley']).ceil\n\n (1..timesX).each do |x|\n (1..timesY).each do |y|\n tiledImage << temp\n end\n end\n\n montage = tiledImage.montage() do |image|\n image.geometry = \"#{tilex}x#{tiley}+0+0\"\n image.background_color = 'transparent'\n image.tile = \"#{timesX}x#{timesY}\"\n end\n tiledImage.clear()\n\n return montage\n end",
"def measure map, x, y \n if map[x][y] != 'land' || x >= 6 || y >= 6 #Ensures water, counted land, and coordinates\n return 0 #off the grid aren't counted.\n end\n \n size = 1\n map[x][y] = 'counted land' #Marks the starting tile as something bedsides Land. Every tile surrounding the starting tile becomes the \"new starting tile\" as the the recursion happens.\n \n size = size + measure(map, x-1, y-1) #Each of these lines is run again and again until\n size = size + measure(map, x, y-1) #a non-land square is encountered. \n size = size + measure(map, x+1, y-1) #That's the recursive part.\n size = size + measure(map, x-1, y)\n size = size + measure(map, x+1, y)\n size = size + measure(map, x-1, y+1)\n size = size + measure(map, x, y+1)\n size = size + measure(map, x+1, y+1)\n \n size\nend",
"def big_merger(placed_sur_tiles, placed_tile)\n other_tiles = []\n hotel_name1 = placed_sur_tiles[0].hotel\n hotel_name2 = placed_sur_tiles[1].hotel\n hotel_name3 = placed_sur_tiles[2].hotel\n game_hotel1 = self.game_hotels.where(name: hotel_name1).first\n game_hotel2 = self.game_hotels.where(name: hotel_name2).first\n game_hotel3 = self.game_hotels.where(name: hotel_name3).first\n if (game_hotel1.chain_size >= game_hotel2.chain_size) && (game_hotel1.chain_size >= game_hotel3.chain_size)\n dominant_hotel = game_hotel1.hotel\n acquired_hotel1 = game_hotel2\n acquired_hotel2 = game_hotel3\n color = dominant_hotel.color\n c2 = game_hotel2.hotel.color\n c3 = game_hotel3.hotel.color\n game_tiles2 = self.game_tiles.where(hotel: hotel_name2)\n game_tiles2.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c2]\n other_tiles << temp\n end\n game_tiles3 = self.game_tiles.where(hotel: hotel_name3)\n game_tiles3.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c3]\n other_tiles << temp\n end\n game_hotel1.chain_size += game_tiles2.length + game_tiles3.length\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel2.chain_size = 0\n game_hotel2.save\n game_hotel2.update_share_price\n game_hotel3.chain_size = 0\n game_hotel3.save\n game_hotel3.update_share_price\n elsif (game_hotel2.chain_size >= game_hotel1.chain_size) && (game_hotel2.chain_size >= game_hotel3.chain_size)\n dominant_hotel = game_hotel2.hotel\n acquired_hotel1 = game_hotel1\n acquired_hotel2 = game_hotel3\n color = dominant_hotel.color\n c1 = game_hotel1.hotel.color\n c3 = game_hotel3.hotel.color\n game_tiles1 = self.game_tiles.where(hotel: hotel_name1)\n game_tiles1.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c1]\n other_tiles << temp\n end\n game_tiles3 = self.game_tiles.where(hotel: hotel_name3)\n game_tiles3.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c3]\n other_tiles << temp\n end\n game_hotel2.chain_size += game_tiles1.length + game_tiles3.length\n game_hotel2.save\n game_hotel2.update_share_price\n game_hotel1.chain_size = 0\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel3.chain_size = 0\n game_hotel3.save\n game_hotel3.update_share_price\n elsif (game_hotel3.chain_size >= game_hotel1.chain_size) && (game_hotel3.chain_size >= game_hotel2.chain_size)\n dominant_hotel = game_hotel3.hotel\n acquired_hotel1 = game_hotel1\n acquired_hotel2 = game_hotel2\n color = dominant_hotel.color\n c1 = game_hotel1.hotel.color\n c2 = game_hotel2.hotel.color\n game_tiles1 = self.game_tiles.where(hotel: hotel_name1)\n game_tiles1.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c1]\n other_tiles << temp\n end\n game_tiles2 = self.game_tiles.where(hotel: hotel_name2)\n game_tiles2.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c2]\n other_tiles << temp\n end\n game_hotel3.chain_size += game_tiles1.length + game_tiles2.length\n game_hotel3.save\n game_hotel3.update_share_price\n game_hotel1.chain_size = 0\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel2.chain_size = 0\n game_hotel2.save\n game_hotel2.update_share_price\n end \n\n [color, other_tiles, acquired_hotel1, acquired_hotel1_size, acquired_hotel2, acquired_hotel2_size] \n end",
"def resize_to_limit(new_width, new_height)\n manipulate! do |image|\n image = resize_image(image,new_width,new_height) if new_width < image.width || new_height < image.height\n image\n end\n end",
"def build_resources\n delta = (MAP_ROWS + MAP_COLS) / (FOOD_NODE_COUNT + 1)\n distance = delta \n nodes = 0\n \n until nodes == FOOD_NODE_COUNT do\n r = rand( [MAP_ROWS, distance].min )\n c = distance - r\n\n next if c >= MAP_COLS or !@tiles[r][c].empty?\n\n @tiles[r][c].build_resource\n distance += delta\n nodes += 1\n end\n end",
"def initialize\n @tiles = []\n 1.upto(15) { |i| @tiles[i] = Array.new }\n end",
"def apply_tileset(tilemap, ts)\n tilemap.tileset = RPG::Cache.tileset(ts.tileset_name)\n ts.autotile_names.each_with_index do | str, idx |\n tilemap.autotiles[idx] = RPG::Cache.autotile(str)\n end\n tilemap.priorities = ts.priorities\nend",
"def resize_to_limit(width, height)\n manipulate! do |image|\n image = resize_image(image, width, height) if width < image.x_size || height < image.y_size\n image\n end\n self\n end",
"def resize_to_limit(width, height)\n width = dimension_from width\n height = dimension_from height\n manipulate! do |img|\n geometry = Magick::Geometry.new(width, height, 0, 0, Magick::GreaterGeometry)\n new_img = img.change_geometry(geometry) do |new_width, new_height|\n img.resize(new_width, new_height)\n end\n destroy_image(img)\n new_img = yield(new_img) if block_given?\n new_img\n end\n end",
"def tile_crop_resize(image, dpi)\n size = {\n 'x' => image.columns,\n 'y' => image.rows\n }\n\n resize = false\n\n ['x', 'y'].each do |a|\n if (@field['size' + a])\n size[a] = @field['size' + a]*dpi\n resize = true\n end\n end\n\n if (@field['tile'])\n image = tile_image(image, dpi) if @field['tile']\n elsif (resize)\n scaleX = size['x']/image.columns\n scaleY = size['y']/image.rows\n\n scale = scaleX\n scale = scaleY if scaleY > scaleX\n\n image.resize!(image.columns*scale, image.rows*scale, Magick::LanczosFilter, 0.7)\n end\n\n image.crop!(Magick::CenterGravity, size['x'], size['y']) if (@field['crop'])\n\n return image\n end",
"def capsule_map_path(count, world)\n \"#{world.urls[:images]}/map/npczahl#{count}.gif\"\n end",
"def generateMap difficulty\r\n width = 12\r\n height = 100\r\n map = Array.new(height)\r\n i = 0\r\n previousCutterYPos = 0\r\n noCuttterForFirst10Block = 0\r\n while i < height-1\r\n map[i] = Array.new(width)\r\n if(i%3==0) #if the coloumn consist plank then draws the wooden plank on the random position and fills the left space with 0\r\n posX = rand(1..6) #6 randomply decides the position where to draw the wooden plank\r\n plankWithBomb = rand(30)\r\n width.times do |x| \r\n if(x < posX || (posX+4) < x) # fills the coordinate with space i.e 0\r\n map[i][x] = 0\r\n else # fills the coordinate with wooden plank i.e 1 \r\n if(plankWithBomb % (5-difficulty)==0) \r\n map[i][x] = 3\r\n else\r\n map[i][x] = 1 \r\n end\r\n end\r\n end\r\n else #else then just draw the space i.e 0 or cutters \r\n posX = -1\r\n if(previousCutterYPos!=(i-1) && rand(15) % (10-difficulty)==0 && i < 90) # i > 10 denotes that there are no cutter for first 10 blocks or jumps\r\n posX = [0,11].sample \r\n previousCutterYPos = i\r\n end\r\n \r\n 12.times do |x|\r\n if(posX==x)\r\n map[i][posX] = 2\r\n else\r\n map[i][x] = 0\r\n end\r\n end\r\n end\r\n i+=1\r\n end\r\n\r\n # map[height-1] = Array.new()\r\n map[height-1] = [1,1,1,1,1,1,1,1,1,1,1,1] # just making the last block as platform for player to move around\r\n\r\n map # return the map to the calling function\r\nend",
"def google_tile(tx, ty, zoom)\n [tx, (2**zoom - 1) - ty]\n end",
"def generate_possible_areas_for_all_numbered_tiles\n t = Time.now\n puts 'Start: Generate possible areas for all numbered tiles'\n all_possible_areas = {}\n\n # @b_nl.each_with_value do |value, i, j|\n # if value != 0 then\n # restricted_board = create_restricted_board [i,j]\n # t_area = Time.now\n # next if [i,j] == [7,1]\n # puts \"Summoning for [#{i},#{j}]\"\n # a = summon_areas([i,j], value, restricted_board)\n\n # puts \"Summoned area for [#{i},#{j}], time: \" + (Time.now - t_area).to_i.to_s + 's size ' + a.count.to_s\n # all_possible_areas[\"#{i}-#{j}\"] = a\n # end\n (0..@row_count-1).to_a.each do |i|\n (0..@col_count-1).to_a.each do |j|\n # Summon for each numbered tile(non zero)\n if @b_nl[i,j] != 0 then\n restricted_board = create_restricted_board [i,j]\n t_area = Time.now\n next if [i,j] == [7,1]\n puts \"Summoning for [#{i},#{j}]\"\n a = summon_areas([i,j],@b_nl[i,j], restricted_board)\n\n puts \"Summoned area for [#{i},#{j}], time: \" + (Time.now - t_area).to_i.to_s + 's size ' + a.count.to_s\n all_possible_areas[\"#{i}-#{j}\"] = a\n end\n end\n end\n puts 'Finish: Generate possible areas for all numbered tiles, time: ' + (Time.now - t).to_i.to_s + 'seconds'\n all_possible_areas[\"7-1\"] = [[[]]]\n all_possible_areas\n end",
"def resizeImages\n # For each of the 9 images\n for counter in (1..9)\n pngName = \"./images/\" + counter.to_s() + \".png\"\n image = Magick::Image.read(pngName).first\n # Make the new image 25% larger\n thumb = image.scale(1.25)\n thumb.write(pngName)\n end\n end",
"def save_tile(image, dest_path, x, y, width, height, quality)\n image = if image.is_a? Magick::Image\n image\n else\n Magick::Image::read(image).first\n end\n\n quality = quality * 100 if quality < 1\n\n tile = image.crop(x, y, width, height, true)\n tile.write(dest_path)\n end",
"def set_map_initial_zoom(city_size)\n case city_size\n when \"l\"\n 10 \n when \"m\" \n 11\n when \"s\" \n 12\n else \n 9\n end\n end",
"def visible_tiles\n frame_x = (((@width - Config::TileWidth) / Config::TileWidth) ).to_i\n frame_y = (((@height - Config::TileHeight) / Config::TileHeight) ).to_i\n \n \n start_x = player.location.x - (frame_x / 2).to_i\n start_y = player.location.y - (frame_y / 2).to_i\n \n if start_x < 0\n start_x = 0\n end\n if start_y < 0\n start_y = 0\n end\n \n tiles = Array.new\n \n frame_x.times do |i|\n frame_y.times do |j|\n if (start_x + i < game.map.width ) && (start_y + j < game.map.height )\n # puts(\"start_x is #{start_x} and start_y is #{start_y} and i is #{i} and j is #{j}\")\n tiles << game.map.locations[start_x + i, start_y + j]\n end\n end\n end\n \n tiles\n \n end",
"def index\n f = File.open(Rails.root.join(\"datas\",\"map2.yml\"))\n globalMap = Array.new\n f.each_line {|line| globalMap << line.split(' ')}\n\n\n x0 = Integer(params[\"x0\"])\n y0 = Integer(params[\"y0\"])\n width = Integer(params[\"width\"])\n height = Integer(params[\"height\"])\n\n x1 = x0 + width\n y1 = y0 + height\n\n @map = Array.new\n @poisMap = Array.new\n globalMap[y0...y1].each do |line|\n lineZE = Array.new\n width.times do\n lineZE << 0\n end\n @poisMap << lineZE\n @map << line[x0...x1]\n end\n\n @pois = Array.new\n Poi.all.each do |poi|\n if poi.x == nil\n continue\n end\n if poi.y == nil\n continue\n end\n if poi.x > (x0+1) && poi.x < (x1-3) && poi.y < y1 && poi.y > (y0+3)\n level = Integer((poi.lvl)/5)\n puts level\n\n begin\n\n arbres = Array.new\n arbres[0] = [[202,203],[210,211],[218,219]]\n arbres[1] = [[204,205],[212,213],[220,221]]\n arbres[2] = [[206,207],[214,215],[222,223]]\n arbres[3] = [[208,209],[216,217],[224,225]]\n\n #@poisMap[poi.y][poi.x] = 1 + level*5\n #@poisMap[poi.y][poi.x+1] = 2 + level*5\n #@poisMap[poi.y-1][poi.x] = 3 + level*5\n #@poisMap[poi.y-1][poi.x+1] = 4 + level*5\n #@poisMap[poi.y-2][poi.x] = 5 + level*5\n #@poisMap[poi.y-2][poi.x+1] = 6 + level*5\n\n @poisMap[poi.y-1][poi.x+1] = arbres[level][0][1]\n\n @poisMap[poi.y][poi.x] = arbres[level][0][0]\n @poisMap[poi.y][poi.x+2] = arbres[level][1][1]\n @poisMap[poi.y+1][poi.x+1] = arbres[level][1][0]\n @poisMap[poi.y+1][poi.x+3] = arbres[level][2][1]\n @poisMap[poi.y+2][poi.x+2] = arbres[level][2][0]\n rescue\n end\n #@pois << poi\n end\n end\n\n\n\n\n respond_to do |format|\n format.json { render :json => @map }\n format.xml {}\n format.html {}\n end\n end",
"def generate_tile_heights(map_size)\n # USE SUPER SIMPLIFIED VERSION FOR NOW\n return Array.new(map_size, 1)\n\n # STUFF BELOW FOR MORE COMPLEX IMPLEMENTATION IN THE FUTURE\n # I RAN OUT OF TIME :(\n tiles = [\n Array.new((map_size*0.5).floor, 1), \n Array.new((map_size*0.4).floor, 2), \n Array.new((map_size*0.1).floor, 3) \n ].flatten\n\n # Compensate for imperfect percentage rounding \n (map_size - tiles.size).times do |i|\n tiles.push([1, 2, 3].sample)\n end\n\n # Shuffle the tiles to randomly assign them\n tiles = tiles.shuffle\n\n return tiles\n end",
"def copy_tile(src, srcId, dest, destId, origin, target)\n #We need the tile's offset within its block.\n srcPt = [(srcId%3)*16 , (srcId/3)*16]\n reverse = false\n if destId.nil?\n #Special case for our weird internal tile\n destPt = [16,48]\n reverse = true\n else\n destPt = [(destId%2)*32 , (destId/2)*32]\n end\n\n #Now, copy it and magnify it.\n for x in (0...16)\n for y in (0...16)\n for iX in (0...2) \n for iY in (0...2)\n srcVal = src[origin[0]+srcPt[0]+x,origin[1]+srcPt[1]+y]\n destXY = [target[0]+destPt[0]+2*x+iX,target[1]+destPt[1]+2*y+iY]\n if reverse\n if x<8\n destXY[0] += 16\n else\n destXY[0] -= 16\n end\n if y<8\n destXY[1] += 16\n else\n destXY[1] -= 16\n end\n end\n dest[destXY[0], destXY[1]] = srcVal\n end\n end\n end\n end\nend",
"def draw_tiles(tile_bag)\n until tiles.length == 7\n tiles.concat(tile_bag.draw_tiles(1)) #because draw_tiles returns an array\n\n end\n end",
"def best_zoom(collection, center_point, width, height)\n min_lat, max_lat, min_lng, max_lng = 0, 0, 0, 0\n collection.each do |loc|\n if loc.class == Location\n min_lat = loc.lat if loc.lat < min_lat\n max_lat = loc.lat if loc.lat > max_lat\n min_lng = loc.lng if loc.lng < min_lng\n max_lng = loc.lng if loc.lng > max_lng\n elsif loc.class == Array # expecting [lat, lng] array elements\n min_lat = loc.first if loc.first < min_lat\n max_lat = loc.first if loc.first > max_lat\n min_lng = loc.last if loc.last < min_lng\n max_lng = loc.last if loc.last > max_lng\n end\n end\n distance_diag = calculate_distance2(min_lat, min_lng, max_lat, max_lng)\n pixels_diag = Math.sqrt(width ** 2 + height ** 2)\n meters_per_pixel_needed = distance_diag / pixels_diag\n # compare here, meters per pixel to this number for different zoom levels\n zoom_levels_yahoo = [0, 2**0, 2**1, 2**2, 2**3, 2**4, 2**5, 2**6, 2**7, 2**8, 2**9, 2**10, 2**11, 2**12, 2**13, 2**14, 2**15, 2**16, 2**17] #start close in and zoom out\n zoom_levels_yahoo.each_with_index do |zl, i|\n zoom = (18 - i) if meters_per_pixel_needed > zl\n end\n zoom = 10 if (zoom.nil? || zoom == 0)\n zoom\n end",
"def all_tilestacks_rule\n if $compute_tilestacks.none?\n STDERR.puts \" Skipping tilestack creation\"\n []\n else\n STDERR.puts \" #{@base_tiles.size} base tiles per input frame (#{@source.tilesize}x#{@source.tilesize} px)\"\n if @source.respond_to?(:tilestack_rules)\n # The source natively supplies tilestacks. We should depend on these\n targets = @source.tilestack_rules\n targets = Rule.touch(\"#{@raw_tilestack_dir}/SOURCE_COMPLETE\", targets)\n else\n # The source supplies tiles. We should depend on these\n targets = all_tiles_rule\n end\n targets = tilestack_rule(Tile.new(0,0,0), targets)\n Rule.touch(\"#{@tilestack_dir}/COMPLETE\", targets)\n end\n end",
"def find_cut(map)\n while map.length > 2\n # This is ok\n v1,v2 = get_vertices(map)\n # Merge \n map[v1] = merge_edges(map,v1,v2)\n # Delete\n remove_vertex(map,v2)\n # Remove occurences\n convert_vertex(map,v2,v1)\n # Remove loops\n remove_loops(map,v1)\n\n end\nend",
"def create\nActionController::Parameters.permit_all_parameters = true\n @tile = Tile.new(tile_params)\n\n if params[:imd] != nil\n @image = Image.find(params[:imd])\n @image.tiles << @tile\n end\n if params[:tti] != nil\n\t\t@terraintype = Terraintype.find(params[:tti]) \n\t\t@terraintype.tiles << @tile\n\t\t#@tile.terraintype = @terraintype \n end\n if params[:lmd] != nil\n @layer = Layer.find(params[:lmd])\n @layer.tiles << @tile\n end\n\n if params[:rid] != nil\n \t@resource = Resource.find(params[:rid])\n\t @resource.tiles << @tile\n\t end \n if params[:rids] != nil\n\t\tparams[:rids].each {\t|x| \n\t \t@resource = Resource.find(x)\t \n\t \t@tile.resources << @resource\n\t\t}\n\tend\t\t\n\tif params[:bids] != nil\n\t\tparams[:bids].each {\t|x| \n\t \t@building = Building.find(x)\t \n\t \t@tile.buildings << @building\n\t\t}\n\tend\t\nRails.logger.debug \"tile params: \" + params[:imd].to_s\n \n respond_to do |format|\n\n if @tile.save \n format.html { redirect_to @tile, notice: 'Tile was successfully created.' }\n format.json { render action: 'id', status: :created, location: @tile }\n else\n format.html { render action: 'new' }\n format.json { render json: @tile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tileset(id, tile_width = 32, tile_height = 32, global = false, ext = '.png', retro = nil)\n a = global ? @global_tilesets : @tilesets\n return a[id] if a[id]\n s = @prefix + @tileset_dir + id.to_s.split(@separator).join('/') + ext\n retro = Res.retro_images if retro.nil?\n tileset = Gosu::Image.load_tiles s, tile_width, tile_height, tileable: true, retro: retro\n a[id] = tileset\n end",
"def render\n canvas = Vips::Image.grey(@width, @height)\n\n @tiles.each do |tile|\n canvas = canvas.insert(tile.image, tile.offset.x, tile.offset.y) # rubocop:disable Style/RedundantSelfAssignment\n end\n\n # add attribution image to bottom corner if available & attribution fits into image\n if add_attribution?\n options = { x: canvas.width - attribution.width, y: canvas.height - attribution.height }\n canvas = canvas.composite2(attribution, :over, **options)\n end\n\n canvas\n end",
"def tile_board\n @board_array.each_with_index do |row_array, row|\n 10.times{|column| row_array << Tile.new(row,column)}\n end\n end",
"def draw_tiles(tile_bag)\n if @players_plaque.length < MAX_NUM_OF_TILES_ALLOWED\n add_tiles = MAX_NUM_OF_TILES_ALLOWED - @players_plaque.length\n @players_plaque.concat(tile_bag.draw_tiles(add_tiles))\n end\n end",
"def tile_size level\n\t\t\t2 ** level\n\t\tend",
"def tile(col, row, original_map_state)\n image = TileCache.get(@session_id, col, row)\n \n if !image\n x, y = Tile.to_xy(col, row)\n pan(x, y, original_map_state)\n \n image = map\n \n TileCache.put(@session_id, col, row, image)\n image = TileCache.get(@session_id, col, row)\n end\n \n image\n end",
"def initialize(options)\n @tile_source = options[:source]\n raise \"Missing options[:source].\" unless @tile_source\n @tile_source = Magick::Image.read(@tile_source)[0] if @tile_source.is_a?(String)\n @tile_size = options[:size] || DEFAULT_TILE_SIZE\n @tile_overlap = options[:overlap] || DEFAULT_TILE_OVERLAP\n @tile_format = options[:format] || DEFAULT_TILE_FORMAT\n @max_tiled_height = @tile_source.rows\n @max_tiled_width = @tile_source.columns\n @tile_quality = options[:quality] || DEFAULT_QUALITY\n @overwrite = options[:overwrite] || false\n @destination = options[:destination] || File.join(Dir.pwd, \"tiles\")\n end",
"def all_tiles(x, y)\n newTilePoint = map_tile_adjust_xy(x, y)\n tile_events_xy(newTilePoint.x, newTilePoint.y).collect {|ev| ev.tile_id } + layered_tiles(x, y)\n end",
"def layered_tiles(x, y)\n newTilePoint = map_tile_adjust_xy(x, y)\n [2, 1, 0].collect {|z| tile_id(newTilePoint.x, newTilePoint.y, z) }\n end",
"def width; @width ||= GeoWeb::Map.map_extent(zoom, tile_width); end",
"def generate_tectonic_plates\n max_radius = (width / 10) * 2.0\n\n hill_resources = [ :coal, :iron, :uranium ]\n mountain_resources = [ :coal, :iron, :uranium ]\n\n (width/4).times do\n candidates = { }\n\n radius = (width / 10) * (1.0 + Kernel::rand)\n pos = [ Kernel::rand(@maxx), Kernel::rand(@maxy) ]\n cx,cy = pos\n\n tiles = { }\n\n 1.upto(radius) do |r|\n (cx-r).upto(cx+r) do |x|\n (cy-r).upto(cy+r) do |y|\n pos = [x,y]\n next if tiles[pos]\n next unless in_range?(pos)\n\n if Kernel::rand >= r.to_f/max_radius\n tiles[pos] = true\n tile = self[pos]\n if tile[:terrain] == :grass then\n tile[:terrain] = :hills\n tile[:resource] = nil\n tile[:resource] = hill_resources[Kernel::rand(hill_resources.length - 1)] if Kernel::rand < 0.20\n tile[:resource] = :arable if tile[:resource].nil? && Kernel::rand < 0.40\n elsif tile[:terrain] == :hills then\n tile[:terrain] = :mountains\n tile[:resource] = nil\n tile[:resource] = mountain_resources[Kernel::rand(mountain_resources.length - 1)] if Kernel::rand < 0.40\n else\n tile[:terrain] = :grass\n tile[:resource] = nil\n tile[:resource] = :arable if Kernel::rand < 0.10\n tile[:resource] = :oil if Kernel::rand < 0.03\n tile[:resource] = hill_resources[Kernel::rand(hill_resources.length - 1)] if tile[:resource].nil? && Kernel::rand < 0.05\n end\n end\n end\n end\n end\n end\n end",
"def ox=(ox)\n #\n unless @tilemap_drawn\n @ox = ox\n @ox_oy_set[0] = true\n return\n end\n \n return if @ox == ox\n # Shift all tiles left or right by the difference\n shift = @ox - ox\n \n @tile_sprites.each {|set| set.each{|tile| tile.x += shift }}\n @ox = ox\n # Determine if columns need to be shifted\n col_num = @corner_index\n #return unless @tile_sprites[col_num][0].x <= -49 || @tile_sprites[col_num][0].x >= -17\n while @tile_sprites[col_num][0].x <= -49 || @tile_sprites[col_num][0].x >= -17\n \n @corner_tile_loc[0] += (shift < 0 ? 1 : -1)\n modTileId = ((SCREEN[0]+64)*(SCREEN[1]+64))/1024 \n # If new ox is greater than old ox\n if shift < 0\n # Move all sprites in left column to the right side and change bitmaps\n # and z-values\n (0...(SCREEN[1]/32+2)).each{|n|\n j = ((SCREEN[0]/32+2) * n + col_num) % modTileId\n @tile_sprites[j].each_index{|i|\n tile = @tile_sprites[j][i]\n @animating_tiles.delete(tile.tile_sprite_id)\n tile.x += 64 + SCREEN[0]\n \n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n tile_id = @map_data[map_x,map_y,i]\n \n if tile_id.nil?\n tile.z = [map_y * 32, 0].max\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n next\n else\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32\n end\n end\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8) * 32,((tile_id - 384) / 8) *32, 32, 32)\n else\n auto_id = tile_id/48-1\n tile.bitmap = @autotiles[auto_id]\n tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1\n end\n }\n }\n # New corner should be the tile immediately right of the previous tile\n col_num /= SCREEN[0]/32+2\n col_num *= SCREEN[0]/32+2\n @corner_index = (@corner_index + 1) % (SCREEN[0]/32+2) + col_num\n else\n # Shift right column to the left\n # Gets the right column\n row_index = col_num / (SCREEN[0]/32+2)\n row_index *= (SCREEN[0]/32+2)\n col_num = (@corner_index - 1) % (SCREEN[0]/32+2) + row_index\n \n (0...(SCREEN[1]/32+2)).each{|n|\n j = ((SCREEN[0]/32+2) * n + col_num) % modTileId\n @tile_sprites[j].each_index{|i|\n tile = @tile_sprites[j][i]\n @animating_tiles.delete(tile.tile_sprite_id)\n tile.x -= 64 + SCREEN[0]\n \n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n tile_id = @map_data[map_x,map_y,i]\n if tile_id.nil?\n tile.z = [map_y * 32, 0].max\n tile.bitmap = @tileset\n tile.src_rect.set(0,0,0,0)\n next\n else\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32\n end\n end\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)\n else\n auto_id = tile_id/48-1\n tile.bitmap = @autotiles[auto_id]\n tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1\n end\n }\n }\n col_num /= SCREEN[0]/32+2\n col_num *= SCREEN[0]/32+2\n @corner_index = (@corner_index - 1) % (SCREEN[0]/32+2) + col_num\n end\n col_num = @corner_index\n end #end of while\n end",
"def calculate_zoom(top_left:, bottom_right:, width:, height:)\n # multiplication factor between horizontal span and map width\n h_factor = (bottom_right.column - top_left.column) / (width.to_f / Honua.configuration.tile_width)\n\n # possible horizontal zoom to fit geographical extent in map width\n h_possible_zoom = top_left.zoom - (Math.log(h_factor) / Math.log(2)).ceil\n\n # multiplication factor between vertical span and map height\n v_factor = (bottom_right.row - top_left.row) / (height.to_f / Honua.configuration.tile_height)\n\n # possible vertical zoom to fit geographical extent in map height\n v_possible_zoom = top_left.zoom - (Math.log(v_factor) / Math.log(2)).ceil\n\n # initial zoom to fit extent vertically and horizontally\n [h_possible_zoom, v_possible_zoom].min\n end",
"def optional_tiles; end",
"def resize_to_limit(width, height)\n manipulate! do |img|\n img.resize \"#{width}x#{height}>\"\n img = yield(img) if block_given?\n img\n end\n end",
"def draw_tiles (num)\n tiles_drawn = @bag_of_tiles.sample(num)\n tiles_drawn.each do | tile |\n @bag_of_tiles.slice!(@bag_of_tiles.index(tile))\n end\n return tiles_drawn\n end",
"def scale(value)\n @tileset.scale = value\n end",
"def create_map_picture\n @picture = Sprite.new(@viewport)\n @picture.bitmap = Cache.picture(MINIMAP_PICTURE)\n @picture.x = P_X; @picture.y = P_Y\n @picture.opacity = 0\n end",
"def initialize(tiles = [], player)\n tiles.reject!{|p| p.x.nil? || p.y.nil? }\n\n @map = []\n @explored_area = []\n\n @known_floors = {}\n @last_seen_floors = {}\n @known_walls = {}\n @known_stashes = {}\n @seen_floors = {}\n @player = player\n\n x_dimension = tiles.map(&:x).sort.last\n y_dimension = tiles.map(&:y).sort.last\n\n if @@point_navigate_path.any? && !@@point_navigate_path.include?(@player.position)\n find_path_to_point(@@destination) # Our path has become corrupted - recalculate it!\n end\n @@free_space_path.delete(@player.position)\n @@point_navigate_path.delete(@player.position)\n\n tiles.each do |tile_point|\n coord = [tile_point.x, tile_point.y]\n case tile_point.type\n when 'floor'\n @known_floors[coord] = tile_point\n @last_seen_floors[coord] = -1\n when 'wall'\n @known_walls[coord] = tile_point\n when 'stash'\n @known_stashes[coord] = tile_point\n else\n raise \"Unknown type : #{tile_point.type}\" if tile_point.type\n end\n end\n\n for key in @last_seen_floors.keys\n @last_seen_floors[key] = @last_seen_floors[key] + 1\n end\n\n @pathfinder = Pathfinder.new(x_dimension, y_dimension)\n update_path_blocks(@known_walls.keys)\n\n create_map(x_dimension, y_dimension)\n end",
"def scale\n scale_factor = 20 # template.png height divided by canvas height\n self.image_x *= scale_factor\n self.image_y *= scale_factor\n self.height *= scale_factor\n self.width *= scale_factor\n self.rotation *= 180 / Math::PI\n end",
"def set_screen_factors(lat_min, lat_max, lon_min, lon_max)\n @x_factor = 0\n @y_factor = 0\n # TODO add a border\n x_range = lon_max.to_f - lon_min.to_f\n @x_factor = (x_range * MAP_SCALE) / (SCRATCH_MAX_X - SCRATCH_MIN_X)\n y_range = lat_max.to_f - lat_min.to_f\n @y_factor = (y_range * MAP_SCALE) / (SCRATCH_MAX_Y - SCRATCH_MIN_Y)\n # TODO don't skew the map, figure on one factor and use accordingly\n end",
"def update_projectiles\n\t\t@projectiles.delete_if do |projectile|\n\t\t\tprojectile.move\n\t\t\tprojectile.out_of_bounds\n\t\tend\n\tend",
"def initialize(generate = false, file_name = 'map')\n @file_name = file_name\n @data_path = \"./data/#{file_name}.dat\"\n @blocks = {}\n @tiles = {}\n @tiles_info = {\n 1 => {\n :path => \"./\" + Config.get('img_path') + \"grass.png\",\n :type => :grass\n },\n 2 => {\n :path => \"./\" + Config.get('img_path') + \"grass.png\",\n :type => :grass\n },\n 3 => {\n :path => \"./\" + Config.get('img_path') + \"grass.png\",\n :type => :grass\n },\n 4 => {\n :path => \"./\" + Config.get('img_path') + \"grass.png\",\n :type => :grass\n },\n 5 => {\n :path => \"./\" + Config.get('img_path') + \"oak.png\",\n :type => :tree\n },\n 6 => {\n :path => \"./\" + Config.get('img_path') + \"betula.png\",\n :type => :tree\n },\n 7 => {\n :path => \"./\" + Config.get('img_path') + \"picea.png\",\n :type => :tree\n },\n 8 => {\n :path => \"./\" + Config.get('img_path') + \"mountain.png\",\n :type => :mountain\n }\n }\n JSON.dump_default_options[:max_nesting] = 10\n JSON.load_default_options[:max_nesting] = 10\n init_from_config Config['BLOCKS_IN_MAP_DIM'], Config['BLOCK_DIM']\n if generate || !File.exist?(@data_path)\n generate_map\n else\n file = File.open(@data_path, \"r\")\n data = Marshal.load(file)\n @tiles = data[:tiles]\n @blocks = data[:blocks]\n check_map\n end\n end",
"def copy_cheaty(src, srcId, dest, destId, origin, target)\n #We need the tile's offset within its block.\n destPt = [(destId%2)*32 , (destId/2)*32]\n\n #Now, copy it and magnify it.\n for x in (0...16)\n for y in (0...16)\n for iX in (0...2) \n for iY in (0...2)\n srcVal = src[origin[0]+x,origin[1]+y]\n destXY = [target[0]+destPt[0]+2*x+iX,target[1]+destPt[1]+2*y+iY]\n dest[destXY[0], destXY[1]] = srcVal\n end\n end\n end\n end\nend",
"def tile_bounds(tx, ty, zoom)\n min_x, min_y = pixels_to_meters(tx * @tile_size, ty * @tile_size, zoom)\n max_x, max_y = pixels_to_meters((tx + 1) * @tile_size, (ty + 1) * @tile_size, zoom)\n [min_x, min_y, max_x, max_y]\n end",
"def resize_to_limit!(image, width, height)\n with_minimagick(image) do |img|\n img.combine_options do |cmd|\n yield cmd if block_given?\n cmd.resize \"#{width}x#{height}>\"\n end\n end\n end",
"def tiles_remaining\n return @tiles\n end",
"def copy_water(src, srcId, dest, destId, origin, target, animId)\n #We need the tile's offset within its block.\n srcPt = [ animId*16 , srcId*16 ]\n\n #Are we doing full tiles, or quadrants?\n if destId.is_a? Array\n #Give it an offset\n destId = destId.map{|id| id+= 8}\n elsif destId==0\n destId = [0,1,4,5] #Make it an array\n elsif destId==1\n destId = [2,3,6,7] #Make it an array\n else\n raise \"Unknown water permutation\"\n end\n\n #Turn this into a series of destination points:\n destPts = []\n destId.each{|pt|\n destPts.push [(pt%4)*16 + animId*64 , (pt/4)*16]\n }\n\n #Now, copy it and magnify it.\n srcId = 0\n destPts.each {|pt|\n for x in (0...8)\n for y in (0...8)\n for iX in (0...2) \n for iY in (0...2)\n srcVal = src[origin[0]+srcPt[0]+8*(srcId%2)+x,origin[1]+srcPt[1]+8*(srcId/2)+y]\n destXY = [target[0]+pt[0]+2*x+iX,target[1]+pt[1]+2*y+iY]\n dest[destXY[0], destXY[1]] = srcVal\n end\n end\n end\n end\n srcId += 1\n }\nend",
"def resize_to_limit(new_width, new_height)\n width, height = FastImage.size(self.current_path)\n if width > new_width || height > new_height\n resize_to_fit(new_width, new_height)\n end\n end",
"def max_crop_area_growth(crop_from, crop_size)\n {\n top: crop_from[:y],\n right: image_size[:width] - crop_from[:x] - crop_size[:width],\n bottom: image_size[:height] - crop_from[:y] - crop_size[:height],\n left: crop_from[:x],\n }\n end",
"def large_process\n case [model.attachable_type, model.image_type]\n when ['User', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n when ['User', 'inspiration'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'avatar'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'alternate'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Alternative', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n else\n resize_to_fit 1024, 9999 # fixed width\n end\n # TODO: Test and implement this.\n # fix_exif_rotation\n quality 70\n end",
"def cut_to_fit(options)\n %Q{-thumbnail #{options.width}x#{options.height}^ \\\n -gravity #{options.gravity} \\\n -unsharp 0x.5 \\\n -auto-orient \\\n -extent #{options.width}x#{options.height}}\n end",
"def recalculate!(scale)\n neighbor = @coordinate.zoom_to(zoom - 1)\n parent = neighbor.container\n\n col_shift = 2 * (neighbor.column - parent.column)\n row_shift = 2 * (neighbor.row - parent.row)\n\n @offset.x -= scale * tile_width * col_shift\n @offset.y -= scale * tile_height * row_shift\n @coordinate = parent\n end",
"def draw_tiles(num)\n random_tiles = @tiles.sample(num)\n random_tiles.each do |letter|\n @tiles.slice!(@tiles.index(letter))\n end\n return random_tiles\n end",
"def tiles\n return @tiles\n end"
] |
[
"0.71161556",
"0.61068445",
"0.6008391",
"0.5891905",
"0.58417696",
"0.5748425",
"0.56101924",
"0.55432343",
"0.55327004",
"0.53978735",
"0.5359074",
"0.5253409",
"0.5205672",
"0.5189787",
"0.5148607",
"0.513522",
"0.51283264",
"0.5098436",
"0.509807",
"0.5092467",
"0.50913197",
"0.5089791",
"0.50890744",
"0.50843835",
"0.5040913",
"0.5032243",
"0.50267684",
"0.5001597",
"0.49946824",
"0.49822775",
"0.49822775",
"0.49784938",
"0.49706063",
"0.49689186",
"0.49687573",
"0.49598393",
"0.49562606",
"0.49429232",
"0.49412563",
"0.49210045",
"0.4919832",
"0.4899113",
"0.48872727",
"0.48455593",
"0.48357227",
"0.48284838",
"0.481447",
"0.48081148",
"0.4801135",
"0.47705328",
"0.47589603",
"0.47553423",
"0.47461647",
"0.4743094",
"0.4741171",
"0.4715543",
"0.47111303",
"0.47076374",
"0.47060242",
"0.4702185",
"0.4692414",
"0.46912518",
"0.46880692",
"0.4685225",
"0.46737483",
"0.4660952",
"0.46517494",
"0.46475875",
"0.46443024",
"0.46441877",
"0.46306062",
"0.463034",
"0.46245858",
"0.4612028",
"0.46074674",
"0.46026334",
"0.4602476",
"0.46007612",
"0.45998123",
"0.45929503",
"0.4581336",
"0.45739374",
"0.45734054",
"0.4571085",
"0.45688927",
"0.45659712",
"0.45655334",
"0.45633185",
"0.45629385",
"0.45620432",
"0.45601198",
"0.45487446",
"0.45448002",
"0.45446175",
"0.45439184",
"0.45435038",
"0.4542557",
"0.45324102",
"0.45277068",
"0.45205048"
] |
0.63503176
|
1
|
Build land mass image from Google Map image Returns true if image created
|
def build_reduced_land_mass_image(x, y, zoom, accuracy_pixels, overwrite = false)
land_mass_tile_path = LandMassTile.tile_path(x, y, zoom, accuracy_pixels)
# exit if file already exists
return false if (!overwrite && File.exists?(land_mass_tile_path))
begin
# build up square of 4 children tiles
child_tiles = (0..1).map { |this_x| (0..1).map { |this_y| OpenStruct.new(:x => this_x+x*2, :offset_x => this_x, :y => this_y+y*2, :offset_y => this_y, :zoom => zoom+1) } }.flatten(1)
reduce_tiles = child_tiles.select do |tile|
tile.accuracy_pixels = accuracy_pixels
tile.path = LandMassTile.tile_path(tile.x, tile.y, tile.zoom, tile.accuracy_pixels)
tile.exists = File.exists?(tile.path)
tile.img = Magick::Image.read(tile.path).first if tile.exists
tile.exists # remove image if tile does not exist
end
stitch_tiles = child_tiles.select do |tile|
tile.accuracy_pixels = accuracy_pixels * 2
tile.path = LandMassTile.tile_path(tile.x, tile.y, tile.zoom, tile.accuracy_pixels)
tile.exists = File.exists?(tile.path)
tile.img = Magick::Image.read(tile.path).first if tile.exists
tile.exists # remove image if tile does not exist
end unless reduce_tiles.length == 4
if (reduce_tiles.length == 4)
# We are building a land mass tile from children with the same number of pixels in the tile
# which means we need to "squeeze" 4 tiles into 1
new_tile = Magick::Image.new(AppConfig.gmap_tile_size / accuracy_pixels * 2, AppConfig.gmap_tile_size / accuracy_pixels * 2) do
self.background_color = "transparent"
end
child_tile_size = new_tile.columns / 2
reduce_tiles.each do |tile|
raise "Tile#{tile.path} is incorrectly #{tile.img.columns} wide / high" if ( (tile.img.columns != child_tile_size) || (tile.img.rows != child_tile_size) )
pixels = tile.img.export_pixels(0, 0, tile.img.columns, tile.img.rows, "RGBA")
new_tile.import_pixels(tile.offset_x * child_tile_size, tile.offset_y * child_tile_size, tile.img.columns, tile.img.rows, "RGBA", pixels)
end
# now resize down to single tile size
reduced_tile = new_tile.resize(AppConfig.gmap_tile_size / accuracy_pixels, AppConfig.gmap_tile_size / accuracy_pixels)
reduced_tile.write land_mass_tile_path
elsif (stitch_tiles.length == 4)
# We are building a land mass tile from children with a lower accuracy level i.e. we need to
# build up this tile by stitching 4 children tiles together
new_tile = Magick::Image.new(AppConfig.gmap_tile_size / accuracy_pixels, AppConfig.gmap_tile_size / accuracy_pixels) do
self.background_color = "transparent"
end
child_tile_size = new_tile.columns / 2
stitch_tiles.each do |tile|
raise "Tile#{tile.path} is incorrectly #{tile.img.columns} wide / high" if ( (tile.img.columns != child_tile_size) || (tile.img.rows != child_tile_size) )
pixels = tile.img.export_pixels(0, 0, tile.img.columns, tile.img.rows, "RGBA")
new_tile.import_pixels(tile.offset_x * child_tile_size, tile.offset_y * child_tile_size, tile.img.columns, tile.img.rows, "RGBA", pixels)
end
new_tile.write land_mass_tile_path
else
reduce_tiles_info = reduce_tiles.map{|c| "#{c.x}:#{c.y} zm #{c.zoom}" }.join(',')
stitch_tiles_info = stitch_tiles.map{|c| "#{c.x}:#{c.y} zm #{c.zoom}" }.join(',')
SLogger.warn("Could not reduce land mass image for position as not all children tiles exist. Tile #{x}:#{y} (zoom #{zoom}). Reduce tiles: #{reduce_tiles_info}. Stitch tiles: #{stitch_tiles_info}")
false
end
rescue Exception => e
SLogger.warn("Could not save reduced land mass image for position #{x}:#{y} (zoom #{zoom}). Error '#{e.message}'")
false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def map_image(lat, long, width=500, height=400)\n \"http://maps.google.com/maps/api/staticmap?zoom=16&size=#{width}x#{height}&markers=#{lat},#{long}&sensor=false\"\n end",
"def map_image location, width=500, height=275, zoom=15\n image_tag(\"http://maps.googleapis.com/maps/api/staticmap?center=#{location.latitude},#{location.longitude}&zoom=#{zoom}&size=#{width}x#{height}&markers=color:blue%7Clabel:1%7C#{location.latitude},#{location.longitude}&sensor=false\", :class => \"map_image\")\n end",
"def get_haplotype_img(map_id)\n\n map = Map.find(map_id)\n @markers = []\n chromosome = params['chromosome'] || 1\n start = params['start'] || 20000000\n stop = params['end'] || 25000000\n\n # do the processing to get the data and create the image\n get_region_marker_data(chromosome, start, stop)\n # redirect output to the image file itself, thereby rendering the file\n redirect_to draw_haplotype_image(@markers, @strains, @genotypes, false, 'high', 'gif')\n\n end",
"def generate_images width=500, height=350\n # Base image with all territories shaded\n canvas = Magick::Image.new(width, height, Magick::TextureFill.new(@@map_bg))\n canvas.format = 'jpg'\n gc = Magick::Draw.new\n Territory.all.each do |t|\n gc.fill(\"transparent\")\n if t.clan\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(0.25)\n end\n gc.stroke('rgb(64, 0, 0)')\n gc.stroke_width(1)\n if t.shape # uses svg-like shapes\n s = t.shape.split(',')\n path = \"M #{s[0]} #{s[1]} \"\n s[2..-1].each_slice(2) do |p|\n path << \"L #{p[0]} #{p[1]} \"\n end\n path << \"z\"\n gc.path(path)\n end\n\n if t.clan\n # draw the small icon for the clan if it exists\n if t.clan.image_filename 16\n gc.composite(t.position_x - 8, t.position_y - 8, 16, 16,\n Magick::Image.read(\"#{RAILS_ROOT}/public/images/#{t.clan.image_filename(16)}\").first)\n else # or draw a circle of their color\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(1);\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n else\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n end\n gc.draw(canvas)\n canvas.write(\"#{RAILS_ROOT}/public/images/map/base.jpg\"){ self.quality = 95 } # TODO tweak the quality\n\n true\n end",
"def detect_landmarks path_to_image_file:\n # [START get_vision_service]\n vision = Google::Cloud::Vision.new\n # [END get_vision_service]\n\n # [START construct_request]\n image = vision.image path_to_image_file\n landmark = image.landmark\n # [END construct_request]\n\n # [START print_landmark]\n puts \"Found landmark: #{landmark.description}\" unless landmark.nil?\n # [END print_landmarks]\nend",
"def processImage(params, metadata)\n url = params['metadataServerURL']\n \n # This is used to determine if we should actually process this image or\n # not, based on some criteria (e.g. modification date and whether or not\n # the tile set exists.\n process = false\n \n # See if there is an existing checkpoint and date for this map.\n checkpointDate = nil\n @checkpoints.each do |checkpoint|\n if (checkpoint['id'].to_s == metadata['id'].to_s)\n checkpointDate = DateTime.parse(checkpoint['updated_at'])\n break\n end\n end\n \n # If there is no date, then we haven't seen this map before, so we want\n # to process it. Otherwise, we only process the map if the new date is\n # more recent than the old checkpoint date.\n currentDate = DateTime.parse(metadata['updated_at'])\n if (checkpointDate == nil || checkpointDate < currentDate) then process = true end\n \n # We don't want to process an image if there aren't enough control points,\n # regardless of if the times check out...\n if (metadata['no_control_points'].to_i < 3) then process = false end\n controlPoints = fetchControlPoints(url, metadata['id'])\n\n if (process)\n puts 'Processing map '+metadata['id'].to_s+'...'\n \n # Reset the metadata to include all the in-depth metadata for this map.\n metadata = getMapMetadata(url, metadata['id'])\n fileName = metadata['identifier']\n \n # The y values in the database is \"wrong\": the conversion commands\n # start from the top left corner but MapHub starts from the bottom\n # left. Therefore, we need to \"flip\" the y values around the median\n # line of the map.\n mapHeight = Float(metadata['height'])\n median = mapHeight / 2\n controlPoints.map! do |cp|\n y = Float(cp['y'])\n if (y > median)\n difference = y - median\n y = median - difference\n elsif (y < median)\n difference = median - y\n y = median + difference\n else\n # This point is exactly on the median. Don't anger it.\n end\n cp['y'] = y\n cp\n end\n \n ENV['GDAL_DATA'] = $GDALRoot\n dir = Dir.mktmpdir()\n \n # Translate the image.\n translateCommand = 'gdal_translate -of VRT -a_srs EPSG:4326'\n controlPoints.each do |cp|\n translateCommand = translateCommand+' -gcp '+cp['x'].to_s+' '+cp['y'].to_s+' '+cp['lng']+' '+cp['lat']\n end\n translateCommand = translateCommand+' '+params['imageDirectory']+'/raw/'+fileName+'.jp2 '+dir.to_s+'/'+fileName+'-original.vrt'\n puts \"Translating: #{translateCommand}\"\n system(translateCommand)\n \n # Warp the image.\n warpCommand='gdalwarp -of VRT -s_srs EPSG:4326 -t_srs EPSG:4326 '+dir.to_s+'/'+fileName+'-original.vrt '+dir.to_s+'/'+fileName+'-warped.vrt'\n puts \"Warping: #{warpCommand}\"\n system(warpCommand)\n\n # Generate the tile set, placing the generated images in the temporary\n # directory.\n #tileCommand='gdal2tiles.py -n '+dir.to_s+'/'+fileName+'-warped.vrt '+dir.to_s+'/'+$tilesetName\n publishURL = params['publishServerURL'] + $tilesetName\n tileCommand='gdal2tiles.py -u '+publishURL+' -k '+dir.to_s+'/'+fileName+'-warped.vrt '+dir.to_s+'/'+fileName\n puts \"Tiling: #{tileCommand}\"\n system(tileCommand)\n \n # Next we need to tell the server what the new map boundaries are. Get\n # the XML data so we can parse out the boundaries.\n # xmlFile = File.new(dir.to_s+'/'+$tilesetName+'/tilemapresource.xml')\n # xmlDoc = REXML::Document.new(xmlFile)\n # bounds = xmlDoc.root.elements['BoundingBox'].attributes\n # \n # Make a PUT request to update the map with the new boundaries.\n # This is disabled for the time being.\n # uri = URI(params['metadataServerURL'].to_s+'maps/'+metadata['id'].to_s)\n # request = Net::HTTP::Put.new(uri.path)\n # request.set_form_data(\n # 'ne_lat' => bounds['maxx'],\n # 'ne_lng' => bounds['maxy'],\n # 'sw_lat' => bounds['minx'],\n # 'sw_lng' => bounds['miny']\n # )\n # http = Net::HTTP.new(uri.host, uri.port)\n # response = http.request(request)\n \n # Clean up the generated files to leave only the images and the XML\n # file which contains the map bounds and other GIS information.\n FileUtils.rm(Dir.glob(dir.to_s+'/'+$tilesetName+'/*.html'))\n \n # Remove the current tile set and move the new tile set into its\n # place.\n FileUtils.mkdir_p(params['imageDirectory']+'/'+$tilesetName)\n FileUtils.rm_rf(params['imageDirectory']+'/'+$tilesetName+'/'+fileName)\n \n # Move /tmp/.../IDENTIFIER to target/ts_google/IDENTIFIER\n FileUtils.mv(dir.to_s+'/'+fileName, params['imageDirectory']+'/'+$tilesetName+'/'+fileName)\n \n return true\n end\n \n return false\n end",
"def map_image(map = nil)\n map ? image_tag(\"maps/#{map}_thumb.jpg\") : image_tag('maps/unknown.jpg')\n end",
"def generate_map datecart\n image_tag \"https://maps.google.com/maps/api/staticmap?#{format_google_maps_api_call_parameters(datecart.cart_items)}\", :class => \"map\", :alt => \"Date Map\"\n end",
"def img_and_map_generate(uuid,\n filename,\n seqid,\n range,\n config_obj,\n width,\n add_introns,\n config_override = [])\n\n log \"generating img/map #{uuid}\"\n log filename, 2\n log \"#{seqid}, #{range.inspect}\", 2\n time = Benchmark.measure do\n config_copy = config_obj.clone\n config_override.each do |option|\n gt_ruby_type, section,\n attribute, value = option\n if value.nil?\n config_copy.unset(section, attribute)\n else\n config_copy.send(\"set_#{gt_ruby_type}\", section, attribute, value)\n end\n end\n mode = add_introns ? :on : :off\n fix = feature_index(filename, mode)\n gtrange = fix.get_range_for_seqid(seqid)\n gtrange.start = range.first\n gtrange.end = range.last\n diagram = GT::Diagram.new(fix, seqid, gtrange, config_copy)\n info = GT::ImageInfo.new\n canvas = GT::CanvasCairoFile.new(config_copy, width, info)\n diagram.sketch(canvas)\n lock(:map) do\n @cache[:map][uuid] = info\n end\n lock(:img) do\n @cache[:img][uuid] = canvas.to_stream\n end\n end\n log \"done (%.4fs)\" % time.real, 3\n return true\n rescue => err\n log \"ERROR: #{err}\", 3\n return false\n end",
"def export_mindmap\n\t\treturn false if @current_search == {phrase: \"\", thumbnail: nil}\n\t\treturn false unless @current_search[:thumbnail]\n\n\t\ttarget_file = ask_save_file\n\t\treturn false unless target_file && target_file != \"\"\n\t\t@data_controller.render_picture(\n\t\t\t@current_search[:phrase],\n\t\t\t@data_controller.look_for(@current_search[:phrase]),\n\t\t\ttarget_file,\n\t\t)\n\tend",
"def create_map_picture\n @picture = Sprite.new(@viewport)\n @picture.bitmap = Cache.picture(MINIMAP_PICTURE)\n @picture.x = P_X; @picture.y = P_Y\n @picture.opacity = 0\n end",
"def smart_map_image_url map\n if url_responsive? map.image\n map.image\n else\n url = \"http://image.www.gametracker.com/images/maps/160x120/tf2/#{map.name}.jpg\"\n if url_responsive? url\n url\n else\n \"unkown_image.jpg\"\n end\n end\n end",
"def apply_image_transformation?\n true\n end",
"def create\n @map_image = MapImage.new(params[:map_image])\n\n respond_to do |format|\n if @map_image.save\n format.html { redirect_to(@map_image, :notice => 'Map image was successfully created.') }\n format.xml { render :xml => @map_image, :status => :created, :location => @map_image }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @map_image.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_advanced\n image_service = ImageGeneratingService.new(self, 'Advanced.jpg', 'image/jpeg', 69)\n output_path = image_service.generate\n original_size_mb = File.size(output_path).to_f / 2**20\n if original_size_mb > 1.0\n image_service.generate_resized(1200)\n end\n end",
"def get_image_from_pixels(pixels, dimension, map, depth, mime_type); end",
"def image_1_is_from_google?\n !image_1_google_thumb.blank?\n end",
"def visible?(map = nil)\n r = Rectangle.new @x.round + @img_gap.x, @y.round + @img_gap.y, @img[0].width, @img[0].height\n return Rectangle.new(0, 0, G.window.width, G.window.height).intersect? r if map.nil?\n map.cam.intersect? r\n end",
"def create_background_image\n split_tile_set_into_tiles\n create_image_list\n\n montage_cmd = \"montage #{@image_list.join(' ')} \"\n montage_cmd += \"-tile #{@maps[:background][0].size}x \"\n montage_cmd += \"-geometry 32x32+0+0 media/grid_one/full_map_image.png\"\n\n system(\"#{montage_cmd}\")\n\n @background_image = Gosu::Image.new(@window,\n 'media/grid_one/full_map_image.png',\n false)\n\n FileUtils.rm_r Dir.glob('media/tmp/*')\n end",
"def create_image_list\n @image_list = []\n\n iterate_over_each_character_in_array_of_lines(@maps[:background]) do |y,x|\n @map_image_key.each do |key, value|\n if @maps[:background][y][x] == key\n @image_list.push(\"media/tmp/tile#{value}.png\")\n end\n end\n end\n end",
"def create\n @mapimage = Mapimage.new(mapimage_params)\n\n respond_to do |format|\n if @mapimage.save\n format.html { redirect_to @mapimage, notice: 'Mapimage was successfully created.' }\n format.json { render :show, status: :created, location: @mapimage }\n else\n format.html { render :new }\n format.json { render json: @mapimage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def store_finder_map_image\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.div.className(create_ats_regex_string(\"ats-storefindermapimg\")), format_method(__method__))\n end",
"def img_file\n return \"map_\" + symbol.to_s + \"_full\"\n end",
"def create_static_map\n path_array = coordinates_string.split(\"|\")\n\n while path_array.length > 70\n path_array = reductionPath(path_array)\n end\n coordinates_string_temp = \"\"\n path_array.each do |pos|\n # pos_array = pos.split(\",\")\n # lat = pos_array[0].to_f.round(6).to_s\n # lng = pos_array[1].to_f.round(6).to_s\n\n # coordinates_string_temp += \"|#{lat},#{lng}\"\n coordinates_string_temp += \"|#{pos}\"\n end\n \"http://maps.googleapis.com/maps/api/staticmap?path=color:0xc84446ff|weight:2#{coordinates_string_temp}&size=79x79&sensor=false\"\n end",
"def project_image image, leftup\n img = get_image(image)\n if leftup == :left\n img.change_geometry('1!') { |cols, rows, geo_image| geo_image.scale!(cols, rows) }\n elsif leftup == :up\n width = img.columns\n img.change_geometry(\"#{width}x1!\") { |cols, rows, geo_image| geo_image.scale!(cols, rows) }\n elsif\n raise \"project_image: invalid leftup parameter\"\n end\n end",
"def photo\n\t\t@map = GoogleMap::Map.new\n\t\t@map.center = GoogleMap::Point.new(38.06, -84.497631) #Lexington Kentucky\n\t\t@map.zoom = 12 #200km\n\t\t\n\t\t# define control types shown on map\n\t\t@map.controls = [ :large, :scale, :type ]\n\t\t# valid controls options include\n\t\t# :large \n\t\t# :small \n\t\t# :overview\n\t\t# :large_3d\n\t\t# :scale\n\t\t# :type\n\t\t# :menu_type\n\t\t# :hierachical_type\n\t\t# :zoom\n\t\t# :zoom_3d\n\t\t# :nav_label \n\t \t\n\t\t# allow user to double click to zoom\n\t\t@map.double_click_zoom = true\n\t\t\n\t\t# not certain what this does\n\t\t@map.continuous_zoom = false\n\t\t\n\t\t# allow user to scroll using mouse wheel?\n\t\t@map.scroll_wheel_zoom = false\n\t\t\n\t\t#set some markers\n\t\t\n Location.find_each do |loc|\n\t @map.markers << GoogleMap::Marker.new(\n\t :map => @map,\n\t :icon => GoogleMap::SmallIcon.new(@map, 'blue'),\n\t :lat => loc.lat,\n\t :lng => loc.lon,\n\t :html => loc.desc,\n\t :open_infoWindow => false\n\t )\n end\n\t \n end",
"def visible?(map = nil)\n r = Rectangle.new @x, @y, @img[0].width, @img[0].height\n return Rectangle.new(0, 0, G.window.width, G.window.height).intersect? r if map.nil?\n map.cam.intersect? r\n end",
"def create_map\n @map = Sprite.new\n @map.bitmap = Cache.picture(MAP_PICTURE)\n @map.x = M_X\n @map.y = M_Y\n @map.z = 11\n end",
"def smallworld_image(*args, &block)\n Smallworld::Image.define_smallworld_image(*args, &block)\nend",
"def crop_and_save_image( image, ri )\n\n design_template = ri.version.design_template\n image_name = ri.image_name\n path = ri.get_path\n\n height = get_original_height( design_template, image_name )\n width = get_original_width( design_template, image_name )\n\n image = resize_with_crop( image, width.to_f, height.to_f )\n\n image.format 'png'\n # Any name will do, the AI script will just place all of the images\n # found in the collage folder.\n full_path = path + '/image.png'\n image.write( full_path )\n return true\n end",
"def preview\n @map = Map.new mapParams\n @map.name = \"preview\"\n image = @map.to_wms_query_string(type: 'image/jpeg', ext: '.jpg')\n \n render :json => {success: true, cachedImage: image, width: @map.width, height: @map.height}, :layout => false\n end",
"def show_image\n temp_floor_tile = Image.new('tiles\\tile_floor_1.png')\n hex_width = temp_floor_tile.width - 6\n hex_height = temp_floor_tile.width - 4\n temp_floor_tile.remove\n @hexArray.each_with_index do | line, x |\n bottom_y = hex_height * 11\n y_start = bottom_y - (11 - line.size) * (hex_height / 2)\n line.each_with_index do | hex, y |\n cur_x = x * hex_width\n cur_y = y_start - y * hex_height\n\n case hex.type\n when Hex::FLOOR_TYPE\n Image.new('tiles\\tile_floor_1.png', x:cur_x, y:cur_y)\n when Hex::LAVA_TYPE\n Image.new('tiles\\tile_liquid_1.png', x:cur_x, y:cur_y)\n when Hex::EXIT_TYPE\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n Image.new('tiles\\dung_ladderdown.png', x:cur_x, y:cur_y)\n else\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n end\n if hex.contained_object != nil && hex.contained_object.type == MovingObject::PLAYER_TYPE\n Image.new('tiles\\player.png', x:cur_x, y:cur_y)\n end\n end\n end\n end",
"def image_work?\n true\n end",
"def raster_file?\n false\n end",
"def capsule_map_path(count, world)\n \"#{world.urls[:images]}/map/npczahl#{count}.gif\"\n end",
"def gmaps4rails_marker_picture\n {\n \"rich_marker\" => \"<div class='my-marker'>It works!<img height='30' width='30' src='http://farm4.static.flickr.com/3212/3012579547_097e27ced9_m.jpg'/></div>\"\n }\nend",
"def photograph?\n true\n end",
"def set_mapimage\n @mapimage = Mapimage.find(params[:id])\n end",
"def image\n [:MANAGED_MAP, :UNMANAGED_MAP].each do |map|\n unless self.class.const_defined?(map)\n raise MapUndefined, \"Const #{map} is undefined; maps appear unbuilt\"\n end\n end\n\n map = @managed ? self.class::MANAGED_MAP : self.class::UNMANAGED_MAP\n distro = @distro.downcase.to_sym\n\n unless map[distro].nil?\n return map[distro][@version] unless map[distro][@version].nil?\n return map[distro][\"*\"] unless map[distro][\"*\"].nil?\n end\n\n nil\n end",
"def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end",
"def fetch_map_preview(latitude, longitude, zoom)\n tile = get_tile_number(latitude, longitude, zoom)\n api_url = \"http://tile.openstreetmap.org/#{zoom}/#{tile[:x]}/#{tile[:y]}.png\"\n file_name = \"#{latitude}_#{longitude}_#{zoom}.png\"\n File.new(file_name, File::CREAT)\n Down::NetHttp.download(api_url, destination: \"./#{file_name}\")\n\n file_name\nend",
"def computeProjection\n w,h = @type==:vertical ? [@image.width, @image.height] : [@image.height, @image.width]\n mw,mh = @type==:vertical ? [@image.width, @image.height-@image.borders.bottom] : [@image.height, @image.width-@image.borders.right]\n content_mask = Array.new(w){[false, 0]}\n\n w.times do |a|\n obj_height = 0\n gap = 0\n (h-mh).times do |b|\n x,y = @type==:vertical ? [a,b] : [b,a]\n idx = @image.index(x, y)\n #p [idx, w, h, mh, a, b, x, y, @image.width, @image.height]\n if @data[idx] <= @threshold\n obj_height += 1\n obj_height += gap if gap <= @image.min_obj_size\n gap = 0\n else\n gap += 1\n content_mask[a] = [true, b] if obj_height > @image.min_obj_size\n obj_height = 0\n end\n end\n end\n\n content_mask\n end",
"def png_path\n path = @path[0...@path.length - 3] + 'png'\n path_remote = @path_remote[0...@path_remote.length - 3] + 'png'\n File.exists?(path) ? path_remote : 'https://maps.avicus.net' + '/default_map.png' # May need configured\n end",
"def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end",
"def gv_make_image(name=nil)\n return unless gv_object\n name = gv_object.name unless name\n file = \"#{name}.png\"\n gv_object.output(:png => file)\n file\n end",
"def draw_map game_map\r\n tiles = game_map.tiles # 2d array of the tiles set!\r\n wooden_plank_image = game_map.wooden_plank # image of the wooden plank \r\n i = 0\r\n j = 0\r\n unit_width = 20\r\n unit_height = 20\r\n\r\n # drawing the background image of the game map\r\n #game_map.background.draw(0,0,0) # 0: for x position, 0: for y position, 0: for ZOrder\r\n\r\n height = tiles.length\r\n width = tiles[0].length\r\n\r\n while i < height\r\n j = 0\r\n while j < width\r\n if(tiles[i][j]==1 || tiles[i][j]==3)\r\n x = j * unit_width\r\n y = i * unit_height\r\n draw_plank(x, y, wooden_plank_image)\r\n j+=4 # increment the value of the j by 4 to skip the next 4 blocks\r\n end\r\n j+=1\r\n end\r\n i+=1\r\n end\r\n\r\nend",
"def new_image?\n @new_image\n end",
"def add_image \n image = CARMD.image(self.vin)\n if image == \"\"\n image = \"http://clipart-library.com/img/2050778.png\"\n end\n self.auto_image = image \n self.save \n end",
"def create_worldmap\n @pokemon_worldmap = GamePlay::WorldMap.new(:pokedex, $env.get_worldmap)\n @pokemon_worldmap.create_graphics\n end",
"def imagemagick7?; end",
"def robot_image_generator\n img_base_url = 'https://robohash.org/'\n @robot.img_sm = img_base_url + @robot.robot_name + '?size=80x80'\n @robot.img_lg = img_base_url + @robot.robot_name + '?size=300x300'\n end",
"def imagemagick?; end",
"def to_tex\n q_url = \"http://dream.misasa.okayama-u.ac.jp/?q=\"\n basename = File.basename(image.name,\".*\")\n lines = []\n lines << \"\\\\begin{overpic}[width=0.49\\\\textwidth]{#{basename}}\"\n lines << \"\\\\put(1,74){\\\\colorbox{white}{(\\\\sublabel{#{basename}}) \\\\href{#{q_url}#{image.global_id}}{#{basename}}}}\"\n lines << \"%%(\\\\subref{#{basename}}) \\\\nolinkurl{#{basename}}\"\n lines << \"\\\\color{red}\"\n\n surface.surface_images.each do |osurface_image|\n oimage = osurface_image.image\n #image_region\n opixels = oimage.spots.map{|spot| [spot.spot_x, spot.spot_y]}\n worlds = oimage.pixel_pairs_on_world(opixels)\n pixels = image.world_pairs_on_pixel(worlds)\n oimage.spots.each_with_index do |spot, idx|\n length = image.length\n height = image.height\n x = \"%.1f\" % (pixels[idx][0] / length * 100)\n y = \"%.1f\" % (height.to_f / length * 100 - pixels[idx][1] / length * 100)\n line = \"\\\\put(#{x},#{y})\"\n line += \"{\\\\footnotesize \\\\circle{0.7} \\\\href{#{q_url}#{spot.target_uid}}{#{spot.name}}}\"\n line += \" % #{spot.target_uid}\" if spot.target_uid\n line += \" % \\\\vs(#{(\"%.1f\" % worlds[idx][0])}, #{(\"%.1f\" % worlds[idx][1])})\"\n lines << line\n end\n end\n\n width_on_stage = image.transform_length(image.width / image.length * 100)\n scale_length_on_stage = 10 ** (Math::log10(width_on_stage).round - 1)\n scale_length_on_image = image.transform_length(scale_length_on_stage, :world2xy).round\n lines << \"%%scale #{(\"%.0f\" % scale_length_on_stage)}\\ micro meter\"\n lines << \"\\\\put(1,1){\\\\line(1,0){#{(\"%.1f\" % scale_length_on_image)}}}\"\n\n lines << \"\\\\end{overpic}\"\n\n lines.join(\"\\n\")\n end",
"def contains_png?\n contains_images? and @url =~ /p\\z/i\n end",
"def render_tiled_image gcode, gmask\n debug \"rendering tiled image\"\n job_id = job_hash\n hyst = -@scale[0]/2\n gcode.comment \"raster gcode for job #{job_id}\"\n gcode.comment \"image: #{@image.filename} #{@image.size.inspect}\"\n gcode.comment \"config: #{@config.inspect}\"\n\n gcode.preamble :feed => @config[:feed], :mask => true\n gmask.preamble\n\n @config[:repeat][1].times do |ytile|\n debug \"begin tile row #{ytile}\"\n @tiled_rows.each_with_index do |spans, ypix|\n debug \"pixel row #{ypix} is empty\" if spans.empty?\n unless spans.empty?\n yinches = y_inches(ytile, ypix)\n forward = spans[0][0] < spans[-1][1]\n dir = forward ? 1 : -1\n\n debug \"pixel row #{ypix} at #{yinches} inches going #{forward ? 'forward' : 'backward'} with #{spans.size} spans\"\n\n gcode.g0 :x => spans[0][0] - dir*@config[:overshoot], :y => yinches\n gcode.g1 :x => spans[-1][1] + dir*@config[:overshoot], :y => yinches\n gmask.begin_row forward\n spans.each {|span| gmask.span forward, span[0]+hyst, span[1]+hyst }\n end # unless spans.empty?\n end # @image.each_row\n debug \"end tile row #{ytile}\"\n end # @config[:repeat][i].times\n\n gcode.epilogue\n end",
"def image?\n image ? true : false\n end",
"def convert_to_img\n\t\t\t`gs -sDEVICE=png16m '-r#{OCR::MIN_DENSITY}' -o '#{@image}' '#{@input_file}'`\n\t\tend",
"def create_static_map\n legs = @itinerary.legs\n markers = create_markers\n polylines = create_polylines\n\n params = {\n 'size' => '700x435',\n 'maptype' => 'roadmap',\n }\n\n iconUrls = {\n 'blueMiniIcon' => 'https://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle_blue.png',\n 'startIcon' => 'http://maps.google.com/mapfiles/dd-start.png',\n 'stopIcon' => 'http://maps.google.com/mapfiles/dd-end.png'\n }\n\n markersByIcon = markers.group_by { |m| m[\"iconClass\"] }\n\n url = \"https://maps.googleapis.com/maps/api/staticmap?\" + params.to_query\n markersByIcon.keys.each do |iconClass|\n marker = '&markers=icon:' + iconUrls[iconClass]\n markersByIcon[iconClass].each do |icon|\n marker += '|' + icon[\"lat\"].to_s + \",\" + icon[\"lng\"].to_s\n end\n url += URI::encode(marker)\n end\n\n polylines.each do |polyline|\n color = polyline['options']['color'].nil? ? \"0000ff\" : polyline['options']['color']\n url += URI::encode(\"&path=color:0x#{color}|weight:5|enc:\" + polyline['geom']['points'])\n end\n url += \"&key=#{ENV['GOOGLE_API_KEY']}\"\n return url\n end",
"def extract_graphic\n if !Cache.screenshot(@save_number, header).nil?\n bitmap_screenshot = Cache.screenshot(@save_number, header)\n @screenshot.zoom_x = 2\n @screenshot.zoom_y = 2\n else @virtualb = DataManager.load_screenshot(@save_number)\n if @virtualb.nil?\n bitmap_screenshot = black_bitmap\n else\n bitmap_screenshot = @virtualb.get_bitmap\n @screenshot.zoom_x = 2\n @screenshot.zoom_y = 2\n Cache.add_screenshot(@save_number, bitmap_screenshot, header[:key])\n end\n end\n @screenshot.bitmap = bitmap_screenshot\n @screenshot_loaded = false\n @loading_bar.disappear\n end",
"def render_tiled_image gcode, gmask\n debug \"rendering tiled image\"\n job_id = job_hash\n hyst = -@scale[0]/2\n gcode.comment \"raster gcode for job #{job_id}\"\n gcode.comment \"image: #{@image.filename} #{@image.size.inspect}\"\n gcode.comment \"config: #{@config.inspect}\"\n\n gcode.preamble :feed => @config[:feed], :mask => true\n gmask.preamble\n\n @config[:repeat][1].times do |ytile|\n debug \"begin tile row #{ytile}\"\n ypix = 0\n (0...@tiled_rows).each do |spans|\n debug \"pixel row #{ypix} is empty\" if spans.empty?\n unless spans.empty?\n yinches = y_inches(ytile, ypix)\n forward = spans[0][0] < spans[-1][1]\n dir = forward ? 1 : -1\n\n debug \"pixel row #{ypix} at #{yinches} inches going #{forward ? 'forward' : 'backward'} with #{spans.size} spans\"\n\n gcode.g0 :x => spans[0][0] - dir*@config[:overshoot], :y => yinches\n gcode.g1 :x => spans[-1][1] + dir*@config[:overshoot], :y => yinches\n gmask.begin_row forward\n spans.each {|span| gmask.span forward, span[0]+hyst, span[1]+hyst }\n end # unless spans.empty?\n ypix += 1\n end # @image.each_row\n debug \"end tile row #{ytile}\"\n end # @config[:repeat][i].times\n\n gcode.epilogue\n end",
"def image?\n marc_leader_06_k_match = record.leader.byteslice(6) == 'k'\n\n marc_leader_06_g_match = record.leader.byteslice(6) == 'g'\n marc_008_33_match = record.fields('008').find do |field|\n %w[a c i k l n p s t].include?(field.value.byteslice(33))\n end\n\n marc_006_match = record.fields('006').find do |field|\n field.value.byteslice(0) == 'k' ||\n (field.value.byteslice(0) == '6' &&\n %w[a c i k l n p s t].include?(field.value.byteslice(16)))\n end\n\n return true if marc_leader_06_k_match ||\n (marc_leader_06_g_match && marc_008_33_match) ||\n marc_006_match\n end",
"def draw_custom_image\r\r\n bitmap = Cache.picture($game_map.ach_display.graphic)\r\r\n rect = Rect.new(0,0,bitmap.width,bitmap.height)\r\r\n target = Rect.new(0,0,contents.width,contents.height)\r\r\n contents.stretch_blt(target, bitmap, rect, 255)\r\r\n end",
"def has_images?\n @has_images ||= !@drawings.empty?\n end",
"def get_image(sf_step)\n sheet = @sheet_class.new\n sheet[1, 1] = 'Single Form Learning'\n # Construct and add Grammar Test information\n test_image = @grammar_test_image_maker.get_image(sf_step.test_result)\n sheet.append(test_image)\n sheet\n end",
"def graphicsmagick?; end",
"def create\n @loc_image = LocImage.new(loc_image_params)\n\n respond_to do |format|\n if @loc_image.save\n format.html { redirect_to @loc_image, notice: 'Loc image was successfully created.' }\n format.json { render action: 'show', status: :created, location: @loc_image }\n else\n format.html { render action: 'new' }\n format.json { render json: @loc_image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def image?\n !!image\n end",
"def grid_image\n s = ''\n s << \" %s %s %s \\n\" % [own(256), own(128), own(64)]\n s << \" %s %s %s \\n\" % [own(32), own(16), own(8)]\n s << \" %s %s %s \\n\" % [own(4), own(2), own(1)]\n s\n end",
"def image_gel gel, image_name\n show do\n title \"Image gel #{gel}\"\n check \"Clean the transilluminator with ethanol.\"\n check \"Put the gel #{gel} on the transilluminator.\"\n check \"Turn off the room lights before turning on the transilluminator.\"\n check \"Put the camera hood on, turn on the transilluminator and take a picture using the camera control interface on computer.\"\n check \"Check to see if the picture matches the gel before uploading.\"\n check \"Rename the picture you just took exactly as <b>#{image_name}</b>.\"\n end\n end",
"def get_map(building, array_of_buildings_nearby)\n each_result = array_of_buildings_nearby.map { |building| \"markers=color:green%7Clabel:%7C#{building.latitude},#{building.longitude}&\" }\n map_from_google = \"http://maps.googleapis.com/maps/api/staticmap?center=#{building.latitude},#{building.longitude}&zoom=13&size=1300x1000&maptype=roadmap&markers=color:red%7Clabel:%7C#{building.latitude},#{building.longitude}&\"+each_result.join+\"sensor=false&key=#{GOOGLE_CLIENT_ID}\"\n return map_from_google\n end",
"def generate_inspire_image(image_path)\n # first empty the inspire folder\n FileUtils.rm_rf(\"#{image_for('', 'mobile_inspire')}/.\", secure: true)\n FileUtils.rm_rf(\"#{image_for('', 'desktop_inspire')}/.\", secure: true)\n image = Gg::ImageProcessing.new(\"#{satellitedir}/#{image_path}\")\n i_name = image_path.split('/').last\n image.generate(image_for(i_name, 'desktop_inspire'), 'desktop')\n image.generate(image_for(i_name, 'mobile_inspire'), 'mobile')\n end",
"def build_maps\n build_image_maps\n build_flavor_maps\n end",
"def convert_standalone_image(el, _opts, img); end",
"def raster_work?\n false\n end",
"def is_small_imageable?\n return true\n end",
"def image(key, image_path)\n # Idea from here http://itext.ugent.be/library/question.php?id=31 \n # Thanks Bruno for letting me know about it.\n img = @image_class.getInstance(image_path)\n img_field = @form.getFieldPositions(key.to_s)\n\n \n rect = @rectangle.new(img_field[1], img_field[2], img_field[3], img_field[4])\n img.scaleToFit(rect.width, rect.height)\n img.setAbsolutePosition(\n img_field[1] + (rect.width - img.getScaledWidth) / 2,\n img_field[2] + (rect.height - img.getScaledHeight) /2\n )\n\n cb = @stamp.getOverContent(img_field[0].to_i)\n cb.addImage(img)\n end",
"def _minimap_autotile\n b = Bitmap.new(24, 32)\n c1 = Color.new(191, 191, 191)\n c2 = Color.new(255, 255, 255)\n b.fill_rect(2, 0, 4, 1, c2)\n b.set_pixel(1, 1, c2)\n b.fill_rect(2, 1, 4, 6, c1)\n b.set_pixel(6, 1, c2)\n b.fill_rect(0, 2, 1, 4, c2)\n b.fill_rect(1, 2, 1, 4, c1)\n b.fill_rect(6, 2, 1, 4, c1)\n b.fill_rect(7, 2, 1, 4, c2)\n b.set_pixel(1, 6, c2)\n b.set_pixel(6, 6, c2)\n b.fill_rect(2, 7, 4, 1, c2)\n b.fill_rect(7, 8, 10, 1, c2)\n b.set_pixel(6, 9, c2)\n b.fill_rect(7, 9, 10, 22, c1)\n b.set_pixel(17, 9, c2)\n b.set_pixel(5, 10, c2)\n b.fill_rect(6, 10, 1, 20, c1)\n b.fill_rect(17, 10, 1, 20, c1)\n b.set_pixel(18, 10, c2)\n b.set_pixel(4, 11, c2)\n b.fill_rect(5, 11, 1, 18, c1)\n b.fill_rect(18, 11, 1, 18, c1)\n b.set_pixel(19, 11, c2)\n b.set_pixel(3, 12, c2)\n b.fill_rect(4, 12, 1, 16, c1)\n b.fill_rect(19, 12, 1, 16, c1)\n b.set_pixel(20, 12, c2)\n b.set_pixel(2, 13, c2)\n b.fill_rect(3, 13, 1, 14, c1)\n b.fill_rect(20, 13, 1, 14, c1)\n b.set_pixel(21, 13, c2)\n b.set_pixel(1, 14, c2)\n b.fill_rect(2, 14, 1, 12, c1)\n b.fill_rect(21, 14, 1, 12, c1)\n b.set_pixel(22, 14, c2)\n b.fill_rect(0, 15, 1, 10, c2)\n b.fill_rect(1, 15, 1, 10, c1)\n b.fill_rect(22, 15, 1, 10, c1)\n b.fill_rect(23, 15, 1, 10, c2)\n b.set_pixel(1, 25, c2)\n b.set_pixel(22, 25, c2)\n b.set_pixel(2, 26, c2)\n b.set_pixel(21, 26, c2)\n b.set_pixel(3, 27, c2)\n b.set_pixel(20, 27, c2)\n b.set_pixel(4, 28, c2)\n b.set_pixel(19, 28, c2)\n b.set_pixel(5, 29, c2)\n b.set_pixel(18, 29, c2)\n b.set_pixel(6, 30, c2)\n b.set_pixel(17, 30, c2)\n b.fill_rect(7, 31, 10, 1, c2)\n return b\n end",
"def has_image?\n false\n end",
"def image_copy(another_image)\n\n java_import Java::edu.stanford.cfuller.imageanalysistools.image.ImageFactory\n\n ImageFactory.create(another_image)\n\n end",
"def generate_image_location(id, page_number)\n generate_build_location \"#{@config.image_directory_name}/#{id}-#{page_number}\"\n end",
"def create\n @artwork_image_map = ArtworkImageMap.new(artwork_image_map_params)\n\n respond_to do |format|\n if @artwork_image_map.save\n format.html { redirect_to @artwork_image_map, notice: 'Artwork image map was successfully created.' }\n format.json { render :show, status: :created, location: @artwork_image_map }\n else\n format.html { render :new }\n format.json { render json: @artwork_image_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createImageSource\n if !self.imageSource\n # Compose absolute URL to file.\n sourceURL = self.url.absoluteURL\n if sourceURL == nil\n return false\n end\n \n # Create a CGImageSource from the URL.\n imageSource = CGImageSourceCreateWithURL(sourceURL, nil)\n if imageSource == nil\n return false\n end\n \n imageSourceType = CGImageSourceGetType(imageSourceType)\n if imageSourceType == nil\n return false\n end\n \n return true\n \n end\n end",
"def greyScale? \n\t\treturn @image.grey? \n\tend",
"def can_render_images_on?\n self.ppi && self.resolution_x && self.resolution_y\n end",
"def generate_images_for(image_filename)\n source_image_path = source_path_of_file(image_filename)\n if source_image_path\n imgsrcbasename = File.basename(source_image_path, '.*').gsub(' ', '_')\n imgsrcextname = File.extname(source_image_path)\n FileUtils.mkdir_p(@asset_path)\n\n PROFILES.each do |profile|\n non_retina_dest_pathname = File.join(\n @asset_path,\n \"#{imgsrcbasename}-#{profile[:width]}#{imgsrcextname.downcase}\")\n retina_dest_pathname = File.join(\n @asset_path,\n \"#{imgsrcbasename}-#{profile[:width]}@2x#{imgsrcextname.downcase}\")\n\n unless File.exists?(non_retina_dest_pathname)\n # \\> will resize only larger-to-smaller\n system \"convert \\\"#{source_image_path}\\\" -quality #{profile[:quality]} \"\\\n \"-strip -interlace Plane -resize #{profile[:width]}x#{profile[:height]}\\\\> \"\\\n \"\\\"#{non_retina_dest_pathname}\\\"\"\n end\n unless File.exists?(retina_dest_pathname)\n system \"convert \\\"#{source_image_path}\\\" -quality #{profile[:quality]} \"\\\n \"-strip -interlace Plane -resize #{profile[:width] * 2}x#{profile[:height] * 2}\\\\> \"\\\n \"\\\"#{retina_dest_pathname}\\\"\"\n end\n end\n return true\n end\n @missing_images << image_filename if image_filename\n false\n end",
"def create image_url, page_url, x, y, h, w\n #@img = Img.create(image_url: image_url, page_url: page_url, x: x, y: y, h: h, w: w)\n end",
"def image(key, image_path, options = {})\n # Idea from here http://itext.ugent.be/library/question.php?id=31 \n # Thanks Bruno for letting me know about it.\n img = Image.get_instance(image_path)\n coords = @form.get_field_positions(key.to_s)\n rect = coords[0].position\n img.set_absolute_position(rect.left, rect.bottom)\n img.scale_to_fit(rect)\n image_content = @stamp.get_over_content(options.fetch(:page, 1))\n image_content.add_image(img)\n end",
"def resize_image(image_string, dest)\n image = Gg::ImageProcessing.new(image_string)\n i_name = dest.split('/').last\n image.blob_generate(project.image_for(i_name, 'show'))\n image.blob_generate(project.image_for(i_name, 'show_image_desk'), 'desktop')\n image.blob_generate(project.image_for(i_name, 'show_image_mob'), 'mobile')\n end",
"def render_cassette\n image = render_mutant_region( @construct.cassette_features, :label => @construct.cassette_label )\n\n # Construct the annotation image\n image_list = Magick::ImageList.new\n annotation_image = Magick::Image.new( image.columns, @annotation_height )\n\n # Stack the images\n image_list.push( annotation_image )\n image_list.push( image )\n\n return image_list.append( true )\n end",
"def image; end",
"def check_map\n begin\n @map_cells_range.each do |y|\n @map_cells_range.each do |x|\n if @tiles[x].nil? || @tiles[x][y].nil?\n raise RuntimeError, \"tile #{x},#{y} not found, regenerate the map\"\n end\n end\n end\n rescue RuntimeError => e\n error e.message\n generate_map\n return false\n end\n true\n end",
"def create_region_display_tilemap\n # Create Region Tileset\n Cache.create_region_tileset_bitmap \n # Create Region Tilemap\n @region_tilemap = Tilemap.new(@viewport1)\n @region_tilemap.map_data = $game_map.data.dup\n @region_tilemap.flags = Table.new(8192)\n # Make Region Tilemap Invisible\n @region_tilemap.visible = false\n # Set Region Tilemap Flags (Over Character [?])\n 64.upto(128) {|n| @region_tilemap.flags[n] = 0x10} \n # Go Through Game Map Tiles\n $game_map.data.xsize.times {|x|\n $game_map.data.ysize.times {|y|\n # Clear Region Tilemap Info\n 4.times {|z| @region_tilemap.map_data[x, y, z] = 0}\n # Get Region ID\n region_id = $game_map.region_id(x, y)\n # Get Passability Flags\n flag1 = $game_map.tileset.flags[$game_map.data[x, y, 2]] \n # If Region ID is 0 or more\n if region_id > 0\n next @region_tilemap.map_data[x, y, 2] = 64 + region_id if flag1 > 16 and flag1 & 0x10 != 0\n @region_tilemap.map_data[x, y, 2] = region_id \n else \n next @region_tilemap.map_data[x, y, 2] = 64 if flag1 > 16 and flag1 & 0x10 != 0\n next @region_tilemap.map_data[x, y, 1] = 64 \n end \n }\n }\n # Set Region Tilemap Bitmap (Tile B)\n @region_tilemap.bitmaps[5] = Cache.region_tileset_bitmap\n # Update Region Tilemap\n update_region_tilemap\n end",
"def polyline_image(polyline, size = 150, color = \"blue\")\n image_tag(polyline_map_url(polyline, size, color),\n alt: \"Activity map\")\n end",
"def has_image?(image)\n # FIXME\n true\n end",
"def is_processed_image? picture\n model.class.to_s.underscore == \"pimage\"\n end",
"def generate_image\n matrix_values = compute_values\n max, min = matrix_values.max.to_f, matrix_values.min.to_f\n \n hue_range = HeatPalette::HSL_HUE_MAX - HeatPalette::HSL_HUE_MIN\n matrix_scaled = ((matrix_values - min)*(hue_range-1)/(max-min)).round\n \n contours_values = explicit_range(min..max, @contours).drop(1)\n contours_scaled = contours_values.map{|e| ((e - min)*(hue_range-1)/(max-min)).round}\n rainbow = colorines(contours_scaled)\n \n @metadata[\"max_value\"] = max\n @metadata[\"min_value\"] = min\n @metadata[\"contours_values\"] = contours_values\n \n legend_stream = rainbow.map{|e| ChunkyPNG::Color.from_hex(e)}\n \n @legend = ChunkyPNG::Image.new(hue_range, LEGEND_HEIGHT, legend_stream*LEGEND_HEIGHT)\n \n stream = matrix_scaled.flatten.to_a\n stream.map!{|e| ChunkyPNG::Color.from_hex(\"#{rainbow[e]}\")}\n @img = ChunkyPNG::Image.new(@width, @height, stream).rotate_counter_clockwise\n end",
"def image(hash={})\n\t\tif hash['id'] =~ /nsys|Hand|Arm|Leg|Eye|back|abdomen|chest|head|neck/o\n\t\t\tStatus.sf_update(hash['id'], hash['name'])\n\t\tend\n\tend",
"def link_to_map(address, *args)\n\n options = args.extract_options!\n options[:width] ||= 100\n options[:height] ||= 100\n\n image = image_tag(\"http://maps.googleapis.com/maps/api/staticmap?center=#{address.latitude},#{address.longitude}&zoom=11&size=#{options[:width]}x#{options[:height]}&sensor=false\")\n link_to image, \"http://maps.google.com/maps?q=#{address.latitude},#{address.longitude}&hl=en\", class: 'thumbnail', target: :_blank\n\n end",
"def set_image(image_file_name)\n\t\t\tbegin\n\t\t\t\t@image = ImageList.new(image_file_name)\n\t\t\t\t@file_name = \"#{File.dirname(image_file_name)}/scanned_#{File.basename(image_file_name)}\"\n\t\t\t\t@image.normalize.resize!(50,50).threshold(MaxRGB*0.55).write(@file_name)\n\t\t\t\t@image = ImageList.new(@file_name)\n\t\t\t\treturn true if scan\n\t\t\t\treturn false\n\t\t\trescue\n\t\t\t\traise InvalidImage, \"Invalid image - could not be processed by RMagick\"\n\t\t\tend\n\t\tend",
"def save_to_file image\n File.open('uml.png', 'wb') do |file|\n file << image.body\n end if image\n end"
] |
[
"0.65212107",
"0.6318531",
"0.60746366",
"0.6005758",
"0.5996662",
"0.59701306",
"0.59648114",
"0.58217037",
"0.5816226",
"0.57740957",
"0.57737017",
"0.57700574",
"0.5730569",
"0.5672069",
"0.5645524",
"0.5635373",
"0.56217074",
"0.55699897",
"0.5561187",
"0.55515546",
"0.5516033",
"0.55058396",
"0.54869735",
"0.54038244",
"0.53693444",
"0.53667045",
"0.5361492",
"0.5359839",
"0.5348461",
"0.5326538",
"0.5317894",
"0.5314005",
"0.5288562",
"0.5285575",
"0.5277422",
"0.52586",
"0.52398235",
"0.523097",
"0.5209144",
"0.52083576",
"0.52075696",
"0.52068675",
"0.5198509",
"0.5184518",
"0.5175042",
"0.51744777",
"0.517326",
"0.51579654",
"0.51483595",
"0.5146851",
"0.51328045",
"0.5124385",
"0.51082855",
"0.50900996",
"0.50888544",
"0.50775796",
"0.5070352",
"0.5069915",
"0.5069376",
"0.5068185",
"0.5064766",
"0.50575787",
"0.50524116",
"0.50474393",
"0.5040542",
"0.503723",
"0.5035204",
"0.50343865",
"0.5028679",
"0.5025422",
"0.500649",
"0.49967837",
"0.49936906",
"0.49890688",
"0.49847093",
"0.49810874",
"0.49797496",
"0.4976647",
"0.49739173",
"0.4963439",
"0.49484292",
"0.49479535",
"0.49458772",
"0.4944564",
"0.49389493",
"0.49389422",
"0.49388173",
"0.49374732",
"0.4937268",
"0.49354574",
"0.49350116",
"0.4932908",
"0.49316218",
"0.49258482",
"0.49226627",
"0.49225146",
"0.4922396",
"0.49118516",
"0.49036795",
"0.48961315"
] |
0.64696825
|
1
|
get x,y tiles for all tiles at maximum zoom level 1 down to zoom level 0 (1 tile)
|
def get_tiles
tiles = []
accuracy_pixels_config = AppConfig.gmap_accuracy
(0...AppConfig.gmap_max_zoom).reverse_each do |zoom|
tiles_across = 2**zoom
# the accuracy will go down by half at each zoom level with a floor of 1 i.e. 8 => 4, 7 => 2, 6 => 1, 5 => 1, 4 => 1
accuracy_pixels = (accuracy_pixels_config.to_f / 2**(AppConfig.gmap_max_zoom - zoom).to_f ).ceil
tiles_at_zoom = (0...tiles_across).map { |x| (0...tiles_across).map { |y| OpenStruct.new(:x => x, :y => y, :zoom => zoom, :accuracy_pixels => accuracy_pixels) } }.flatten(1)
tiles.concat tiles_at_zoom
end
tiles
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def google_tile(tx, ty, zoom)\n [tx, (2**zoom - 1) - ty]\n end",
"def tile_bounds(tx, ty, zoom)\n min_x, min_y = pixels_to_meters(tx * @tile_size, ty * @tile_size, zoom)\n max_x, max_y = pixels_to_meters((tx + 1) * @tile_size, (ty + 1) * @tile_size, zoom)\n [min_x, min_y, max_x, max_y]\n end",
"def tiles_at(x, y)\n @layers[:tile_layers].map { |_, tiles| tiles[y][x] }.compact\n end",
"def tiles\n return @tiles\n end",
"def tiles\n return @tiles\n end",
"def all_tiles(x, y)\n newTilePoint = map_tile_adjust_xy(x, y)\n tile_events_xy(newTilePoint.x, newTilePoint.y).collect {|ev| ev.tile_id } + layered_tiles(x, y)\n end",
"def tiles\n @tiles\n end",
"def tile_bounds\n tile = tile_number\n zoom = zoom_level\n sw = ::GeoMonitor::LatLngPoint.from_number(tile[:x], tile[:y], zoom).to_3857\n ne = ::GeoMonitor::LatLngPoint.from_number(tile[:x] + 1, tile[:y] - 1, zoom).to_3857\n self.class.new(\n north: ne.lat,\n east: ne.lng,\n south: sw.lat,\n west: sw.lng\n )\n end",
"def visible_tiles\n frame_x = (((@width - Config::TileWidth) / Config::TileWidth) ).to_i\n frame_y = (((@height - Config::TileHeight) / Config::TileHeight) ).to_i\n \n \n start_x = player.location.x - (frame_x / 2).to_i\n start_y = player.location.y - (frame_y / 2).to_i\n \n if start_x < 0\n start_x = 0\n end\n if start_y < 0\n start_y = 0\n end\n \n tiles = Array.new\n \n frame_x.times do |i|\n frame_y.times do |j|\n if (start_x + i < game.map.width ) && (start_y + j < game.map.height )\n # puts(\"start_x is #{start_x} and start_y is #{start_y} and i is #{i} and j is #{j}\")\n tiles << game.map.locations[start_x + i, start_y + j]\n end\n end\n end\n \n tiles\n \n end",
"def meters_to_tile(mx, my, zoom)\n px, py = meters_to_pixels(mx, my, zoom)\n pixels_to_tile(px, py)\n end",
"def tile_at x,y\n return nil if x < 0 || y < 0 || x >= @width || y >= @height\n return @map[x][y] \n end",
"def each_tile level\n\t\t\tsize = tile_size level\n\t\t\t(0...size).each do |y|\n\t\t\t\t(0...size).each do |x|\n\t\t\t\t\tyield(x, y) if block_given?\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def layered_tiles(x, y)\n newTilePoint = map_tile_adjust_xy(x, y)\n [2, 1, 0].collect {|z| tile_id(newTilePoint.x, newTilePoint.y, z) }\n end",
"def get_grids(x, y, width, height)\n x = (x*10)-5\n y = (y*10)-5\n end_x= x+(width*10)-1\n end_y= y+(height*10) -1\n return [[y, x], [end_y, end_x]]\n end",
"def get_grids(x, y, width, height)\n x = (x*10)-5\n y = (y*10)-5\n end_x= x+(width*10)-1\n end_y= y+(height*10) -1\n return [[y, x], [end_y, end_x]]\n end",
"def tile_at(x, y)\n tiles_at(x, y).last\n end",
"def tile\n tile_at(@position)\n end",
"def pixels_to_raster(px, py, zoom)\n map_size = @tile_size << zoom\n [px, map_size - py]\n end",
"def tile(x, y)\n\n @tiles[x][y]\n end",
"def tile_lon_lat_bounds(tx, ty, zoom)\n bounds = tile_bounds(tx, ty, zoom)\n min_lon, min_lat = meters_to_lon_lat(bounds[0], bounds[1])\n max_lon, max_lat = meters_to_lon_lat(bounds[2], bounds[3])\n\n [min_lon, min_lat, max_lon, max_lat]\n end",
"def tiles\n @shape.values.map { |v| v.values }.flatten.select {|x| x != :empty}\n end",
"def each_tile_with_index level\n\t\t\tidx = 0\n\t\t\tsize = tile_size level\n\t\t\t(0...size).each do |y|\n\t\t\t\t(0...size).each do |x|\n\t\t\t\t\tyield(x, y, idx) if block_given?\n\t\t\t\t\tidx += 1\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def tile(y, x, matrix)\n matrix[y - 1 .. y + 1].map {|line| line[x - 1 .. x + 1]}\n end",
"def initialize(width, height, tile_width, tile_height)\n @max_tile_x = width/tile_width\n @max_tile_y = height/tile_height\n @max_subgrid_x = (width/tile_width)*3\n @max_subgrid_y = (height/tile_height)*3\n @tiles = Array.new(max_tile_y) {|i| Array.new(max_tile_x)}\n end",
"def surrounding_tiles(x, y)\n diffs = [\n [-1, -1], [0, -1], [1, -1],\n [-1, 0], [0, 0], [1, 0],\n [-1, 1], [0, 1], [1, 1],\n ]\n\n diffs.map { |dx, dy| tiles_at(x + dx, y + dy) }.flatten\n end",
"def all_tiles\n\t\t@entities.sort!\n\t\t\n\t\tall_tiles = @map_tiles + @entities\n\t\tall_tiles\n\tend",
"def _cell_zoom\r\n @x = params[:x]\r\n @y = params[:y]\r\n @otu = Otu.find(params[:otu_id])\r\n @chr = Chr.find(params[:chr_id])\r\n @confidences = @proj.confidences\r\n @mx = Mx.find(params[:mx_id])\r\n end",
"def reachable_tiles\n @tiles\n end",
"def tiles\n return @players_plaque\n end",
"def cal_pos\n x, y = map_location(@grid_x, @grid_y)\n x += @tile_size/2\n y += @tile_size/2\n [x,y]\n end",
"def from_quad_tree_to_tile(qt, zoom)\n tx = 0\n ty = 0\n\n qt = \"0#{qt}\" if qt[0] != ?0\n\n zoom.downto(1) do |i|\n ch = qt[zoom - i].chr\n mask = 1 << (i - 1)\n digit = ch.to_i\n\n tx += mask if digit & 1 > 0\n ty += mask if digit & 2 > 0\n end\n ty = ((1 << zoom) - 1) - ty\n [ tx, ty ]\n end",
"def create_tilemap\n @tilemap = Tilemap.new(@viewport1)\n @tilemap2 = Tilemap.new(@viewport4)\n @tilemap.map_data = $game_map.data.clone\n @tilemap2.map_data = $game_map.data.clone\n result = []\n for i in 0..@tilemap2.map_data.xsize\n for j in 0..@tilemap2.map_data.ysize\n for k in 0..@tilemap2.map_data.zsize\n if ($game_map.region_id(i,j) - @etage) <= 1\n @tilemap2.map_data[i,j,k] = 0\n else\n unless Etage::MAP.include?($game_map.map_id)\n @tilemap2.map_data[i,j,k] = 0\n end\n end\n end\n end\n end\n load_tileset\n end",
"def refresh_tiles\n return if empty?\n xdiff = @array[0].real_x.round / -32 - 1\n ydiff = @array[0].real_y.round / -32 - 1\n if ydiff > 0\n ydiff.times do\n move_up do |sprite|\n sprite.mapy += YSIZE\n sprite.real_y += 32 * YSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n elsif ydiff < 0\n ydiff.abs.times do\n move_down do |sprite|\n sprite.mapy -= YSIZE\n sprite.real_y -= 32 * YSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n end\n if xdiff > 0\n xdiff.times do\n move_left do |sprite|\n sprite.mapx += XSIZE\n sprite.real_x += 32 * XSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n elsif xdiff < 0\n xdiff.abs.times do\n move_right do |sprite|\n sprite.mapx -= XSIZE\n sprite.real_x -= 32 * XSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n temp_bitmaps = nil\n end\n end",
"def squares_by_tile(layer, tile_id)\n @tile_mapper[layer][tile_id] || []\n end",
"def tile(*coords)\n (coords.size == 1) ? tile_map[coords.first] : tile_map[coords]\n end",
"def get_tile_number(lat_deg, lng_deg, zoom)\n lat_rad = lat_deg/180 * Math::PI\n n = 2.0 ** zoom\n x = ((lng_deg + 180.0) / 360.0 * n).to_i\n y = ((1.0 - Math::log(Math::tan(lat_rad) + (1 / Math::cos(lat_rad))) / Math::PI) / 2.0 * n).to_i\n\n {:x => x, :y => y}\nend",
"def tile(r,c)\r\n \ttiles[r,c]\r\n end",
"def get_tile_number(lat_deg, lng_deg, zoom)\n lat_rad = lat_deg/180 * Math::PI\n n = 2.0 ** zoom\n x = (lng_deg + 180.0) / 360.0 * n\n y = (1.0 - Math::log(Math::tan(lat_rad) + (1 / Math::cos(lat_rad))) / Math::PI) / 2.0 * n\n if !y.infinite?.nil?\n y = x\n end\n\n [x, y]\n end",
"def get_mouse_tile_x\n return ((@window.mouse_x - @x + (@scroll_x*@scale))/screen_tile(0)).floor\n end",
"def tile(x, y)\r\n row, col = get_row_col x, y\r\n return nil if out_of_range? row, col\r\n @tiles[row][col]\r\n end",
"def get_tile(gid)\n\t\t\treturn [nil,nil,nil] if gid.zero?\n\t\t\ttileset_gid = each_tileset_key.reverse_each.find{|first_gid| first_gid <= gid}\n\t\t\traise(\"Cannot resolve tileset GID: #{tileset_gid}!\") unless tileset_gid\n\t\t\ttileset = get_tileset(tileset_gid)\n\t\t\t# The tile IDs inside the tileset are relative to 0, but the GID we\n\t\t\t# have for our tile is global for all tilesets. As we already determined\n\t\t\t# which tileset it specifies above, we can just convert the absolute GID\n\t\t\t# into a one relative to the determined tileset by removing the absolute\n\t\t\t# part from it.\n\t\t\trelative_id = gid - tileset_gid\n\t\t\treturn [nil,nil,nil] if relative_id >= tileset.num_tiles\n\t\t\ttile = tileset.tiles[relative_id]\n\t\t\treturn [tile,relative_id,tileset]\n\t\tend",
"def pos(tilew, tileh, hmul, x,y)\n r = $map[y] || []\n my = 0\n tile = \"grass\"\n if r.is_a?(Array)\n my = r[x] || 0\n else\n # I apply a factor of 0.7 here, as pure\n # integer multiples of the tile height looks\n # odd. In a proper map representation I may\n # make the height much more granular.\n my = r[x*2].to_i * hmul.to_f * 0.7\n tile = $tiletypes[r[x*2+1]]\n end\n return (x-y)*tilew + 600, -(x+y)*tileh +540 + my*tileh, my, tile\nend",
"def to_tile_data(map, start_x, start_y)\n tiles = []\n map.each_with_index do |row, y|\n if row == nil\n next\n end\n row.each_with_index do |cell, x|\n if cell == nil\n next\n end\n tiles << \"#{hashed_coord(x+start_x, y+start_y)}, #{cell}, 0\"\n end\n end\n\n return tiles.join(\", \")\nend",
"def best_zoom(collection, center_point, width, height)\n min_lat, max_lat, min_lng, max_lng = 0, 0, 0, 0\n collection.each do |loc|\n if loc.class == Location\n min_lat = loc.lat if loc.lat < min_lat\n max_lat = loc.lat if loc.lat > max_lat\n min_lng = loc.lng if loc.lng < min_lng\n max_lng = loc.lng if loc.lng > max_lng\n elsif loc.class == Array # expecting [lat, lng] array elements\n min_lat = loc.first if loc.first < min_lat\n max_lat = loc.first if loc.first > max_lat\n min_lng = loc.last if loc.last < min_lng\n max_lng = loc.last if loc.last > max_lng\n end\n end\n distance_diag = calculate_distance2(min_lat, min_lng, max_lat, max_lng)\n pixels_diag = Math.sqrt(width ** 2 + height ** 2)\n meters_per_pixel_needed = distance_diag / pixels_diag\n # compare here, meters per pixel to this number for different zoom levels\n zoom_levels_yahoo = [0, 2**0, 2**1, 2**2, 2**3, 2**4, 2**5, 2**6, 2**7, 2**8, 2**9, 2**10, 2**11, 2**12, 2**13, 2**14, 2**15, 2**16, 2**17] #start close in and zoom out\n zoom_levels_yahoo.each_with_index do |zl, i|\n zoom = (18 - i) if meters_per_pixel_needed > zl\n end\n zoom = 10 if (zoom.nil? || zoom == 0)\n zoom\n end",
"def setup_region_tile_mapping\n @region_tile_mapping = {}\n (0..63).each {|i| @region_tile_mapping[i] = []}\n for x in 0..data.xsize\n for y in 0..data.ysize\n @region_tile_mapping[region_id(x, y)] << [x,y]\n end\n end\n end",
"def screen_tile(widthheight)\n return widthheight == 0 ? @window.tile_width * @scale : @window.tile_height * @scale\n end",
"def [](x, y)\n return @tiles[x][y] if within? x, y\n end",
"def screen_tile_x\n Graphics.width / TILE_WIDTH\n end",
"def get_tile_bbox(x,y,z)\n min_x, min_y = get_merc_coords(x * 256, y * 256, z)\n max_x, max_y = get_merc_coords( (x + 1) * 256, (y + 1) * 256, z )\n return \"#{min_x},#{min_y},#{max_x},#{max_y}\"\n end",
"def get_tile_bbox(x,y,z)\n min_x, min_y = get_merc_coords(x * 256, y * 256, z)\n max_x, max_y = get_merc_coords( (x + 1) * 256, (y + 1) * 256, z )\n return \"#{min_x},#{min_y},#{max_x},#{max_y}\"\n end",
"def pixels_to_tile(px, py)\n tx = (px / @tile_size.to_f).ceil.to_i - 1\n ty = (py / @tile_size.to_f).ceil.to_i - 1\n [tx, ty]\n end",
"def draw_map_cells(x, y)\n for i in (0..x-1)\n for j in (0..y-1)\n MapCellEmpty.create(:x => $node_size*5 * i + $node_size *5/2.0, :y => $node_size * 5 * j + $node_size * 5/2.0)\n end\n end\n end",
"def snapshot_boundaries\n minmax = @snapshot.first.map { |dim_coord| [dim_coord, dim_coord] }\n @snapshot.each do |coord|\n coord.each_with_index do |dim_coord, i|\n minmax[i][0] = dim_coord if dim_coord < minmax[i][0]\n minmax[i][1] = dim_coord if dim_coord > minmax[i][1]\n end\n end\n minmax\n end",
"def to_2d_array(tile_hash)\n min_x = tile_hash.min_by{|v|v[:x]}[:x]\n min_y = tile_hash.min_by{|v|v[:y]}[:y]\n map = []\n tile_hash.each do |cell|\n rel_x = cell[:x] - min_x\n rel_y = cell[:y] - min_y\n if map.length < rel_y + 1 || map[rel_y] == nil\n map[rel_y] = []\n end\n map[rel_y][rel_x] = cell[:index]\n end\n map\nend",
"def get_subgrid(cords)\n subgrid = []\n x_pos = cords[0] - cords[0] % 3\n (x_pos..x_pos + 2).each do |row_num|\n y_pos = cords[1] - cords[1] % 3\n subgrid += @grid[row_num][y_pos, 3]\n end\n subgrid\n end",
"def zoom\n end",
"def get_tile_type(x, y)\n :tile\n end",
"def draw(viewport)\n viewport.map! { |p| p / @tile_size }\n x0, x1, y0, y1 = viewport.map(&:to_i)\n\n # restrict to prevent re-rendering\n x0 = 0 if x0.negative?\n x1 = @width - 1 if x1 >= @width\n y0 = 0 if y0.negative?\n y1 = @height - 1 if y1 >= @height\n\n (x0..x1).each do |x|\n (y0..y1).each do |y|\n @layers[:tile_layers].each do |_, tiles|\n next unless tiles[y][x]\n\n tiles[y][x].draw(x * @tile_size, y * @tile_size) if tiles[y][x].id != 0\n # tiles[y][x].x = x\n # tiles[y][x].y = y\n end\n end\n end\n end",
"def get_tile_position(x, y)\n spacing = Vector2.new((assets.tile_width/2.0).round, (assets.tile_height/2.0).round)\n Vector2.new((-x * spacing.x) + (y * spacing.x) - y + x + OFFSET.x,\n (x * spacing.y) + (y*spacing.y) - y - x + OFFSET.y)\n end",
"def build_grid size\n self.tiles.clear\n size.to_i.times do |row|\n size.to_i.times do |column|\n self.tiles.build({\n x: column,\n y: row\n })\n end\n end\n end",
"def max_tile_dimensions\n lambda do |projection|\n projection.explicit_tile_dimensions(max_size(projection))\n end\n end",
"def load_tiles(zombie_setting)\n tiles = Gosu::Image.load_tiles(zombie_setting[\"image_tile_dir\"], 32, 32)\n tile_no = zombie_setting[\"tile_loc\"]\n \n start = (tile_no - 1) * 3\n\n @image_tiles = Array.new\n for x in 0..3 do\n for y in 0..2 do\n @image_tiles << tiles[start + y]\n end\n start +=12\n end \n end",
"def get_surrounding_tiles(row, column, cell)\n surrounding_tiles = []\n index = GAME_BOARD[column-1].index(cell)\n if column == 1 \n if index == 0\n surrounding_tiles << GAME_BOARD[column-1][index+1]\n surrounding_tiles << GAME_BOARD[column][index]\n elsif index == 8\n surrounding_tiles << GAME_BOARD[column-1][index-1]\n surrounding_tiles << GAME_BOARD[column][index]\n else\n surrounding_tiles << GAME_BOARD[column-1][index-1] \n surrounding_tiles << GAME_BOARD[column-1][index+1] \n surrounding_tiles << GAME_BOARD[column][index]\n end\n elsif column == 12\n if index == 0\n surrounding_tiles << GAME_BOARD[column-1][index+1]\n surrounding_tiles << GAME_BOARD[column-2][index] \n elsif index == 8\n surrounding_tiles << GAME_BOARD[column-1][index-1]\n surrounding_tiles << GAME_BOARD[column-2][index] \n else\n surrounding_tiles << GAME_BOARD[column-1][index-1] \n surrounding_tiles << GAME_BOARD[column-1][index+1] \n surrounding_tiles << GAME_BOARD[column-2][index]\n end\n elsif index == 0\n surrounding_tiles << GAME_BOARD[column-1][index+1] \n surrounding_tiles << GAME_BOARD[column][index]\n surrounding_tiles << GAME_BOARD[column-2][index]\n elsif index == 8\n surrounding_tiles << GAME_BOARD[column-1][index-1] \n surrounding_tiles << GAME_BOARD[column][index]\n surrounding_tiles << GAME_BOARD[column-2][index]\n else\n surrounding_tiles << GAME_BOARD[column-1][index+1] \n surrounding_tiles << GAME_BOARD[column-1][index-1] \n surrounding_tiles << GAME_BOARD[column][index]\n surrounding_tiles << GAME_BOARD[column-2][index]\n end\n\n surrounding_tiles\n end",
"def read_tmx(file)\n filename = File.basename(file)\n map_name = filename.gsub('.tmx', '')\n\n tmx = File.open(file) { |f| Nokogiri::XML(f) }\n map_count = tmx.css('map').count\n map = tmx.css('map').first\n\n tiles_wide = map.attributes['width'].value.to_i\n tiles_high = map.attributes['height'].value.to_i\n\n # ========== Make sure that sucker is valid ==============\n raise \"No maps in this tmx?? #{filename}\" if map_count < 1\n raise \"More than one map in a tmx?? #{filename}\" if map_count > 1\n\n if map.attributes['orientation'].value != 'orthogonal'\n raise \"The tilemap #{filename} isn't orthogonal\"\n elsif map.attributes['tilewidth'].value != '32' || map.attributes['tileheight'].value != '32'\n raise \"The tilemap #{filename} doesn't use 32x32 tiles\"\n end\n\n # ============ Grab tilesets =============\n tilesets = []\n map.css('tileset').each do |tileset|\n attrs = tileset.attributes\n image = tileset.css('image').first # assuming one image lol...\n\n tilesets << Tileset.new(\n attrs['firstgid'].value.to_i,\n attrs['name'].value,\n attrs['tilewidth'].value.to_i,\n attrs['tileheight'].value.to_i,\n attrs['tilecount'].value.to_i,\n image.attributes['source'].value.gsub('assets/', ''),\n image.attributes['width'].value.to_i / 32\n )\n end\n # First tileset should be the one with the largest firstgid\n tilesets.sort! { |a, b| b.firstgid <=> a.firstgid }\n\n # ============== Grab layers ================\n layers = []\n found_collision_layer = false\n map.css('layer').each do |layer|\n attrs = layer.attributes\n data = layer.css('data').first # Assuming 1 data lol\n raise \"Tile encoding must be csv #{filename}\" if data.attributes['encoding'].value != 'csv'\n\n layers << Layer.new(\n attrs['name'].value.downcase.strip,\n attrs['width'].value.to_i,\n attrs['height'].value.to_i,\n data.content.split(',').map(&:to_i),\n {} # Sublayers come from multiple tilesets being used in one layer\n )\n\n if layers.last.collision?\n if found_collision_layer\n raise \"Two collision layers found in tilemap #{filename}\"\n else\n found_collision_layer = true\n end\n end\n end\n raise \"No collision layer found in tilemap #{filename} (intentional or no?)\" unless found_collision_layer\n\n # ============ Populate sublayers ============\n\n layers.each do |layer|\n layer.raw_data.each_with_index do |num, i|\n next if num == 0\n\n global_index = (num & 0x00FFFFFF)\n flags = (num & 0xFF000000) >> 24\n\n if (flags & (1 << 6)) != 0\n puts \"WARNING: #{filename} layer \\\"#{layer.name}\\\" tile #{i} is y-flipped - ignoring this flip.\"\n flags &= ~(1 << 6)\n end\n\n tileset = tilesets.find do |t|\n global_index - t.firstgid >= 0\n end\n index = global_index - tileset.firstgid\n\n layer.sublayers[tileset] ||= Sublayer.new(tileset, Array.new(layer.raw_data.size, -1), [])\n layer.sublayers[tileset].data[i] = (index | (flags << 24))\n end\n\n # Flip the sublayer data upside-down (for 0=bottom)\n layer.sublayers.values.each do |sublayer|\n new_data = sublayer.data.clone\n (0...tiles_wide).each do |x|\n (0...tiles_high).each do |y|\n new_data[y * tiles_wide + x] = sublayer.data[(tiles_high - y - 1) * tiles_wide + x]\n end\n end\n sublayer.data = new_data\n end\n\n # Compress sublayer data if necessary\n if layer.collision?\n # Collision layer should not be compressed and only have one sublayer\n raise \"collision layer has more than one tileset. #{filename}\" if layer.sublayers.size > 1\n else\n # Non-collision layers should all be compressed\n layer.sublayers.each do |tileset, sublayer|\n new_data = []\n compress_tilemap_data(sublayer.data).each do |entry|\n case entry\n when TileRepetition\n new_data += [entry.count, entry.tile_index]\n\n when TileAlternation\n new_data << -entry.count\n tile_indices = sublayer.data[entry.first_index...(entry.first_index + entry.count)]\n new_data += tile_indices\n\n else\n raise \"what\"\n end\n end\n sublayer.compressed_data = new_data\n end\n end\n end\n\n # ===== Grab imagelayers for parallax backgrounds =====\n image_layers = []\n map.css('imagelayer').each do |imagelayer|\n attrs = imagelayer.attributes\n\n struct = ImageLayer.new\n struct.name = attrs['name'].value\n struct.x = attrs['x'] ? attrs['x'].value : '0'\n struct.y = attrs['y'] ? attrs['y'].value : '0'\n struct.filename = imagelayer.css('image').first.attributes['source'].value\n\n IMAGE_LAYER_DEFAULTS.each do |field, default_value|\n if element = imagelayer.css(\"properties property[name='#{field}']\").first\n value = element.attributes['value'].value\n else\n value = default_value\n end\n struct.send(\"#{field}=\", value)\n end\n\n image_layers << struct\n end\n\n # ===== Grab object layers for whatever =====\n map_height = tiles_high.to_i * 32\n map_objects = []\n map.css('objectgroup object').each do |object|\n attrs = object.attributes\n\n struct = MapObject.new\n struct.id = attrs['id'].value\n struct.name = attrs['name'] ? attrs['name'].value : '<unnamed>'\n struct.x = (attrs['x'] ? attrs['x'].value : '0').to_i\n struct.y = map_height - (attrs['y'] ? attrs['y'].value : '0').to_i\n struct.width = (attrs['width'] ? attrs['width'].value : '0').to_i\n struct.height = (attrs['height'] ? attrs['height'].value : '0').to_i\n struct.type = attrs['type'].value.downcase.to_sym if attrs['type']\n struct.properties = {}\n\n object.css('properties property').each do |property|\n prop_attrs = property.attributes\n struct.properties[prop_attrs['name'].value] = prop_attrs['value'].value\n end\n\n map_objects << struct\n end\n\n map_options = MapOptions.new(1.15, 0.025)\n\n tmx.css('map > properties > property').each do |prop|\n attrs = prop.attributes\n\n case attrs['name'].value\n when 'gravity' then map_options.gravity = eval(attrs['value'].value)\n when 'drag' then map_options.drag = eval(attrs['value'].value)\n else puts \"UNKNOWN MAP PROPERTY #{attrs['name'].inspect}\"\n end\n end\n\n # === DONE ===\n Struct.new(:layers, :image_layers, :map_objects, :tiles_high, :tiles_wide, :name, :filename, :height, :options)\n .new( layers, image_layers, map_objects, tiles_high, tiles_wide, map_name, filename, map_height, map_options)\nend",
"def setMap(level)\n\tcase level\n\twhen 1\n\t\treturn [[[0,0],[1,1],[0,0],[1,0],[-1,0],[0,1],[-1,0],[0,1],[2,0],[2,0]], 3, 0, false, 8]\n\twhen 2\n\t\treturn [[[4,0],[0,0],[0,0],[0,0],[0,0],[-1,0],[-2,0],[0,0],[1,1],[0,0],[2,2],[0,0],[1,1],[0,0],[3,3]],7,0,false,0]\n\twhen 3\n\t\treturn [[[0,0],[0,0],[0,0],[1,1],[2,2],[3,3],[-3,0],[0,0],[-3,0],[-3,0],[0,0]],2,0,false,10]\n\tend\nend",
"def square(idx)\n tiles = []\n x = (idx / 3) *3\n y = (idx % 3) * 3\n\n (x...x+3).each do |i|\n (y...y+3).each do |j|\n tiles << self[[i,j]]\n end\n end\n tiles\n end",
"def draw_tiles(tile_bag)\n until tiles.length == 7\n tiles.concat(tile_bag.draw_tiles(1)) #because draw_tiles returns an array\n\n end\n end",
"def create_tiles\n # Screen fits exactly 15x10 tiles (for 480x320), but it has a buffer around it\n # so the game has time to refresh without showing a black border during movement.\n tiles = []\n (TOTALSIZE).times { tiles << TileSprite.new($visuals.viewport) }\n @array = tiles\n startx = $visuals.map.real_x / -32 - 1\n starty = $visuals.map.real_y / -32 - 1\n for y in 0...YSIZE\n for x in 0...XSIZE\n mapx = startx + x\n mapy = starty + y\n idx = x + y * XSIZE\n @array[idx].real_x = $visuals.map.real_x + mapx * 32\n @array[idx].real_y = $visuals.map.real_y + mapy * 32\n draw_tile(@array[idx], mapx, mapy)\n end\n end\n $temp_bitmaps = nil\n # Don't dispose the bitmaps hash because tiles reference these instances; they're not clones.\n end",
"def pos\r\n { x: @tile.x,\r\n y: @tile.y }\r\n end",
"def draw_tiles (num)\n tiles_drawn = @bag_of_tiles.sample(num)\n tiles_drawn.each do | tile |\n @bag_of_tiles.slice!(@bag_of_tiles.index(tile))\n end\n return tiles_drawn\n end",
"def draw_tiles(num)\n random_tiles = @tiles.sample(num)\n random_tiles.each do |letter|\n @tiles.slice!(@tiles.index(letter))\n end\n return random_tiles\n end",
"def get_neighbors(tile)\n @tiles.flatten.select { |t|\n (t.x <= (tile.x + 1) && t.x >= (tile.x - 1)) &&\n (t.y <= (tile.y + 1) && t.y >= (tile.y - 1)) &&\n tile != t\n }\n end",
"def logical_pos(x, y)\n [\n (x / @tile_width).floor,\n (y / @tile_height).floor\n ]\n end",
"def tile_offset index\n\t\t\t@unit_size * index\n\t\tend",
"def tile_size level\n\t\t\t2 ** level\n\t\tend",
"def calculate_zoom(top_left:, bottom_right:, width:, height:)\n # multiplication factor between horizontal span and map width\n h_factor = (bottom_right.column - top_left.column) / (width.to_f / Honua.configuration.tile_width)\n\n # possible horizontal zoom to fit geographical extent in map width\n h_possible_zoom = top_left.zoom - (Math.log(h_factor) / Math.log(2)).ceil\n\n # multiplication factor between vertical span and map height\n v_factor = (bottom_right.row - top_left.row) / (height.to_f / Honua.configuration.tile_height)\n\n # possible vertical zoom to fit geographical extent in map height\n v_possible_zoom = top_left.zoom - (Math.log(v_factor) / Math.log(2)).ceil\n\n # initial zoom to fit extent vertically and horizontally\n [h_possible_zoom, v_possible_zoom].min\n end",
"def meters_to_pixels(mx, my, zoom)\n res = resolution(zoom)\n px = (mx + @origin_shift) / res\n py = (my + @origin_shift) / res\n [px, py]\n end",
"def find_hole\n @tiles.size.times do |x|\n @tiles.size.times do |y|\n return [x,y] if @tiles[y][x].nil?\n end\n end\n end",
"def tile_id(x, y, layer, map_id = nil)\n return $game_map.tile_id(x, y, layer) unless map_id\n Cache.map(map_id).data[x, y, layer]\n end",
"def zoom(factor = 5)\n upstream_slice = self.class.sketch.slices.select{|s| s.start_cumulative_bp < @start_cumulative_bp}.sort_by{|s| s.start_cumulative_bp}[-1]\n downstream_slice = self.class.sketch.slices.select{|s| s.start_cumulative_bp > @start_cumulative_bp}.sort_by{|s| s.start_cumulative_bp}[0]\n\n center_bp = (@start_cumulative_bp + @length_bp.to_f/2).round\n\n @length_bp = (@length_bp.to_f/factor).round\n @start_cumulative_bp = (center_bp - @length_bp.to_f/2).round\n @stop_cumulative_bp = (center_bp + @length_bp.to_f/2 - 1).round\n @resolution = @length_pixel.to_f/@length_bp\n self.fetch_sequence\n\n upstream_slice.stop_cumulative_bp = @start_cumulative_bp - 1\n downstream_slice.start_cumulative_bp = @stop_cumulative_bp + 1\n [upstream_slice, downstream_slice].each do |s|\n s.length_bp = s.stop_cumulative_bp - s.start_cumulative_bp + 1\n s.resolution = s.length_pixel.to_f/s.length_bp\n s.range_cumulative_bp = Range.new(s.start_cumulative_bp, s.stop_cumulative_bp)\n s.fetch_sequence\n end\n self.class.sketch.slices.each{|s| s.format_resolution}\n\n self.class.sketch.buffer_images[:zoomed] = self.class.sketch.draw_zoomed_buffer\n self.class.sketch.buffer_images[:information_panel] = self.class.sketch.draw_information_panel\n end",
"def init_tiles\n # Determine how many frames of animation this autotile has\n for i in 0..6\n bm = @autotiles[i]\n if bm.nil?\n @total_frames = 1\n elsif bm.height > 32\n @total_frames[i] = bm.width / 256\n else\n @total_frames[i] = bm.width / 32\n end\n @current_frame[i] = 0\n end\n # Turn on flag that the tilemap sprites have been initialized\n @tilemap_drawn = true\n \n @animating_tiles.clear\n # Create a sprite and viewport to use for each priority level.\n (0...((SCREEN[0]/32+2) * (SCREEN[1]/32+2))*3).each{|i|\n @tile_sprites[i/3] = [] if @tile_sprites[i/3].nil?\n @tile_sprites[i/3][i%3] = Sprite.new(@viewport) unless @tile_sprites[i/3][i%3].is_a?(Sprite)\n # Rename to something shorter and easier to work with for below\n tile = @tile_sprites[i/3][i%3]\n # Assign tile's respective ID value\n tile.tile_sprite_id = i\n # Draw sprite at index location (ex. ID 0 should always be the top-left sprite)\n tile.x = (i % ((SCREEN[0]/32+2)*3) / 3 * 32) - 32 + (@ox % 32)\n tile.y = (i / ((SCREEN[0]/32+2)*3) * 32) - 32 + (@oy % 32)\n\n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n @corner_tile_loc = [map_x, map_y] if i == 0\n # If the tile happens to be drawn along the outside borders of the map\n if map_x < 0 || map_x >= $game_map.width || map_y < 0 || map_y >= $game_map.height\n tile.z = 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n else # Tile is actually on the map\n tile_id = @map_data[map_x,map_y,i%3]\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = tile.y + @priorities[tile_id] * 32 + 32\n end\n # No tile exists here\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')#@tileset\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384 # non-autotile\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)\n else # autotile\n tile.bitmap = @autotiles[tile_id/48-1]\n tile.src_rect.set(((tile_id % 48) % 8)*32,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[i] = tile if tile.bitmap.width > 256\n end\n end\n }\n # Sprite ID located at top left corner (ranges from 0..map_width * map_height\n @corner_index = 0\n end",
"def generate_tile()\n @i = do_generate_tile(@i)\n end",
"def recalculate!(scale)\n neighbor = @coordinate.zoom_to(zoom - 1)\n parent = neighbor.container\n\n col_shift = 2 * (neighbor.column - parent.column)\n row_shift = 2 * (neighbor.row - parent.row)\n\n @offset.x -= scale * tile_width * col_shift\n @offset.y -= scale * tile_height * row_shift\n @coordinate = parent\n end",
"def to_list\n retval = []\n 1.upto(@tiles.length - 1) do |row|\n 1.upto(@tiles[row].length - 1) do |col|\n retval << @tiles[row][col]\n end\n end\n retval\n end",
"def hit\n hit_object = $window.tiles.select{|t| t.within_clickable?(@x, @y) and !t.content.nil?}\n return hit_object.first if !hit_object.nil?\n end",
"def tile_stack(x, y, delay = 0)\n point = Point.new(x, y)\n windows = []\n loop do\n w = PinnableWindow.from_point(point)\n break unless w\n windows << w\n tile(w, delay)\n\n end\n windows\n end",
"def create_spaces\n ((@tiles, @tile_map),\n (@up_vtexs, @up_vtex_map),\n (@down_vtexs, @down_vtex_map),\n (@asc_edges, @asc_edge_map),\n (@desc_edges, @desc_edge_map),\n (@vert_edges, @vert_edge_map)) =\n [[Tile, nil, 1..5, [3,4,5,4,3], [1..3, 1..4, 1..5, 2..5, 3..5]],\n [Vtex, :up, 1..6, [3,4,5,6,5,4], [1..3, 1..4, 1..5, 1..6, 2..6, 3..6]],\n [Vtex, :down, 0..5, [4,5,6,5,4,3], [0..3, 0..4, 0..5, 1..5, 2..5, 3..5]],\n [Edge, :asc, 1..6, [3,4,5,5,4,3], [1..3, 1..4, 1..5, 2..6, 3..6, 4..6]],\n [Edge, :desc, 1..6, [3,4,5,5,4,3], [1..3, 1..4, 1..5, 1..5, 2..5, 3..5]],\n [Edge, :vert, 1..5, [4,5,6,5,4], [1..4, 1..5, 1..6, 2..6, 3..6]]\n ].map {|cls, align, row_interval, row_counts, col_intervals|\n rows = row_counts.zip(row_interval.to_a).map {|c, r| [r]*c}.flatten\n cols = col_intervals.map {|ival| ival.to_a}.flatten\n count = rows.length\n list = (0...count).to_a.map {|i| cls.new}\n list.each {|obj| obj.alignment = align} unless align.nil?\n list.zip(rows, cols).each {|obj, row, col| obj.row, obj.col = row, col}\n map = Hash[list.map {|obj| [[obj.row, obj.col], obj]}]\n [list, map]\n }\n\n @vtexs = @up_vtexs + @down_vtexs\n @edges = @asc_edges + @desc_edges + @vert_edges\n @all_spaces = @tiles + @vtexs + @edges\n\n @vtex_map = Hash[@vtexs.map {|v| [v.coords, v]}]\n @edge_map = Hash[@edges.map {|e| [e.coords, e]}]\n\n @all_spaces.zip((0...(@all_spaces.length)).to_a).each do |obj, id|\n obj.id = id\n end\n end",
"def tiles_remaining\n return @tiles\n end",
"def mapx\n return $game_map.events[@id].real_x * 32\n end",
"def split_tile_set_into_tiles\n number_of_tiles = @tile_set[0].columns/32\n\n number_of_tiles.times do |i|\n image = @tile_set[0].crop((i*32), 0, 32, 32)\n image.write(\"media/tmp/tile#{i}.png\")\n end\n end",
"def tile_board\n @board_array.each_with_index do |row_array, row|\n 10.times{|column| row_array << Tile.new(row,column)}\n end\n end",
"def iTile(x,y)\r\n return (x>=@x1 and x<=@x2 and y>=@y1 and y<=@y2)\r\n end",
"def display_all_tiles\n array = []\n @default_tiles.each do |key, value|\n array << (key * value).split(\"\")\n end\n return array.flatten\n end",
"def jumpto_tile(x, y)\n jumpto(0, [x, y])\n end",
"def screen_tile_y\n Graphics.height / TILE_HEIGHT\n end",
"def slice!(&block)\n if ! @overwrite && File.directory?(@destination) && ! Dir[\"@{@destination}/*\"].empty?\n raise \"Output directory #{@destination} already exists!\"\n @overwrite ? Rails.logger.warn(msg) : raise(msg)\n end\n\n image = @tile_source.dup\n orig_width, orig_height = image.columns, image.rows\n\n # iterate over all levels (= zoom stages)\n max_level(orig_width, orig_height).downto(0) do |level|\n width, height = image.columns, image.rows\n\n current_level_dir = File.join(@destination, level.to_s)\n FileUtils.mkdir_p(current_level_dir)\n\n if block_given?\n yield current_level_dir\n end\n\n # iterate over columns\n x, col_count = 0, 0\n while x < width\n # iterate over rows\n y, row_count = 0, 0\n while y < height\n dest_path = File.join(current_level_dir, \"#{col_count}_#{row_count}.#{@tile_format}\")\n tile_width, tile_height = tile_dimensions(x, y, @tile_size, @tile_overlap)\n\n save_cropped_image(image, dest_path, x, y, tile_width, tile_height, @tile_quality)\n\n y += (tile_height - (2 * @tile_overlap))\n row_count += 1\n end\n x += (tile_width - (2 * @tile_overlap))\n col_count += 1\n end\n\n image.resize!(0.5)\n end\n\n image.destroy!\n end",
"def zoom_2\n return 1.0\n end",
"def update_mouse_tiles\n mx = (Mouse.pos[0] / 32) ; my = (Mouse.pos[1] / 32)\n case [mx, my]\n when [Tile_X, Tile_Y] then $game_player.mouse_over = 1\n when [Tile_X + 1, Tile_Y] then $game_player.mouse_over = 2\n when [Tile_X + 2, Tile_Y] then $game_player.mouse_over = 3\n when [Tile_X + 3, Tile_Y] then $game_player.mouse_over = 4\n when [Tile_X + 4, Tile_Y] then $game_player.mouse_over = 5\n when [Tile_X + 5, Tile_Y] then $game_player.mouse_over = 6\n when [Tile_X + 6, Tile_Y] then $game_player.mouse_over = 7\n when [Tile_X + 7, Tile_Y] then $game_player.mouse_over = 8\n when [Tile_X + 8, Tile_Y] then $game_player.mouse_over = 9\n else \n $game_player.mouse_over = 0 if $game_player.mouse_over != 0\n end\n if $game_player.mouse_over > 0\n create_mouse_blink\n update_mouse_blink_position\n @mouse_blink.opacity -= 3\n @mouse_blink.opacity = 70 if @mouse_blink.opacity <= 6\n else\n dispose_mouse_blink\n end\n end",
"def zoom_1\n return 1.0\n end",
"def measure map, x, y \n if map[x][y] != 'land' || x >= 6 || y >= 6 #Ensures water, counted land, and coordinates\n return 0 #off the grid aren't counted.\n end\n \n size = 1\n map[x][y] = 'counted land' #Marks the starting tile as something bedsides Land. Every tile surrounding the starting tile becomes the \"new starting tile\" as the the recursion happens.\n \n size = size + measure(map, x-1, y-1) #Each of these lines is run again and again until\n size = size + measure(map, x, y-1) #a non-land square is encountered. \n size = size + measure(map, x+1, y-1) #That's the recursive part.\n size = size + measure(map, x-1, y)\n size = size + measure(map, x+1, y)\n size = size + measure(map, x-1, y+1)\n size = size + measure(map, x, y+1)\n size = size + measure(map, x+1, y+1)\n \n size\nend"
] |
[
"0.7280654",
"0.70180815",
"0.6971471",
"0.68322015",
"0.68322015",
"0.6829012",
"0.6770443",
"0.6716278",
"0.670656",
"0.6472291",
"0.6470912",
"0.64243317",
"0.6414456",
"0.639209",
"0.639209",
"0.623337",
"0.6219596",
"0.6210064",
"0.6206513",
"0.62036145",
"0.61381966",
"0.610335",
"0.60951436",
"0.6088492",
"0.6083768",
"0.6019433",
"0.5961271",
"0.59508365",
"0.59421486",
"0.59410745",
"0.5931226",
"0.593104",
"0.59266144",
"0.5905527",
"0.5882503",
"0.58821684",
"0.5871608",
"0.58630633",
"0.5848728",
"0.5837634",
"0.5835627",
"0.58272225",
"0.5826312",
"0.5812071",
"0.5806012",
"0.5800063",
"0.57868576",
"0.5766629",
"0.5764078",
"0.5764078",
"0.572837",
"0.57064503",
"0.5697852",
"0.5696585",
"0.56873846",
"0.56835407",
"0.5681258",
"0.5661987",
"0.5633643",
"0.5616537",
"0.5611244",
"0.56103927",
"0.56061316",
"0.5568537",
"0.5553109",
"0.55506676",
"0.5543333",
"0.5533661",
"0.55312824",
"0.5523585",
"0.55202496",
"0.55124366",
"0.5511069",
"0.54821837",
"0.54747087",
"0.54476255",
"0.5446974",
"0.5443822",
"0.54206634",
"0.5420254",
"0.54109",
"0.5404484",
"0.5403843",
"0.5402827",
"0.5380005",
"0.5378254",
"0.5373974",
"0.5373392",
"0.5372087",
"0.5366144",
"0.5365365",
"0.53640515",
"0.5361849",
"0.53463185",
"0.53429127",
"0.53417516",
"0.5335008",
"0.5329369",
"0.53115314",
"0.5310308"
] |
0.78720015
|
0
|
blow away any existing state, when next used to fetch events from mingle will crawl all the way back to time zero
|
def reset
@entry_cache.clear
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def keep_going; end",
"def times_walked_to(state); end",
"def ack_changes\n @queries.each { |query| query[:current_state] = query[:event_state] }\n end",
"def stale_state\n end",
"def take_while( & block )\n \n load_parent_state\n \n return super\n\n end",
"def next_event\n return current_event unless next_event?\n\n current_event.update!(visited: true)\n update!(current_event: current_event.next_event)\n current_event\n end",
"def on_state_while(state_id, item = nil)\n end",
"def audit\n while cursor = @queue.shift\n step(Stupidedi::Builder::StateMachine.new(@config, [cursor]))\n end\n end",
"def reset_standing_events\n destroy_standing_events\n # Reset processed flag\n reset_processed\n process_standing_events\n end",
"def backlog; end",
"def backlog; end",
"def stale_state\n nil\n end",
"def stale_state\n nil\n end",
"def low_frequency\n log \"Updating event status\"\n M2mhub::Event.open_or_recently_closed.each(&:update_status!)\n log \"Finished\"\n true\n end",
"def after_cycle; end",
"def backtrack(input_elist)\n\n\t\telist = Marshal.load(Marshal.dump(input_elist))\n\n\t\t# sort events based on slack\n\t\telist.sort! do |event1, event2|\n\t\t\tget_slack(event1) <=> get_slack(event2)\n\t\tend\n\t\t\n\t\t# find next event to assign (the one with the least slack) and remove from event list\n\t\tcurr_event = elist.delete_at(0)\n\n\t\t# make array of all possible start times for current event\n\t\tstart_vals = []\n\t\tcurr_event.times.each do |t|\n\t\t\tfor i in t[0]..(t[1]-curr_event.length)\n\t\t\t\tstart_vals.push(i)\n\t\t\tend\n\t\tend\n\t\tputs \"starting #{curr_event.name}, all times: #{curr_event.times}\"\n\t\t# try each assigning each possible value until one works\n\t\tstart_vals.each do |v1|\n\t\t\tv2 = v1+curr_event.length\n\t\t\tcurr_event.times=([[v1,v2]])\n\n\t\t\t# uses 1 room for the chosen time value\n\t\t\t# make an array containing every room that is available for the entire chosen time bracket\n\t\t\tintersect = @availability[v1]\n\t\t\tfor i in (v1+1)...v2\n\t\t\t\tintersect = intersect & @availability[i]\n\t\t\tend\n\t\t\tputs \"looking for room for #{curr_event.name} from #{v1} to #{v2}. Available: #{intersect}\"\n\t\t\t#puts \"available times for next event: #{elist[0].times}\"\n\t\t\t# assign curr_event to the first room in the array of available rooms\n\t\t\tunless intersect.empty?\n\t\t\t\t# variable to store name of room; used later if chosen time value fails\n\t\t\t\tcurr_room = intersect[0]\n\n\t\t\t\t@roomhash[curr_room].push(curr_event)\n\n\t\t\t\t# this room becomes unavailable for every hour in the chosen time bracket\n\t\t\t\tfor i in v1...v2\n\t\t\t\t\t@availability[i].delete(curr_room)\n\t\t\t\tend\n\n\t\t\t\tputs \"trying #{curr_event.name} from #{v1} to #{v2} in #{curr_room}\"\n\t\t\telse\n\t\t\t\t# no available room; skip the rest of this iteration of the loop\n\t\t\t\tnext\n\t\t\tend\n\t\t\t\n\t\t\t# base case - have assigned values to every event from original list\n\t\t\tif elist.empty?\n\t\t\t\treturn [curr_event]\n\t\t\tend\n\t\t\t\n\t\t\t# store current state of events list, to revert back to later if this path fails\n\t\t\ttemp_elist = Marshal.load(Marshal.dump(elist))\n\n\t\t\t# check for host conflicts - a host can't be at 2 events at the same time\n\t\t\telist.each do |e|\n\t\t\t\tcurr_event.hosts.each do |h|\n\t\t\t\t\t# for each event, if it shares a host with curr_event\n\t\t\t\t\tif e.hosts.include?(h)\n\t\t\t\t\t\ttrim_times(e,v1,v2)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\t# re-sort & check slack; if any events have a negative amount of slack, this time assignment doesn't work\n\t\t\telist.sort! do |event1, event2|\n\t\t\t\tget_slack(event1) <=> get_slack(event2)\n\t\t\tend\n\t\t\t\n\t\t\tif get_slack(elist[0]) >= 0\n\n\t\t\t\t# this time assignment works; recursively call backtrack algorithm to assign a time to the next event in the list\n\t\t\t\tresult = backtrack(elist)\n\t\t\t\treturn result + [curr_event] unless result==\"fail\"\n\t\t\tend\n\t\t\t\n\t\t\t# didn't return success in if statements; remove v from potential start times,\n\t\t\t# remove curr_event from room hash, reset room availability, un-trim altered times\n\t\t\t# for i in v1..v2\n\t\t\t# \t@availability[i] += 1\n\t\t\t# end\n\t\t\tfor i in v1...v2\n\t\t\t\t@availability[i].push(curr_room)\n\t\t\tend\n\t\t\troomhash[curr_room].delete(curr_event)\n\t\t\telist = Marshal.load(Marshal.dump(temp_elist))\n\t\tend\n\n\t\t# went through all recursive calls without returning a success\n\t\tputs \"returning fail on #{curr_event.name}\"\n\t\treturn \"fail\"\n\tend",
"def trigger!\n\treturn if (@next_state_name == nil)\n\n\tcurrent_state = nil\n current_state = @states.fetch(@current_state_name) unless @current_state_name.nil?\n\n\tnext_state = @states.fetch(@next_state_name)\n next_state_name = @next_state_name\n\n\t@next_state_name = nil\n\n\tcurrent_state.atexit if(current_state.respond_to?(:atexit))\n\t@current_state_name = next_state_name\n\tnext_state.atentry if(next_state.respond_to?(:atentry))\n end",
"def enter_pending; end",
"def leeway; end",
"def leeway; end",
"def reset_events_cache\n Event.where(target_id: self.id, target_type: 'Post').\n order('id DESC').limit(100).\n update_all(updated_at: Time.now)\n end",
"def next_state_for_event(event)\r\n ns = next_states_for_event(event)\r\n ns.empty? ? nil : ns.first.to\r\n end",
"def update_next_state\n # Maybe if I do this it won't query for this game's tiles every time? ¯\\_(ツ)_/¯\n tiles = self.tiles \n players = self.players \n voids = tiles.where(\"height < 1\")\n\n # Pick random tiles to raise\n raiseTiles = voids.sample((voids.length/2).ceil)\n dropCounter = (players.length/2).ceil\n dropTiles = []\n\n # Drop tiles players were on\n players.each do |player|\n dropTiles << player.tile\n end \n\n # Pick random tiles to drop\n while dropCounter > 0\n randTile = tiles.sample\n\n if (!dropTiles.include?(randTile) && randTile.height > 0)\n dropTiles << randTile \n dropCounter -= 1\n end\n end\n\n tiles.each do |tile| \n if (dropTiles.include?(tile))\n tile.update(height: tile.height-1)\n elsif (raiseTiles.include?(tile))\n tile.update(height: [2, 1, 1, 1].sample)\n end\n end\n end",
"def run_once\n if !initialized?\n process_initial_events\n ensure_state_initialized\n else\n process_latest_events\n end\n end",
"def advance!\n @state = (@state + 1) % @@states.length\n end",
"def prestart ( )\n reset( )\n @matchstate[:state] = 0\n @chain = [ @states[0], ]\n end",
"def on_state_timeup(state_id)\n end",
"def drop_while( & block )\n\n load_parent_state\n \n return super\n\n end",
"def crawl(&blk)\r\n while crawlNext(&blk)\r\n end\r\n end",
"def next states\n raise \"Must be implemented by subclass\"\n end",
"def each_reachable_state\n each_touch_reachable_state { |r| yield r }\n each_clap_reachable_state { |r| yield r }\n end",
"def handle_backtrack\n\t\tend",
"def next_state\n newstate = state_transition_out\n newiteration = @iteration\n if [:day, :signup].include?(@state)\n newiteration = @iteration + 1\n end\n @state = newstate\n @iteration = newiteration\n #state_transition_in\n @state\n end",
"def live\r\n @state=1\r\n end",
"def start_falling(event)\n event.obfalling = 1\n event.move_speed = 4.5\n event.through = true\n event.fallbyjump.nil? ? event.move_away_from_player : event.fallbyjump = nil\n RPG::SE.new(FallSe,80).play \n @eve_fall.push(event) unless @eve_fall.include?(event)\n @eve_fall = @eve_fall.uniq \n @player_busy = event.picked = false if event.picked\n end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def wakeup; end",
"def back_track()\n @ole.BackTrack()\n end",
"def tick events\n @outerlimit = (battlefield_width + battlefield_height) * 3\n #print \"mode=#{@mode},stage=#{@stage},dir=#{@dir},walldir=#{@walldir}\\n\"\n #print \"at (#{x},#{y}) at time #{time},res=#{@trk_res}\\n\"\n #mode nil is startup and initialize variables\n #STDOUT.flush\n # ###########\n # # Sensors\n # ###########\n @since_evade += 1\n @sincehit += 1\n @sincehit = 0 if not events['got_hit'].empty?\n events['got_hit'].each{|e| @hit_filter += e.first}\n @hit_filter *= 0.99\n if events['robot_scanned'].empty?\n @sinceblip += 1\n @closest = @outerlimit\n #print\"\\n\" \n else\n @closest = events['robot_scanned'].collect{|e| e.first}.sort.first\n @sinceblip = 0\n #print \",blip=#{@closest}\\n\"\n end\n # ###########\n # # High level logic - state machine\n # ###########\n #print \"sincehit=#{@sincehit},closest=#{@closest},range=#{@range}\\n\"\n #mode 0 is orient tank\n if @mode == 0\n @stage = 0\n @range = @outerlimit\n @mode = 1 if aimrad(@dir*90)\n #mode 1 find range of nearest target\n elsif @mode == 1\n #setup radar for a scan\n if @stage==0\n aimrad(@dir*90 + 180,60,1)\n @range = min(@range,@closest)\n @stage +=1\n #continue around for full circle\n elsif @stage == 1\n @range = min(@range,@closest)\n if aimrad(@dir*90,60,1)\n #did we see a bot?\n if @range == @outerlimit\n @stage = 0 \n else\n @mode = 2\n @stage = 0\n end\n end\n end\n #mode 2: find the nearestbot\n elsif @mode == 2\n #start next circle to re find the closest bot\n if @stage == 0\n #print \"range is #{@range}\\n\"\n aimrad(@dir*90 + 180,60,1)\n @stage +=1\n #continue scan for the closest bot\n elsif @stage == 1\n #print \"dir=#{@dir},angle=#{radar_heading}, closest=#{@closest}\\n\"\n if @closest < @range * 1.25\n @range = @closest\n @mode = 3\n @stage = 0\n @tangle = radar_heading\n #print \"found target at angle #{@tangle}\\n\"\n #if we finished the scan, and didn't find close target, recompute range\n elsif aimrad(@dir*90,60,1)\n @mode = 0\n @stage =0\n end\n end\n #mode 3 is tracking bot\n elsif @mode == 3\n #entry from previous mode, determine whether to scan ccw or cw\n if @stage == 0\n @trk_dir,@trk_res,@stage = -1,4,2\n #first scan in this direction\n elsif @stage == 1\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n else\n @stage = 2\n end\n #second scan in this direction\n elsif @stage == 2\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n else\n @trk_dir = -@trk_dir\n @trk_res = min(@trk_res + 2,4)\n @stage = 3\n end\n #the target bot has moved out of our window, expand the window\n elsif @stage == 3\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = - @trk_dir\n @trk_res = max(@trk_res - 2,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n elsif @trk_res < 6\n @trk_dir = - @trk_dir\n @trk_res = @trk_res +1\n else\n #we lost our target, reaquire from scratch\n @mode = 0\n @stage = 0\n end\n end\n @tangle += @@ScanRes[@trk_res] * @trk_dir\n aimrad(@tangle)\n #print\"tangle=#{@tangle}, res=#{@@ScanRes[@trk_res]}, rot=#{@trk_dir}\\n\"\n elsif @mode == 4\n #determine which corner to go to from a corner\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 + 95*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 60*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @prevCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n elsif @stage == 3\n aimrad(@dir*90 -5*@walldir)\n @stage += 1\n elsif @stage == 4\n @nextCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + @walldir)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n elsif @mode == 5\n #determine which corner to go to from middle of wall\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 - 5*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @nextCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 150*@walldir)\n @stage += 1\n elsif @stage == 3\n @stage += 1 \n aimrad(@dir*90 -150*@walldir)\n elsif @stage == 4\n aimrad(@dir*90 -185*@walldir)\n @stage += 1\n elsif @stage == 5 \n @prevCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + 2)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n end\n #compute the distances to the four walls\n walls = [battlefield_width - x,y,x,battlefield_height - y]\n #hug the wall, if we are slightly off the wall, than move back to the wall\n toleftwall,torightwall = walls[(@dir+1)%4],walls[(@dir-1)%4]\n #print \"wallroom left=#{toleftwall}, right=#{torightwall}\\n\"\n if toleftwall > 80 and toleftwall < 200\n aimtank(@dir * 90 + 20)\n elsif torightwall > 80 and torightwall < 200\n aimtank(@dir * 90 - 20)\n else\n aimtank(@dir * 90)\n end\n #If we reach a corner or wall, turn towards farthest corner on this wall\n if walls[@dir] < 100\n if toleftwall > torightwall\n @walldir = 1 #we are now going ccw\n @dir = (@dir+1)%4 # turn ccw\n #print \"turn left\\n\" \n else\n @walldir = -1 #we are now going cw\n @dir = (@dir-1)%4 #turn cw\n #print \"turn right\\n\" \n end\n #don't check corners at T junction\n if toleftwall > 100 and torightwall > 100\n @mode = 5 # determin weather it is safer ahead or behind\n @stage = 0\n else\n @mode = 4 # determin if previous corner was safer\n @stage = 0\n end\n #If we are getting hammered, turn now to evade damage\n # once we evade, avoid making another evasive manuver or we will turn in circles\n elsif @hit_filter > 400 and @since_evade > 100\n @dir = (@dir+@walldir)%4\n @hit_filter = 0\n @since_evade = 0\n end\n accelerate 1\n aim = @mytrack.predict(x,y,time) || (@dir * 90)%360\n aimgun(aim)\n fire 0.1\n doturns #we already computed our turns, now execute them\n STDOUT.flush\n end",
"def run_next\n event = plan.action(state).new(event_log).execute\n event_log << event\n end",
"def on_state_begin(state_id)\n end",
"def steps_before_repeat_state_naive\n\t\t# state = {}\n\t\tsteps = 0\n\t\torig = @moons_pos.to_s\n\t\tzero_vel = [0, 0, 0]\n\t\tstarting_time = Time.now\n\t\tp @moons_pos\n\t\twhile (42)\n\t\t\tsleep(1)\n\t\t\t# state.has_key?(@moons_pos.to_s) ? break : state[@moons_pos.to_s] = true\n\n\t\t\tapply_gravity_to_velocity\n\t\t\tapply_velocity_to_position\n\t\t\tsteps += 1\n\t\t\tp @moons_pos\n\t\t\tbreak if velocity(:io) == zero_vel && @moons_pos.to_s == orig\n\t\tend\n\t\tsteps\n\tend",
"def fetch_next_week_events_and_analyze\n events = fetch_next_week_events\n analyze_events(events)\n end",
"def backtrack\n @state = @backtrack_states.pop\n if @verbose\n puts \"log: backtrack to last valid state\"\n end\n end",
"def update\n\t\t\t@current_state.objs.each do |obj|\n\t\t\t\tif obj.life <= 0\n\t\t\t\t\tobj.destroy\n\t\t\t\t\t@current_state.objs.delete obj\n\t\t\t\t\t@current_state.events.each_key do |event|\n\t\t\t\t\t\t@current_state.events[event].each do |x|\n\t\t\t\t\t\t\tif x.owner == obj\n\t\t\t\t\t\t\t\t@current_state.events[event].delete x\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\t#@current_state.objs.each do |obj|\n\t\t\t#\t@current_state.objs[@current_state.objs.index(obj)+1..-1].each do |obj2|\n\t\t\t#\t\tunless collision_between(obj, obj2)\n\t\t\t#\t\t\tnext\n\t\t\t#\t\tend\n\t\t\t#\t\tobj.collision obj2\n\t\t\t#\t\tobj2.collision obj\n\t\t\t#\tend\n\t\t\t#end\n\t\t\n\t\t\t@queue.each do |ev|\n\t\t\t\tcase ev\n\t\t\t\t\twhen Rubygame::QuitEvent\n\t\t\t\t\t\tRubygame.quit\n\t\t\t\t\t\texit\n\t\t\t\t\twhen Rubygame::KeyDownEvent\n\t\t\t\t\t\t[@current_state.events, @global_events].each do |events|\n\t\t\t\t\t\t\tevents[:key_press].each do |x|\n\t\t\t\t\t\t\t\tif ev.key == x.key\n\t\t\t\t\t\t\t\t\tx.call\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\t\t\tevents[:while_key_down].each do |x|\n\t\t\t\t\t\t\t\tif ev.key == x.key\n\t\t\t\t\t\t\t\t\tx.active = true\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\t\t\tevents[:while_key_up].each do |x|\n\t\t\t\t\t\t\t\tif ev.key == x.key\n\t\t\t\t\t\t\t\t\tx.active = false\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\twhen Rubygame::KeyUpEvent\n\t\t\t\t\t\t[@current_state.events, @global_events].each do |events|\n\t\t\t\t\t\t\tevents[:key_release].each do |x|\n\t\t\t\t\t\t\t\tif ev.key == x.key\n\t\t\t\t\t\t\t\t\tx.call\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tevents[:while_key_down].each do |x|\n\t\t\t\t\t\t\t\tif ev.key == x.key\n\t\t\t\t\t\t\t\t\tx.active = false\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tevents[:while_key_up].each do |x|\n\t\t\t\t\t\t\t\tif ev.key == x.key\n\t\t\t\t\t\t\t\t\tx.active = true\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\twhen Rubygame::MouseDownEvent\n\t\t\t\t\t\t[@current_state.events, @global_events].each do |events|\n\t\t\t\t\t\t\tevents[:mouse_press].each do |x|\n\t\t\t\t\t\t\t\tif ev.button == x.button\n\t\t\t\t\t\t\t\t\tx.call ev.pos\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\twhen Rubygame::MouseUpEvent\n\t\t\t\t\t\t[@current_state.events, @global_events].each do |events|\n\t\t\t\t\t\t\tevents[:mouse_release].each do |x|\n\t\t\t\t\t\t\t\tif ev.button == x.button\n\t\t\t\t\t\t\t\t\tx.call ev.pos\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\twhen Rubygame::MouseMotionEvent\n\t\t\t\t\t\t[@current_state.events, @global_events].each do |events|\n\t\t\t\t\t\t\tevents[:mouse_motion].each do |x|\n\t\t\t\t\t\t\t\tx.call ev.pos, ev.rel, ev.buttons\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\tend\n\t\t\t\n\t\t\t@current_state.events[:while_key_down].each do |x|\n\t\t\t\tif x.active\n\t\t\t\t\tx.call\n\t\t\t\tend\n\t\t\tend\n\t\t\t@global_events[:while_key_down].each do |x|\n\t\t\t\tif x.active\n\t\t\t\t\tx.call\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\t@current_state.events[:while_key_up].each do |x|\n\t\t\t\tif x.active\n\t\t\t\t\tx.call\n\t\t\t\tend\n\t\t\tend\n\t\t\t@global_events[:while_key_up].each do |x|\n\t\t\t\tif x.active\n\t\t\t\t\tx.call\n\t\t\t\tend\n\t\t\tend\n\t\t\n\t\t\t@current_state.objs.each do |obj|\n\t\t\t\tobj.update\n\t\t\tend\n\t\t\t\n\t\t\t@current_state.update\n\t\t\t\n\t\t\t@current_state.objs += @objs2\n\t\t\t@current_state.objs.sort! { |a,b| (a.depth or 0) <=> (b.depth or 0) } unless @objs2.empty? # Sort by depth\n\t\t\t@objs2 = []\n\t\t\t\n\t\t\tif @state_buffer != nil\n\t\t\t\t@state_buffer.call\n\t\t\t\t@state_buffer = nil\n\t\t\tend\n\t\tend",
"def _wait_until_events\n config.event_queue.pop.tap do |_event|\n @_remember_time_of_first_unprocessed_event ||= MonotonicTime.now\n end\n end",
"def reset\n @events = []\n end",
"def next_batch()\n @mutex.lock\n begin\n state_check.slice!(0, state_check.length) + pending.slice!(0,pending.length)\n ensure\n @mutex.unlock rescue nil\n end\n end",
"def react!\n @started_at = Time.now\n EM.next_tick do \n\tEM.add_periodic_timer(TICK_INTERVAL) do\n\t @last_tick ||= 0\n\t # puts \"==== tick! last one was #{Time.now - @last_tick} ago\"\n\t @last_tick = Time.now\n\n\t # moves = @next_moves\n\t removals = @scheduled_removals.dup\n\n\t removals.each do |entity|\n\t entity_group = @entities.detect { |es| es.include?(entity) }\n\n\t if entity_group\n\t sockets.values.each do |s|\n\t\tdata = {depth: @entities.index(entity_group), entity_id: entity.guid }\n\t\ttransmit 'removal', data, s\n\t end\n\t end\n\n\t puts \">>>> DELETING ENTITY\"\n\t entity_group.delete(entity) if entity_group\n\t @scheduled_removals.delete(entity)\n\n\t # recompute all fovs? (seems like we could at least limit to heroes on this level, but should really be a question of asking the heroes if the object is visible)\n\t # timing of this could also be problematic\n\n\t heroes.each { |h| h.build_fov_map }\n\t end\n\n\t # step!\n\t @heroes.each { |h| h.update }\n\n\t @next_moves.each do |entity, direction|\n\t if move(entity, direction)\n\t # entity.recompute_fov if entity.is_a?(Hero)\n\t # end\n\t # end\n\n\t # moves.each do |entity, _|\n\t sockets.values.each do |s|\n\t\tif entity.is_a?(Roguecraft::Hero)\n\t\t message_data = entity.attributes.merge({\n\t\t visible: entity.now_visible,\n\t\t invisible: entity.now_invisible\n\t\t })\n\t\t puts \"=== currently visible: #{entity.now_visible.inspect}\"\n\t\t transmit 'move', message_data, s\n\t\tend\n\t end\n\t end\n\t end\n\n\t @next_moves = {}\n\tend\n end\n end",
"def refresh_magic_chests\n @map.events.each_value do |event|\n if event.name =~ Chest_Service::CHEST_REGX\n chest_state = Chest_Service.get_online_state_chest($1)\n case chest_state\n when Chest_Service::CHEST_EMPTY\n local_a = true\n local_b = false\n when Chest_Service::CHEST_FULL\n local_a = false\n local_b = false\n when Chest_Service::DATA_ERROR\n local_a = false\n local_b = true\n else\n local_a = false\n local_b = true\n end\n sw_a = [@map_id, event.id, 'A']\n sw_b = [@map_id, event.id, 'B']\n $game_self_switches[sw_a] = local_a\n $game_self_switches[sw_b] = local_b\n end\n end\n end",
"def reap; end",
"def next_event\n @queue.pop\n end",
"def reset_exy_cache\n @events.keys.each do |id|\n e = @events[id]\n next if !e\n @exy_cache[[e.x,e.y]].push(id) if !(@exy_cache[[e.x,e.y]]||=[]).include?(id)\n end\n end",
"def enter_state\n end",
"def restore_held_pages\n current_page = 1\n held_pages = find_outputs collection, {'fetched' => '0'}, current_page, per_page\n while !held_pages&.first.nil? do\n held_pages.each do |output|\n # Parse and seed pages\n held_page = output['page'].is_a?(String) ? JSON.parse(output['page']) : output['page']\n fix_page! held_page\n pages << held_page\n\n output['fetched'] = '1'\n outputs << output\n end\n\n # Fetch next page\n current_page += 1\n enqueue pages\n save outputs\n held_pages = find_outputs collection, {'fetched' => '0'}, current_page, per_page\n end\n end",
"def closure!\ns0 = new_state\ns1 = new_state\nadd_transition(s0, @start, \"\")\n# reset the final states of the current object\nkeys = @final.keys\ni = 0\nwhile i < keys.size\nadd_transition(keys[i], s1, \"\")\nset_final(keys[i], false)\ni = i + 1\nend\nadd_transition(s0, s1, \"\")\nadd_transition(s1, s0, \"\")\nset_start(s0)\nset_final(s1, true)\nend",
"def rest\n @state -= 1 if @state > 2\n @state += 1 if @state < 2\n end",
"def wakeup() end",
"def fetch_scrollback(last_event_id)\n event_sent = false\n if last_event_id\n channels.each do |channel|\n channel.scrollback(since: last_event_id).each do |event|\n event_sent = true\n queue.push(event)\n end\n end\n end\n\n queue.push(Pubsubstub.heartbeat_event) unless event_sent\n end",
"def extra_state; end",
"def wait_for_state_transitions\n # don't wait for anything unless told otherwise\n end",
"def update_generation\n return if @next_state.nil?\n\n state_changed = self.alive != @next_state\n self.alive = @next_state\n @next_state = nil\n state_changed\n end",
"def next_state\n STATE_SIZE.times do |i|\n mix = @state[i] & 0x80000000 | @state[i+1 - STATE_SIZE] & 0x7fffffff\n @state[i] = @state[i+OFFSET - STATE_SIZE] ^ (mix >> 1)\n @state[i] ^= 0x9908b0df if mix.odd?\n end\n @last_read = -1\n end",
"def goaway!\n goaway block: true\n end",
"def rest\n if @state > 2\n @state -= 1\n elsif @state < 2\n @state += 1\n end\n end",
"def after_cycle\n end",
"def new_state\nnewID = @@nextID\n@@nextID += 1\n@state[newID] = true\n@transition[newID] = {}\nnewID\nend",
"def after_state(state)\n end",
"def closure! \n\t\ttemp = new_state\n\t\tadd_transition(temp, @start, \"\")\n\t\t@start = temp\n\t\ttemp = new_state\n\t\t@final.keys.sort.each { |x| \n\t\tadd_transition(x, temp, \"\") \n\t\tset_final(x, false) }\n\t\t\n\t\t@final = {temp=>true}\n\t\tadd_transition(@start, temp, \"\")\n\t\tadd_transition(temp, @start, \"\")\n\t\t@state.delete(nil)\n\t\t@transition.delete(nil)\n end",
"def next_state_events\n\n t = self.state_transitions(:from => self.state.to_sym)\n authorized_events = Array.new\n\n t.each do |transition|\n #if (is_authorized_event?(transition.event.to_s, user.role.name, self.state))\n authorized_events << transition\n #end\n end\n authorized_events\n end",
"def on?; self.refresh!['state']['on']; end",
"def bridge_all_traffic_state\n super\n end",
"def next_event\n event = @events.shift # shifts the array, returning next event and removing it from the array\n event.treated = true # sets event's treated flag to true\n return event\n end",
"def new_state\n newID = @@nextID\n @@nextID += 1\n @state[newID] = true\n @transition[newID] = {}\n newID \n end",
"def new_state\n newID = @@nextID\n @@nextID += 1\n @state[newID] = true\n @transition[newID] = {}\n newID \n end",
"def new_state\n newID = @@nextID\n @@nextID += 1\n @state[newID] = true\n @transition[newID] = {}\n newID \n end",
"def next_event\n @events_mutex.synchronize do\n @events.shift\n end\n end",
"def chain_state\n super\n end",
"def notify_new_traversal\n @item = @queue.shift\n @layers = @item.each\n @layer = @layers.next\n @index = 0\n end",
"def transition_at; end",
"def transition_at; end",
"def test_resetting_walker\n oid = \"8496071c1b46c854b31185ea97743be6a8774479\"\n @walker.push(oid)\n walk = @walker.each.to_a\n assert_equal oid, walk[0].oid\n assert_equal 1, walk.count\n @walker.reset\n walk = @walker.each.to_a\n assert_equal 0, walk.count\n end",
"def hits_prev\n # see PsiBlastJob for comment\n end",
"def compute_unreachable_states\n queue = [starting_state].to_set\n transitions = self.each_transition.to_a.dup\n\n done_something = true\n while done_something\n done_something = false\n transitions.delete_if do |from, _, to|\n if queue.include?(from)\n queue << to\n done_something = true\n end\n end\n end\n\n transitions.map(&:first).to_set\n end",
"def fetch\n @start_time ||= (Time.current - 1.minute).to_i * 1000\n $mw_log.debug \"Catching Events since [#{@start_time}]\"\n\n new_events = @alerts_client.list_events(\"startTime\" => @start_time, \"tags\" => \"miq.event_type|*\", \"thin\" => true)\n @start_time = new_events.max_by(&:ctime).ctime + 1 unless new_events.empty? # add 1 ms to avoid dups with GTE filter\n new_events\n rescue => err\n $mw_log.info \"Error capturing events #{err}\"\n []\n end",
"def transition_from_pending\n enter_transcoding if Transcoder.available.any?\n end",
"def update_state\n raise \"Nothing to do\"\n end",
"def pre_loop; end",
"def read_backwards\n\t\t_read(EVENTLOG_SEQUENTIAL_READ | EVENTLOG_BACKWARDS_READ)\n\tend",
"def nip_it_in_the_bud\n while has_bud?(@sequence) do\n @sequence.shift\n @sequence.each { |entry| entry.level -= 1 }\n end\n end",
"def process_next_gevent\r\n #@log.info \"Process next event\"\r\n return if @suspend_queue_proc == true\r\n while @proc_queue.size > 0\r\n next_ev_handl = @proc_queue.pop\r\n send(next_ev_handl)\r\n return if @suspend_queue_proc == true\r\n end\r\n \r\n end",
"def advance\n if @days_until_next <= 0\n @state = :shock\n @days_until_next = @rng.call\n else\n @state = :normal\n @days_until_next -= 1\n end\n end",
"def untick; end",
"def rewind\n @seen.clear\n super\n end"
] |
[
"0.61940235",
"0.5989247",
"0.5892048",
"0.58775",
"0.57524645",
"0.574811",
"0.56952465",
"0.56202465",
"0.560294",
"0.560268",
"0.560268",
"0.55705076",
"0.55705076",
"0.5558158",
"0.55566275",
"0.5553874",
"0.5528348",
"0.55066186",
"0.5484289",
"0.5484289",
"0.5472873",
"0.5451234",
"0.54475176",
"0.54359984",
"0.5432638",
"0.5411702",
"0.5410291",
"0.540451",
"0.5403994",
"0.5395056",
"0.5393616",
"0.53836757",
"0.5383256",
"0.5367794",
"0.53670615",
"0.5355302",
"0.5355302",
"0.5355302",
"0.5355302",
"0.5355302",
"0.5355302",
"0.5355302",
"0.5355302",
"0.5334822",
"0.5329446",
"0.53264475",
"0.53185815",
"0.53174734",
"0.5316515",
"0.5305857",
"0.53007114",
"0.53004295",
"0.5291685",
"0.52887547",
"0.52867025",
"0.52853864",
"0.52648705",
"0.5262865",
"0.5246795",
"0.5244384",
"0.5236215",
"0.5227861",
"0.5221829",
"0.5220738",
"0.521889",
"0.5204218",
"0.52041876",
"0.51983774",
"0.5195453",
"0.5173056",
"0.5171728",
"0.51672214",
"0.5154156",
"0.5147152",
"0.5144011",
"0.51389444",
"0.5120247",
"0.511751",
"0.5111391",
"0.51045805",
"0.50857395",
"0.50857395",
"0.50857395",
"0.50852066",
"0.5075725",
"0.5069086",
"0.5067536",
"0.5067536",
"0.5063939",
"0.5062006",
"0.5054007",
"0.5051078",
"0.50509924",
"0.504836",
"0.5045135",
"0.50382197",
"0.5038008",
"0.50287557",
"0.5021836",
"0.5019605",
"0.5013208"
] |
0.0
|
-1
|
fetch the latest events from mingle, i.e., the ones not previously seen
|
def fetch_latest
page = page_with_latest_entries
most_recent_new_entry = page.entries.first
last_fetched_entry = @entry_cache.latest
last_fetched_entry_seen = false
next_entry = nil
while !last_fetched_entry_seen && page
page.entries.each do |entry|
@entry_cache.write(entry, next_entry)
if last_fetched_entry && entry.entry_id == last_fetched_entry.entry_id
last_fetched_entry_seen = true
break
end
next_entry = entry
end
page = page.next
end
@entry_cache.update_current_state(next_entry, most_recent_new_entry)
@entry_cache.entries(next_entry, most_recent_new_entry)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fetch\n @start_time ||= (Time.current - 1.minute).to_i * 1000\n $mw_log.debug \"Catching Events since [#{@start_time}]\"\n\n new_events = @alerts_client.list_events(\"startTime\" => @start_time, \"tags\" => \"miq.event_type|*\", \"thin\" => true)\n @start_time = new_events.max_by(&:ctime).ctime + 1 unless new_events.empty? # add 1 ms to avoid dups with GTE filter\n new_events\n rescue => err\n $mw_log.info \"Error capturing events #{err}\"\n []\n end",
"def events\n object.events.last(10)\n end",
"def sync_events\n events = @last_event_id ? @room.events_after(@last_event_id) :\n @room.recent_events(512)\n return if events.empty?\n respond_recent_events events\n end",
"def latest_events\n events = get_stack_events.select do |event|\n event.timestamp > @last_time\n end\n\n @last_time = Time.now\n\n filter_events(events.sort_by(&:timestamp))\n end",
"def fetch_next_week_events\n return [] unless sources.try(:first).present?\n\n source = sources.first\n source.refresh_token_if_expired\n\n gdata = Googledata.new\n gdata.pull(source.oauth_token)\n end",
"def events\n return if @events.empty?\n @events.uniq.sort\n end",
"def fetch_events\n params = {'calendarId' => CONFIG[:cal_id], \n 'orderBy' => 'startTime',\n #'timeMax' => Time.utc(CONFIG[:year].to_i + 1, 4, 1).iso8601, \n #'timeMin' => Time.utc(CONFIG[:year].to_i, 4, 1).iso8601,\n 'singleEvents' => 'True'}\n \n result = @client.execute(:api_method => @cal.events.list, :parameters => params)\n\n @events_list = []\n result.data.items.each do |item|\n @events_list << item\n end\n end",
"def events_for target, event_types\n url = GITHUB_EVENT_API_END_POINT % target\n etag = @etag_hash[target]\n last_event = @last_event_hash[target]\n\n events_to_send = []\n page = 1\n while page <= 10\n result = @clnt.get(url, {client_id: @client_id, client_secret: @client_secret}, {\"If-None-Match\" => etag})\n break unless result.status_code == 200\n events = JSON.load result.body\n if page == 1 # etag and last event should be set when querying the very first page\n @etag_hash[target] = result.header[\"etag\"]\n @last_event_hash[target] = events[0]\n end\n\n events.each do |event|\n return events_to_send if last_event == event # no need to proceed\n events_to_send << event if event_types.accept? event\n end\n\n page += 1\n end\n\n events_to_send\n end",
"def pop\n @events.pop\n end",
"def recent_events\n Event.includes(:user).where(group_id: self.id).limit(50).order(created_at: :desc).reverse\n end",
"def events\n metadata['events'].sort_by! { |event| event['timestamp'] }\n end",
"def latest_event(&blk)\n latest_event = nil\n page = 1\n count = 100\n loop do\n events = @client.issue_events(@issue.number, per_page: count, page: page)\n matching_events = events.select(&blk)\n latest_event = matching_events.last unless matching_events.empty?\n page += 1\n break if events.length < count\n end\n latest_event\n end",
"def upcoming_events\n [] || Event.where('event_start_date > :date AND event_end_date > :date AND status = :status', {date: Time.now.strftime('%Y-%m-%d'), status: Event.statuses.ready}).limit(3)\n end",
"def fetch_events\n Smash[\n @connection.stacks.reload.map do |stack|\n [stack.id,\n Smash.new(\n :events => stack.events.map(&:attributes),\n :status => stack.stack_status,\n :stack_name => stack.stack_name\n )\n ]\n end\n ]\n end",
"def future_events\n instances = []\n Event.where(place: self).each do |e|\n instances << e.occurrences.where(date: Date.current..2.weeks.from_now)\n end\n instances.flatten!.sort_by(&:date) unless instances.empty?\n end",
"def previous_events\n self.around_events.select{|event|\n event.location.present? && event.end_time < self.start_time\n }.sort{|a,b| a.end_time <=> b.end_time}\n end",
"def get_current_events\n events = get_events\n current_events = []\n \n events.each do |event| \n if event.date > DateTime.now and event.date < DateTime.now + 2.months\n current_events << event\n end\n end\n \n return current_events\n end",
"def find_events(event)\n events = []\n name = event.name\n category = event.category\n description = event.description\n snapshots = find_project_snapshots(event.snapshot_id)\n snapshots.each do |snapshot|\n snapshot.events.reject { |e| e.name!=name || e.category!=category }.each do |event|\n events << event\n end\n end\n events\n end",
"def late_events\n candidate_events.select(&:late?)\n end",
"def found_events\n @mood.events\n end",
"def events\n @events ||= []\n @events\n end",
"def all\n gen_feed Event.find(:all, :limit => @@limit, :order => 'id DESC'), 'All Events';\n end",
"def events\n lfm_path = \"artist.getevents&artist=#{@name}\"\n lfm_data = LastFm::fetch_data(lfm_path)\n return Event.create_from_hash(Hash.from_xml(lfm_data)['lfm']['events']['event']) \n end",
"def get_events(trace: false, &block)\n r = dropbox_query(query: '2/team_log/get_events', trace: trace)\n r['events'].each(&block)\n while r['has_more']\n r = dropbox_query(query: '2/team_log/get_events/continue', query_data: \"{\\\"cursor\\\":\\\"#{r['cursor']}\\\"}\", trace: trace)\n r['events'].each(&block)\n end\n end",
"def get_events\n events = []\n until ((event = SDL.PollEvent) == nil)\n new_event = Events.match(event)\n if new_event.is_a?(Events::KeyReleased)\n @keys_being_repeated.delete(new_event.key)\n end\n if new_event.is_a?(Events::KeyPressed) and not @keys_being_repeated.include?(new_event.key)\n @keys_being_repeated << new_event.key\n end\n events << new_event\n end\n @keys_being_repeated.each {|num| events << Events::KeyPressed.new(num)}\n events\n end",
"def events\n # FIXME this logic belongs in the Event model. stop leaking AR outside of the model\n @events ||= Event.includes(:upcoming_observances).where(\"observances.start_on >= ?\", Date.current).references(:observances)\n end",
"def next_events\n self.around_events.select{|event|\n event.location.present? && event.start_time > self.end_time\n }.sort{|a,b| a.start_time <=> b.start_time}\n end",
"def events\n @events ||= user_events.concat(org_events).uniq\n end",
"def events\n @events ||= {}\n end",
"def fetch_non_favorite_bar_events()\n events = Hash.new\n temp = Bar.find(:all, :select => 'bars.name, bar_events.detail', :joins => :bar_event, :conditions => ['bars.id not in (select bar_id from favorites where user_id = ?) and verified = 1', [self.id] ])\n for t in temp do\n\t if events.key?(t.name)\n\t events[t.name] << t.detail\n\t else\n\t events[t.name] = [t.detail]\n\t end\n\tend\n\t\n\tevents\n end",
"def flattened_events\n _result = []\n _events = events\n\n while event = _events.pop do\n match = _events.find { |e| e == event }\n if match.nil?\n _result << event\n else\n match.increment_frequency\n end\n end\n\n _result\n end",
"def get_events()\n\t\tevents = []\n\n\t\t@DB[:events].order(:date).each do |event|\n\t\t\tnewTimeslots = []\n\t\t\t@DB[:timeslots].where(parent_table: 'events', parent_id: event[:'id']).each do |timeslot|\n\t\t\t\tnewTimeslots.push(DateTime.parse(timeslot[:'time']))\n\t\t\tend\n\n\t\t\tnewAttendees = []\n\t\t\t@DB[:attendees].where(parent_id: event[:'id']).each do |attendee|\n\t\t\t\tattendeeTimeslots = []\n\t\t\t\t@DB[:timeslots].where(parent_table: 'attendees', parent_id: attendee[:'id']).each do |timeslot|\n\t\t\t\t\tattendeeTimeslots.push(DateTime.parse(timeslot[:'time']))\n\t\t\t\tend\n\n\t\t\t\tnewAttendee = Attendee.new(attendee[:'name'], attendeeTimeslots)\n\t\t\t\tnewAttendees.push(newAttendee)\n\t\t\tend\n\n\t\t\tnewEvent = Event.new(event[:'name'], event[:'description'], newTimeslots, newAttendees, event[:'id'])\n\t\t\tif newEvent.get_date >= @epoch\n\t\t\t\tevents.push(newEvent)\n\t\t\tend\n\t\tend\n\n\t\treturn events\n\tend",
"def fetch_events(app_name, env_name, options={})\n @event_fetched_times += 1\n set_env_ready(app_name, env_name, true) # assume env become ready after it spit out all the events\n\n unless @events # unrestricted mode for testing if no explicit events set\n return [generate_event_from_messages(['Successfully deployed new configuration to environment',\n 'terminateEnvironment completed successfully',\n 'Successfully launched environment',\n 'Completed swapping CNAMEs for environments'\n ], Time.now + @event_fetched_times), nil]\n end\n\n events = @events[env_key(app_name, env_name)][@event_fetched_times - 1]\n\n if options.has_key?(:start_time)\n start_time = Time.parse(options[:start_time])\n events = events.select { |e| e[:event_date] >= start_time }\n end\n\n if limit = options[:max_records]\n events = events[0..limit]\n end\n\n [events, nil]\n end",
"def past_events\n events.where(\"date < ?\", Time.now)\n end",
"def last_events(n = 0)\n visited_events = visited\n m = n > visited_events.count ? visited_events.count : n\n visited[-m..-1].to_a\n end",
"def event_list\n events_list\n end",
"def fetch_top_events(params={}, save_to_db=true)\n params = setup_params(params)\n self.model_class = ::Mixpanel::Event\n \n method_url = get_method_url('events', 'top')\n request_params = self.select_params(params, [:type, :limit, :bucket])\n request_params[:resource] = method_url\n \n data = send_request(request_params)\n \n is_empty = (data.blank? || data['events'].blank?)\n if save_to_db && !is_empty\n target_ids = get_target_ids(params) \n \n self.model_class.transaction do\n data['events'].each do |event|\n target_id = event['event']\n # Format to JSON data.\n json_data = {:events => event}.to_json\n \n self.insert_or_update(params, target_ids, \n target_id, json_data)\n end\n end \n end\n return data\n end",
"def pop_next_available\n unused_entries = []\n result = nil\n while (entry = pop)\n if entry.run_at <= Time.now\n result = entry\n break\n else\n unused_entries << entry\n end\n end\n unused_entries.each {|e| push(e) }\n result\n end",
"def upcoming_events\n events.where(\"date > ?\", Time.now)\n end",
"def events_now\n\n # Open empty array\n events = []\n\n # Loop over all the calendars\n CALENDARS.each do |name, id|\n\n # Get the events\n cal_events = calendar(id).find_events_in_range(Time.now, Time.now + 60)\n\n # Loop over each one and add it to the array\n cal_events.each do |e|\n events << {event: e, cal: name} unless e.nil?\n end\n\n end\n\n # Return the final list\n return events\n\nend",
"def reset_events_cache\n Event.where(target_id: self.id, target_type: 'Post').\n order('id DESC').limit(100).\n update_all(updated_at: Time.now)\n end",
"def get_next_calendar_events\n next_events = JSON.parse search_for_future_calendar_events\n next_events[\"items\"]\n end",
"def unfollowed_events\n events.where(visited: false).select do |event|\n !(event.next_event? || event.choices?)\n end\n end",
"def remove_preview_events(events, eventType)\n results = []\n prev = nil\n\n events.each do |r|\n\n if (!prev.nil? and r.event_type == eventType and\n DateTime.strptime(r.created_at).strftime(\"%M\").to_i - DateTime.strptime(prev.created_at).strftime(\"%M\").to_i <= 0)\n # repeat, do nothing\n else\n prev = r\n results << r\n end\n end\n results\n end",
"def show\n @events = Event.last(4).reverse \n end",
"def prune_events\n queue = Array.new(3)\n events_to_delete = []\n self.events.order('timestamp ASC').each do |e|\n queue.shift\n queue.push(e)\n next if queue.compact.size != 3\n event_type_id = e.event_type_id\n events_to_delete << e.id if queue.all?{|e| e.event_type_id == event_type_id}\n\n if events_to_delete.size >= 100\n Event.transaction do\n events_to_delete.each do |e|\n Event.delete(e)\n end\n end\n events_to_delete.clear\n end\n end\n\n Event.transaction do\n events_to_delete.each do |e|\n Event.delete(e)\n end\n events_to_delete.clear\n end\n true\n end",
"def events\n @events ||= event_finder\n end",
"def event_lookup(query_string = '') #:nodoc:\n begin\n response = send_events_request(query_string, :get)\n parsed_json = JSON.parse(response.body)\n @summary = parsed_json['summary']\n events = Event.build_from_google_feed(parsed_json, self) || []\n return events if events.empty?\n events.length > 1 ? events : [events[0]]\n rescue Google::HTTPNotFound\n return []\n end\n end",
"def get_events(num_per_slice = 20, part_no = 0)\n self.events.order(created_at: :desc)\n .limit(num_per_slice)\n .offset(num_per_slice * part_no)\n end",
"def get(name = nil, token = :last, not_found = :wait, found = :return, options = {})\n @raw = send_get_request(@conn, ['/v1/event/list'], options, use_named_parameter('name', name))\n body = JSON.parse(@raw.body)\n # TODO: deal with unknown symbols, invalid indices (find_index will return nil)\n idx = case token\n when :first then 0\n when :last then body.length - 1\n when :next then body.length\n else body.find_index { |e| e['ID'] == token } + 1\n end\n if JSON.parse(@raw.body).count.zero? || idx == body.length\n case not_found\n when :reject\n raise Diplomat::EventNotFound, name\n when :return\n event_name = ''\n event_payload = ''\n event_token = :last\n when :wait\n @raw = wait_for_next_event(['/v1/event/list'], options, use_named_parameter('name', name))\n @raw = parse_body\n # If it's possible for two events to arrive at once,\n # this needs to #find again:\n event = @raw.last\n event_name = event['Name']\n event_payload = Base64.decode64(event['Payload'])\n event_token = event['ID']\n end\n else\n case found\n when :reject\n raise Diplomat::EventAlreadyExits, name\n when :return\n event = body[idx]\n event_name = event['Name']\n event_payload = event['Payload'].nil? ? nil : Base64.decode64(event['Payload'])\n event_token = event['ID']\n end\n end\n\n {\n value: { name: event_name, payload: event_payload },\n token: event_token\n }\n end",
"def fetch_all_events(params={}, save_to_db=true)\n params = setup_params(params)\n self.model_class = ::Mixpanel::Event\n \n event_names = []\n if params[:event]\n if params[:event].is_a?(Array)\n event_names += params[:event]\n else\n event_names << params[:event]\n end\n else\n # Get names of events.\n event_names = self.fetch_event_names(params, false)\n end\n \n # Get events data.\n method_url = get_method_url('events')\n \n request_params = self.select_params(params, [:type, :unit, :interval, :format, :bucket])\n request_params[:resource] = method_url\n request_params[:event] = event_names.to_json\n puts \">>>>>>>>>>>>>>>>> #{request_params.inspect}\" \n event_data = send_request(request_params)\n puts \">>>>>>>>>>>>>>>>> #{event_data}\"\n # Detect event data is empty or not\n is_empty = (event_data.blank? || event_data[RESPONSE_KEYS[:legend_size]].to_i <= 0)\n if save_to_db && !is_empty\n self.model_class.transaction do \n # Get all target ids existing in DB, in order to detect data was changed or not.\n target_ids = get_target_ids(params)\n \n # Sample data:\n # {'data': {'series': ['2010-05-29',\n # '2010-05-30',\n # '2010-05-31',\n # ],\n # 'values': {'account-page': {'2010-05-30': 1,},\n # 'splash features': {'2010-05-29': 6,\n # '2010-05-30': 4,\n # '2010-05-31': 5,\n # }\n # }\n # },\n # 'legend_size': 2}\n\n # Goal: Store each event in a single record in DB. \n series_data = event_data['data']['series']\n values_data = event_data['data']['values']\n event_names.each do |event_name|\n event_values = values_data[event_name]\n next if event_values.blank?\n \n # Get only series related to the event.\n event_series = event_values.keys & series_data\n\n # Keep the original format of the event data (based on Mixpanel API spec).\n origin_data = {\n :data => {\n :series => event_series, \n :values => {event_name => event_values}\n },\n :legend_size => 1\n }\n \n # Format hash to JSON.\n json_data = origin_data.to_json\n \n self.insert_or_update(params, target_ids, \n event_name, json_data)\n end\n end\n end\n return event_data\n end",
"def all_events\n @events = Event.all\n end",
"def events\n @events = registered_application.events.group_by(&:name)\n end",
"def previous_events(event)\n # Initialise the hash to use an empty array as default value\n @dups ||= Hash.new { |h, k| h[k] = [] }\n one_hour_earlier = event.start.advance(:hours => -1)\n @dups[one_hour_earlier]\n end",
"def all\n @events = Event.order(updated_at: :desc).page(params[:page]).per(10)\n end",
"def retrieve(exchange)\n begin\n new = dupl = 0\n events = api_request \"https://api.github.com/events?per_page=100\"\n (new, dupl, stored) = store_count events\n\n # This means that the first page does not contain all new events. Do\n # a paged request and get everything on the queue\n if dupl == 0\n events = paged_api_request \"https://api.github.com/events?per_page=100\"\n (new1, dupl1, stored1) = store_count events\n stored = stored | stored1\n new = new + new1\n end\n\n stored.each do |e|\n repo = e['repo']['name'].gsub('/',' ')\n key = \"evt.#{e['type']}\"\n if @options[:projects_given]\n exchange.publish repo, :persistent => true, :routing_key => GHTorrent::ROUTEKEY_PROJECTS\n debug \"Published update to project #{repo}\"\n if @events_requeue.include? e['type']\n exchange.publish e['id'], :persistent => true, :routing_key => key\n end\n else\n exchange.publish e['id'], :persistent => true, :routing_key => key\n end\n end\n\n return new, dupl\n rescue StandardError => e\n STDERR.puts e.message\n STDERR.puts e.backtrace\n end\n end",
"def fetch_events(calendar_id)\n response = service.list_events(calendar_id,\n max_results: 5,\n single_events: true,\n order_by: \"startTime\",\n time_min: Time.now.iso8601,\n time_max: Date.today.+(1).to_time.iso8601)\n\n # filter out any declined events – they normally represent a clash or room release\n response.items.reject { |event|\n next if event.attendees.nil?\n event.attendees.all? { |attendee| attendee.response_status == \"declined\" }\n }\n end",
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def download_events(apiEngine)\n @events = []\n results = []\n results = apiEngine.client.execute!(\n :api_method => apiEngine.api.events.list,\n :parameters => {\n :calendarId => @ident,\n :singleEvents => true,\n :orderBy => 'startTime',\n :timeMin => @dateMin.iso8601,\n :timeMax => @dateMax.iso8601 })\n\n results.data.items.each do |event|\n if event.start.date_time\n fulldate = event.start.date_time.strftime(\"%B, %d, %Y\")\n month = fulldate.split(',')[0]\n day = fulldate.split(',')[1]\n year = fulldate.split(',')[2]\n else\n fulldate = event.start.date.to_s\n month = fulldate.split('-')[1].to_i\n month = I18n.t(\"date.month_names\")[month]\n day = fulldate.split('-')[2]\n year = fulldate.split('-')[0]\n end\n @events.push(Event.new(event.creator.email, year, month, day, :summary => event.summary))\n end\n end",
"def get_since(timestamp, limit=20)\n uri = '/api/v1/pulses/events'\n params = {limit: limit, since: timestamp}\n events = []\n begin\n json_data = get(uri, params)\n page = json_data['next']\n\n params = URI::decode_www_form(URI(page).query).to_h unless page.nil?\n\n events += json_data['results']\n end while !page.nil?\n\n results = []\n events.each do |event|\n results << OTX::Event.new(event)\n end\n\n return results\n end",
"def events(query)\n ret = Array.new\n \n feed = Feedjira::Feed.parse jira_query(query)\n \n feed.entries.each do |feed_evt|\n event = event_from_feed(feed_evt)\n event.person = query.person\n \n if (event.time < query.to && event.time > query.from)\n ret << event\n end\n end\n \n ret\n end",
"def index\n ReaderEvent.where(\"created_at < :time\", {:time => 3.minutes.ago}).each{|event| event.destroy}\n @reader_events = ReaderEvent.all.order(flow_number: :asc, id: :asc)\n end",
"def index\n @unmatch_event = @current_shop.events.unmatch_event.first\n @keyword_autoreply_events = @current_shop.events.keyword_autoreply_events\n end",
"def available_events\n\t\treturn current_room.events || []\n\tend",
"def fetch_next_week_events_and_analyze\n events = fetch_next_week_events\n analyze_events(events)\n end",
"def fetch_valid_test_events\n Event::NAME_CONFIG.each do |name, e_data|\n\n @client_webhook_setting.event_sources_array.each do |event_source|\n @client_webhook_setting.event_result_types_array.each do |result_type|\n\n next if result_type != e_data[:result_type] ||\n e_data[:inavlid_source].include?(event_source)\n\n event_data = GlobalConstant::Event.send(\"#{name}_event_data\")\n\n if event_source == GlobalConstant::Event.kyc_system_source\n event_data[:user_kyc_detail][:last_acted_by] = Admin::AUTO_APPROVE_ADMIN_ID\n end\n\n event = {\n client_id: @client_id,\n event_source: event_source,\n event_name: name,\n event_data: event_data,\n event_timestamp: Time.now.to_i,\n\n client_webhook_setting_id: @webhook_id,\n lock_id: lock_id\n }\n\n @valid_events[name] ||= []\n @valid_events[name] << event\n end\n end\n end\n end",
"def get_all_events\n events, cursor = get_paginated_first\n while cursor do\n next_events, cursor = get_paginated_next(cursor: cursor)\n events += next_events\n end\n events\n .map(&:to_i)\n end",
"def record_latest_event\n %i[published archived].each do |attribute_name|\n is_changed = send(\"#{attribute_name}_changed?\")\n is_true = send(attribute_name)\n next unless new_record? || is_changed\n\n history[attribute_name] = is_true ? Time.zone.today : nil\n end\n end",
"def run_once \n puts \"About to poll Mingle for new events...\"\n @processors_by_project_identifier.each do |project_identifier, processors|\n begin \n project_feed = ProjectFeed.new(project_identifier, @mingle_access)\n initial_event_count = @from_beginning_of_time ? :all : 25\n broadcaster = ProjectEventBroadcaster.new(project_feed, processors, state_file(project_identifier), initial_event_count)\n broadcaster.run_once \n rescue StandardError => e\n puts \"\\nUnable to retrieve events for project '#{project_identifier}':\"\n puts e\n puts \"Trace:\\n\"\n puts e.backtrace\n end\n end\n end",
"def all_events\n @unreads = current_user.unreads\n search_params = params.except(:utf8, :commit, :controller, :action, :page)\n if search_params.present?\n @events = Event.search(search_params, @unreads).order(\"created_at DESC\")\n @events = @events.paginate(:page => params[:page], :per_page => 5)\n else\n @events = Event.all.order(created_at: :desc).paginate(:page => params[:page], :per_page => 5)\n end\n end",
"def sync\n @events = nil\n each do |event|\n matching_event_page = @event_pages.find do |event_page|\n event_page.ical_url == event.url.to_s\n end\n\n if matching_event_page\n event.url = Icalendar::Values::Uri.new(matching_event_page.url)\n\n matching_event_page.title = event.summary\n # Dates are broken on Lanyrd: https://twitter.com/aslak_hellesoy/status/591272555035684864\n # Start dates is right, end date is wrong (!?!)\n # matching_event_page.dtstart = event.dtstart\n # matching_event_page.dtend = event.dtend\n end\n end\n end",
"def getFeaturedPastEvents\n @es = Event.where(private: false).where(\"date < ?\", Date.today).order(date: :desc)\n @f = @es.sort_by{ |e| [e.attendings.count, e.comments.count] }.reverse.take(3)\n return @f\n end",
"def events\n events = []\n now = Time.now\n @countdowns.times.each do |id, show_time|\n # Prevents extra refreshes\n latest_time = show_time.latest\n events << CalendarEvent.new(\n Shows.find_show(id.to_s).title,\n latest_time,\n latest_time + (60*60*3)\n ) unless (latest_time - now) > (60*60*24*7)\n end\n events.sort! {|a,b| a.start_time <=> b.start_time}\n end",
"def entries(limit=nil)\n limit ||= -1\n LiveJournal::Request::GetEvents.new(@user, :recent => limit, :strict => false).run\n end",
"def event_list\n @_events\n end",
"def other_events\n result = []\n final_result = []\n # we go through each entry in the file_set resource\n object.resource.each_entry do |e|\n entry_id = e.as_json[\"subject\"][\"@id\"]\n # we are only interested in entries that are nested and are missing in preservation_event md field\n if entry_id.include?(\"#nested\") && object.preservation_event.none? { |pe| pe.as_json[\"id\"] == entry_id }\n # append it to a result array\n result << [id: entry_id, predicate: e.as_json[\"predicate\"][\"@id\"], value: e.as_json[\"object\"][\"@value\"]]\n end\n end\n # once we have all required entries in the result array, we need to group them by their respective IDs\n grouping_by_id = result.group_by { |r| r.first[:id] }\n # once grouped, go through each value from the groupings of IDs\n grouping_by_id.each_value do |grouping|\n event_details = []\n event_type = event_end = event_start = initiating_user = outcome = software_version = ''\n # each grouping/value has a predicate and a value;\n # we go through each grouping and assign values to its respective variable\n # by matching the predicate\n grouping.each do |preservation_event|\n case preservation_event.first[:predicate]\n when \"http://metadata.emory.edu/vocab/cor-terms#eventDetails\" then event_details << preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventType\" then event_type = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventEnd\" then event_end = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventStart\" then event_start = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventUser\" then initiating_user = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventOutcome\" then outcome = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#softwareVersion\" then software_version = preservation_event_value(preservation_event)\n end\n end\n # once we have all the matching values in their respective variables,\n # we create a hash and append it to an array\n final_result << [\n {\n 'event_details' => event_details,\n 'event_type' => event_type,\n 'event_end' => event_end,\n 'event_start' => event_start,\n 'initiating_user' => initiating_user,\n 'outcome' => outcome,\n 'software_version' => software_version\n }.to_json\n ].first\n end\n # we finally return the array with hashes for the missing preservation_events\n final_result\n end",
"def index\n @upcoming_events = Event.upcoming_events\n @previous_events = Event.previous_events\n end",
"def check_events\n temp = poll_response\n index = 0\n puts temp if $debug\n # begin\n if temp.has_key?(\"people\")\n temp[\"people\"].each do |user|\n unless @people_hash.has_key?(user[\"screenname\"])\n @people_hash[user[\"screenname\"]] = user\n end\n end\n end\n unless temp == {}\n # begin\n temp[\"events\"].each do |event|\n key = \"#{event['server_seqid']}#{event['type']}\"\n unless @hash[key] == event[\"server_gmt\"]\n # puts event\n @api.process(event, @people_hash[event['from']]||nil, key)\n @hash[key] = event[\"server_gmt\"]\n end\n\n end\n # rescue\n # puts \"*****\"\n #@log.debug temp[\"events\"]\n # puts \"*****\"\n # puts temp\n # end\n end\n # rescue Exception => e\n # puts e.message, e.backtrace\n # end\n\n end",
"def index\n @events = Event.last_events(current_user, 3)\n end",
"def index\n @events = Event.order('updated_at DESC').page params[:page]\n end",
"def get_events(artist)\n this_uri = \"http://data.pollstar.com/api/pollstar.asmx/ArtistEvents?artistID=#{artist.ArtistID}&startDate=#{Time.now.strftime(\"%m/%d/%Y\")}&dayCount=0&page=0&pageSize=0#{ps_key}\"\n this_uri.gsub! \" \", \"\"\n\n doc = Nokogiri::XML(Net::HTTP.get(URI(this_uri)))\n all_artist_events = doc.xpath(\"//ArtistInfo//Events/Event\") \n\n all_artist_events.each do |ne|\n if Event.where(EventID: ne.attribute('EventID').to_s).count < 1\n event = Event.new\n city = City.new\n event.EventID = ne.attribute('EventID').to_s\n event.EventName = ne.attribute('EventName').to_s\n event.VenueID = ne.attribute('VenueID').to_s\n event.VenueName = ne.attribute('VenueName').to_s\n event.CityID = ne.attribute('CityID').to_s\n city.CityID = ne.attribute('CityID').to_s\n event.CityName = ne.attribute('CityName').to_s\n city.CityName = ne.attribute('CityName').to_s\n event.State = ne.attribute('State').to_s\n city.State = ne.attribute('State').to_s\n event.CountryName = ne.attribute('CountryName').to_s\n city.CountryName = ne.attribute('CountryName').to_s\n event.Region = ne.attribute('Region').to_s\n city.Region = ne.attribute('Region').to_s\n event.play_date = Date.parse(ne.attribute('PlayDate').to_s.gsub(/, */, '-'))\n event.Playtime = ne.attribute('PlayTime').to_s\n event.Url = ne.attribute('Url').to_s\n event.artist_name = artist.ListName\n event.artist_id = artist.id\n \n # Ensure CountryName valide and present\n city.ensure_CountryName\n event.ensure_CountryName\n \n # Verify / Add city to city table\n city = City.find_by CityID: city.CityID unless city.save\n event.city_id = city.id\n event.save\n \n # Create link table entries\n ArtistEvent.create({:artist => artist, :event => event})\n CityEvent.create({:city => city, :event => event})\n end\n end\n \n end",
"def show_events\n @events = Event.order(\"created_at\").to_a\n end",
"def related_events(result = Set.new)\n\t each_event do |ev|\n\t\tev.related_events(result)\n\t end\n\n\t result.reject { |ev| ev.respond_to?(:task) && ev.task == self }.\n\t\tto_set\n\tend",
"def events\n RoyalEvent::Event.where(\n \"id IN (#{subquery.to_sql})\"\n ).order(default_order)\n end",
"def event_all_new(events)\n event_all(events.stack, events.all.first.id)\n end",
"def event_all_new(events)\n event_all(events.stack, events.all.first.id)\n end",
"def search_for_future_calendar_events\n uri = URI.parse(\"https://www.googleapis.com/calendar/v3/calendars/ufbobbo%40gmail.com/events?orderBy=startTime&singleEvents=true&timeMin=#{Time.now.strftime(\"%FT%T%:z\")}&fields=items(id%2Cstart)&key=#{ENV['GOOGLE_API_KEY']}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request).body\n end",
"def find_recent_songs\n songs_with_date_modified_pair = self.lib.songs.reject do |song|\n (!song.metadata.has_key?('date_modified')) or (song.metadata['date_modified'] == nil)\n end\n\n songs_by_date_modified = songs_with_date_modified_pair.sort do |a, b| \n b.metadata['date_modified'] <=> a.metadata['date_modified']\n end\n\n songs_first = songs_by_date_modified.first(3)\n song_names = songs_first.collect {|song| song.metadata['name']} \n end",
"def events_request(max_pages=100)\n results = []\n max_pages.times do |page|\n # Repeatedly request events, page by page, until we reach the final page\n # of results (or for some maximum number of pages)\n req = MobilizeAmericaRequest.new(@api_key, @org_id, page+1)\n results += req.results\n break if req.last_page?\n end\n results\n end",
"def maintenance_history\n maintenance_events.where.not(event_date: '').order(event_date: :desc)\n end",
"def fetch_existing_map(events)\n MeetupEvent\n .where(meetup_event_id: events.map(&:meetup_event_id))\n .to_a\n .each.with_object({}) do |evt, hash|\n hash[evt.meetup_event_id] = evt\n end\n end",
"def events\n @_events ||= self.class.events.dup\n end",
"def last_event\n history.last\n end",
"def last_event\n history.last\n end",
"def my_events\n @events = []\n Event.all.each do |event|\n if (event.creator == current_user.id)\n @events << event\n end\n end\n end",
"def last_n_events(n)\n events.where(['date < ?', Date.today]).first(5)\n end",
"def truncate_history(events, replay_upto = nil)\n return nil if events.nil? || events.empty?\n\n # Just return the original array of events if replay_upto is not set\n # or if the number of events is less than replay_upto\n return events if replay_upto.nil? || events.last['eventId'] <= replay_upto\n\n # Select the events whose eventId is lesser than replay_upto\n truncated = events.select { |event| event['eventId'] <= replay_upto }\n return nil if truncated.empty?\n truncated\n end",
"def finish_events\n audio_event = @vj.fetch_last_event(:audio)\n audio_event.set_duration_now! unless audio_event.nil?\n video_event = @vj.fetch_last_event(:video)\n video_event.set_duration_now! unless video_event.nil?\n end",
"def entries\n AllEntries.new(Page.new(latest_events_path, @mingle_access))\n end",
"def list_system_events_historic\n @instance = prepare_param_instance\n @dbid = prepare_param_dbid\n save_session_time_selection # Werte puffern fuer spaetere Wiederverwendung\n\n additional_where1 = \"\"\n additional_where2 = \"\"\n binds = [@dbid] # 1. Bindevariable\n if @instance && @instance != 0\n additional_where1 << \" AND Instance_Number = ? \"\n binds << @instance\n end\n binds.concat [@time_selection_start, @time_selection_end]\n if params[:suppress_idle_waits]=='1'\n additional_where2 << \" WHERE name.Wait_Class != 'Idle'\"\n end\n\n @events = sql_select_all [\"\n SELECT /* Panorama-Tool Ramm */ hist.Instance_Number, name.Event_Name, name.Wait_Class, hist.Event_ID, hist.Waits, hist.Timeouts, hist.Time_Waited_Secs,\n Min_snap_ID, Max_Snap_ID\n FROM (\n SELECT DBID, Instance_Number, Event_ID,\n SUM(Waits) Waits,\n SUM(Timeouts) Timeouts,\n SUM(Time_Waited_Micro)/1000000 Time_Waited_Secs,\n MIN(Min_Snap_ID) Min_Snap_ID, MAX(Max_Snap_ID) Max_Snap_ID\n FROM (\n SELECT ev.DBID, ev.Instance_Number, ev.Snap_ID, ev.Event_Id, ss.Min_Snap_ID, ss.Max_Snap_ID,\n Total_Waits - LAG(Total_Waits, 1, Total_Waits) OVER (PARTITION BY ev.Instance_Number, Event_ID ORDER BY Snap_ID) Waits,\n Total_Timeouts - LAG(Total_Timeouts, 1, Total_Timeouts) OVER (PARTITION BY ev.Instance_Number, Event_ID ORDER BY Snap_ID) Timeouts,\n Time_Waited_Micro - LAG(Time_Waited_Micro, 1, Time_Waited_Micro) OVER (PARTITION BY ev.Instance_Number, Event_ID ORDER BY Snap_ID) Time_Waited_Micro\n FROM (SELECT DBID, Instance_Number, Min(Snap_ID) Min_Snap_ID, MAX(Snap_ID) Max_Snap_ID\n FROM DBA_Hist_Snapshot ss\n WHERE DBID = ? #{additional_where1}\n AND Begin_Interval_Time >= TO_TIMESTAMP(?, '#{sql_datetime_minute_mask}')\n AND Begin_Interval_Time <= TO_TIMESTAMP(?, '#{sql_datetime_minute_mask}')\n GROUP BY DBID, Instance_Number\n ) ss\n JOIN DBA_Hist_System_Event ev ON ev.DBID = ss.DBID AND ev.Instance_Number = ss.Instance_Number\n WHERE ev.Snap_ID BETWEEN ss.Min_Snap_ID-1 AND ss.Max_Snap_ID /* Vorgänger des ersten mit auswerten für Differenz per LAG */\n ) hist\n WHERE hist.Waits >= 0 /* Ersten Snap nach Reboot ausblenden */\n AND hist.Snap_ID >= hist.Min_Snap_ID /* Vorgaenger des ersten Snap fuer LAG wieder ausblenden */\n GROUP BY DBID, Instance_Number, Event_ID\n ) hist\n JOIN DBA_Hist_Event_Name name ON name.DBID=hist.DBID AND Name.Event_ID = hist.Event_ID\n #{additional_where2}\n ORDER BY Time_waited_Secs DESC\"].concat(binds)\n\n respond_to do |format|\n format.js {render :js => \"$('#list_system_events_historic_area').html('#{j render_to_string :partial=>\"list_system_events_historic\" }');\"}\n end\n end"
] |
[
"0.69378966",
"0.65406334",
"0.65316015",
"0.6414879",
"0.6306085",
"0.63015455",
"0.6299658",
"0.6170858",
"0.6140629",
"0.61404777",
"0.60318124",
"0.6023001",
"0.6018623",
"0.6009017",
"0.59951764",
"0.5986453",
"0.59799767",
"0.5959122",
"0.5954312",
"0.59327245",
"0.59207106",
"0.5920499",
"0.58985823",
"0.5892489",
"0.58862823",
"0.58767194",
"0.5871355",
"0.58644074",
"0.58426857",
"0.5835344",
"0.58183247",
"0.5788213",
"0.57816845",
"0.5753226",
"0.57516956",
"0.5735012",
"0.5733763",
"0.5731519",
"0.57309914",
"0.57309896",
"0.5720809",
"0.57172173",
"0.5713462",
"0.5696502",
"0.5692719",
"0.5692663",
"0.56748444",
"0.5657883",
"0.5654792",
"0.5650409",
"0.56498545",
"0.5644052",
"0.5643243",
"0.5642779",
"0.56299573",
"0.562498",
"0.5620408",
"0.5595316",
"0.5591502",
"0.5590174",
"0.55847484",
"0.55835444",
"0.5582826",
"0.5581117",
"0.5577116",
"0.55771065",
"0.5569838",
"0.5564387",
"0.5559201",
"0.5553147",
"0.5553142",
"0.5552495",
"0.55457795",
"0.553888",
"0.55134994",
"0.551206",
"0.55088407",
"0.55083776",
"0.5502364",
"0.55015504",
"0.5500268",
"0.54733443",
"0.5473024",
"0.54715705",
"0.54704016",
"0.54704016",
"0.54691404",
"0.5451187",
"0.545013",
"0.54500353",
"0.5444145",
"0.5442099",
"0.54390967",
"0.54390967",
"0.5437978",
"0.5434538",
"0.5433364",
"0.54316646",
"0.54286194",
"0.54274714"
] |
0.5576948
|
66
|
returns all previously fetched entries; can be used to reprocess the events for, say, various historical analyses
|
def all_fetched_entries
@entry_cache.all_entries
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def entries\n @entries ||= each_entry.to_a\n end",
"def fetch_entries\n entries.inject([]){ |all, entry| all << entry << addendas[entry] }.flatten.compact\n end",
"def fetch_previous_entries\n batch_id = BatchRegistries.where(replay_name: @current_package.title).first.id\n BatchEntries.where(batch_registries_id: batch_id)\n end",
"def entries\n AllEntries.new(Page.new(latest_events_path, @mingle_access))\n end",
"def get_all_entries\n entries = []\n\n page_number = 0\n while true\n page_entries = get_entries_by_page(page_number)\n entries.concat(page_entries)\n\n # give up once we get a non-full page\n break if page_entries.length < PAGE_SIZE\n\n # continue to the next page\n page_number += 1\n end\n\n entries.map { |e| normalize_entry(e) }\nend",
"def fetch_events\n Smash[\n @connection.stacks.reload.map do |stack|\n [stack.id,\n Smash.new(\n :events => stack.events.map(&:attributes),\n :status => stack.stack_status,\n :stack_name => stack.stack_name\n )\n ]\n end\n ]\n end",
"def entries() end",
"def entries(n=Readline::HISTORY.size)\n size=Readline::HISTORY.size\n Readline::HISTORY.to_a[(size - n)..size-1]\n end",
"def entries(include_obsolete=false)\n if include_obsolete\n @entries\n else\n find_all do |entry|\n !entry.obsolete?\n end\n end\n end",
"def all\n gen_feed Event.find(:all, :limit => @@limit, :order => 'id DESC'), 'All Events';\n end",
"def get_everything!\n self.update!\n\n prev = @prev\n while prev\n prev.update!\n\n self.merge_entries! prev\n prev = prev.prev\n end\n\n nxt = @next\n while nxt\n nxt.update!\n\n self.merge_entries! nxt\n nxt = nxt.next\n end\n\n self\n end",
"def entries\n return Array(@entries)\n end",
"def entries(limit=nil)\n limit ||= -1\n LiveJournal::Request::GetEvents.new(@user, :recent => limit, :strict => false).run\n end",
"def get_all_events\n events, cursor = get_paginated_first\n while cursor do\n next_events, cursor = get_paginated_next(cursor: cursor)\n events += next_events\n end\n events\n .map(&:to_i)\n end",
"def entries\n Entry.where(:feed_id => pk)\n end",
"def entries\n trace 'entries'\n $data['entries']\n end",
"def entries\n trace 'entries'\n @data['entries']\n end",
"def get_history\n events = []\n # Get the first page of the workflow history\n page = get_history_page\n page[\"events\"].each { |x| events << x }\n\n # Get the remaining pages of the workflow history\n until page[\"nextPageToken\"].nil?\n page = get_history_page(page[\"nextPageToken\"])\n page[\"events\"].each { |x| events << x }\n end\n events\n end",
"def get_entries(date = nil)\r\n if date.nil?\r\n list = []\r\n for i in @log\r\n list.push(i)\r\n end\r\n elsif @log[date].nil?\r\n list = nil\r\n else\r\n list = @log[date]\r\n end\r\n list\r\n end",
"def entries; end",
"def entries; end",
"def entries; end",
"def entries; end",
"def fetch\n @start_time ||= (Time.current - 1.minute).to_i * 1000\n $mw_log.debug \"Catching Events since [#{@start_time}]\"\n\n new_events = @alerts_client.list_events(\"startTime\" => @start_time, \"tags\" => \"miq.event_type|*\", \"thin\" => true)\n @start_time = new_events.max_by(&:ctime).ctime + 1 unless new_events.empty? # add 1 ms to avoid dups with GTE filter\n new_events\n rescue => err\n $mw_log.info \"Error capturing events #{err}\"\n []\n end",
"def entries\n @entries ||= Scraper.instance.get_all(Entry, @path, [\n [:reflex, 'td[2]/text()'],\n [:description, 'td[3]/text()'],\n [:language_name, 'td[1]/a/text()'],\n [:language_path, 'td[1]/a/@href'],\n [:source_code, 'td[4]/a/text()'],\n [:source_path, 'td[4]/a/@href'],\n [:reconstruction_name, nil, lambda {|x| @protoform}],\n [:reconstruction_path, nil, lambda {|x| @path}],\n [:flag, \"td[3]/span[@class='flag']/text()\"]\n ], 1)\n end",
"def refresh_all\n\t\tputs \"Refresh all the entries within the local site store ... \"\n\t\tchanges=Hash.new\n\t\tchanges=bulk_refresh(@known_sites.keys)\n\t\t@known_sites.merge!(changes)\n\t\tputs \"Done refresh all entries.\"\n\t\treturn changes\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\tend",
"def entries\n data[:entries]\n end",
"def entries(reload=false)\n @entries = nil if reload\n @entries ||= resource_entries #& recipe_entries\n end",
"def entries()\r\n return @entries.to_a.sort { |a,b|\r\n a.date <=> b.date\r\n }\r\n end",
"def entries\n @entries ||= Scraper.instance.get_all(Entry, @path, [\n [:reflex, 'td[2]/text()'],\n [:description, 'td[3]/text()'],\n [:language_name, nil, lambda {|x| @name}],\n [:language_path, nil, lambda {|x| @path}],\n [:source_code, 'td[4]/a/text()'],\n [:source_path, 'td[4]/a/@href'],\n [:flag, \"td[3]/span[@class='flag']/text()\"]\n ])\n end",
"def get_all_entries\n @feed_entries = FeedEntry.find(:all, :conditions => { :person_id => self.id}, :order => 'published_at DESC')\n end",
"def entries\n @entries ||= table\n end",
"def entry_set; end",
"def get_all\n @monkeys.dup\n end",
"def old_query # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n data = []\n\n query_result = generic_query(params: { 'source-id': 'datacite-usage', 'doi': @doi })\n data += query_result['data'] if query_result['data']\n\n while query_result['links']['next']\n query_result = make_reliable { RestClient.get query_result['links']['next'] }\n query_result = JSON.parse(query_result)\n data += query_result['data'] if query_result['data']\n end\n\n data\n rescue RestClient::ExceptionWithResponse => err\n logger.error(\"#{Time.new} Could not get response from DataCite event data source-id=datacite-usage&doi=#{CGI.escape(@doi)}\")\n logger.error(\"#{Time.new} #{err}\")\n []\n end",
"def entries\n if @group_by\n most_recent_matching_entry_in_group\n elsif @most_recent_only\n Array(most_recent_matching_entry)\n elsif @created_within\n get_created_within\n else\n matching_entries\n end\n end",
"def other_events\n result = []\n final_result = []\n # we go through each entry in the file_set resource\n object.resource.each_entry do |e|\n entry_id = e.as_json[\"subject\"][\"@id\"]\n # we are only interested in entries that are nested and are missing in preservation_event md field\n if entry_id.include?(\"#nested\") && object.preservation_event.none? { |pe| pe.as_json[\"id\"] == entry_id }\n # append it to a result array\n result << [id: entry_id, predicate: e.as_json[\"predicate\"][\"@id\"], value: e.as_json[\"object\"][\"@value\"]]\n end\n end\n # once we have all required entries in the result array, we need to group them by their respective IDs\n grouping_by_id = result.group_by { |r| r.first[:id] }\n # once grouped, go through each value from the groupings of IDs\n grouping_by_id.each_value do |grouping|\n event_details = []\n event_type = event_end = event_start = initiating_user = outcome = software_version = ''\n # each grouping/value has a predicate and a value;\n # we go through each grouping and assign values to its respective variable\n # by matching the predicate\n grouping.each do |preservation_event|\n case preservation_event.first[:predicate]\n when \"http://metadata.emory.edu/vocab/cor-terms#eventDetails\" then event_details << preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventType\" then event_type = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventEnd\" then event_end = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventStart\" then event_start = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventUser\" then initiating_user = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#eventOutcome\" then outcome = preservation_event_value(preservation_event)\n when \"http://metadata.emory.edu/vocab/cor-terms#softwareVersion\" then software_version = preservation_event_value(preservation_event)\n end\n end\n # once we have all the matching values in their respective variables,\n # we create a hash and append it to an array\n final_result << [\n {\n 'event_details' => event_details,\n 'event_type' => event_type,\n 'event_end' => event_end,\n 'event_start' => event_start,\n 'initiating_user' => initiating_user,\n 'outcome' => outcome,\n 'software_version' => software_version\n }.to_json\n ].first\n end\n # we finally return the array with hashes for the missing preservation_events\n final_result\n end",
"def latest_entries\n unless @latest_entries\n @latest_entries = Rails.cache.fetch([@account.cache_key, '/latest_entries'], :expires_in => 10.minutes) do\n Entry.paginate(:all, :from => \"/accounts/#{@account.account_resource_id.to_s}/entries.xml\", :params => { :page => 1, :per_page => 5}) \n end\n end\n @latest_entries\n end",
"def __entries__\n @entries\n end",
"def entries\n if defined? @entries\n @entries\n else\n if @fz_feed_parser && @fz_feed_parser.entries\n @entries = @fz_feed_parser.entries.map { |e| Service::Parser::FeedItem.new(feedjira_parser: e) }\n else\n []\n end\n end\n end",
"def get_entries(event, account)\n @ticket = event.eventable\n @event = event\n @account = account\n\n case event.class.name\n when ServiceCallCompletedEvent.name, ServiceCallCompleteEvent.name\n charge_entries\n when ScSubconSettleEvent.name, ScSubconSettledEvent.name, ScProviderSettleEvent.name, ScProviderSettledEvent.name\n settlement_entries\n when ServiceCallCancelEvent.name, ServiceCallCanceledEvent.name, ScProviderCanceledEvent.name\n cancellation_entries\n when ScCollectEvent.name, ScCollectedEvent.name, ScCollectedByEmployeeEvent.name\n collection_entries\n when ServiceCallPaidEvent.name, ScProviderCollectedEvent.name\n payment_entries\n when ScWorkReopenEvent.name\n reopen_entries\n else\n raise \"Unexpected Event (#{event.class.name}) to be processed by the posting rule (#{self.class.name})\"\n end\n end",
"def all_events\n @events = Event.all\n end",
"def entry_dates()\r\n return @entries_by_date.keys.sort.reverse()\r\n end",
"def fetch_events(app_name, env_name, options={})\n @event_fetched_times += 1\n set_env_ready(app_name, env_name, true) # assume env become ready after it spit out all the events\n\n unless @events # unrestricted mode for testing if no explicit events set\n return [generate_event_from_messages(['Successfully deployed new configuration to environment',\n 'terminateEnvironment completed successfully',\n 'Successfully launched environment',\n 'Completed swapping CNAMEs for environments'\n ], Time.now + @event_fetched_times), nil]\n end\n\n events = @events[env_key(app_name, env_name)][@event_fetched_times - 1]\n\n if options.has_key?(:start_time)\n start_time = Time.parse(options[:start_time])\n events = events.select { |e| e[:event_date] >= start_time }\n end\n\n if limit = options[:max_records]\n events = events[0..limit]\n end\n\n [events, nil]\n end",
"def searches_from_history\n []\n end",
"def get_events()\n\t\tevents = []\n\n\t\t@DB[:events].order(:date).each do |event|\n\t\t\tnewTimeslots = []\n\t\t\t@DB[:timeslots].where(parent_table: 'events', parent_id: event[:'id']).each do |timeslot|\n\t\t\t\tnewTimeslots.push(DateTime.parse(timeslot[:'time']))\n\t\t\tend\n\n\t\t\tnewAttendees = []\n\t\t\t@DB[:attendees].where(parent_id: event[:'id']).each do |attendee|\n\t\t\t\tattendeeTimeslots = []\n\t\t\t\t@DB[:timeslots].where(parent_table: 'attendees', parent_id: attendee[:'id']).each do |timeslot|\n\t\t\t\t\tattendeeTimeslots.push(DateTime.parse(timeslot[:'time']))\n\t\t\t\tend\n\n\t\t\t\tnewAttendee = Attendee.new(attendee[:'name'], attendeeTimeslots)\n\t\t\t\tnewAttendees.push(newAttendee)\n\t\t\tend\n\n\t\t\tnewEvent = Event.new(event[:'name'], event[:'description'], newTimeslots, newAttendees, event[:'id'])\n\t\t\tif newEvent.get_date >= @epoch\n\t\t\t\tevents.push(newEvent)\n\t\t\tend\n\t\tend\n\n\t\treturn events\n\tend",
"def entries\n load_client\n load_entries\n load_preferences\n end",
"def filtered_entries; end",
"def all_contents\n @all_contents ||= Spontaneous::Collections::EntrySet.new(self, entry_store)\n end",
"def extract_events(calendar)\n events = []\n rep_until = Date.today >> MONTHS_ADVANCE_FOR_REPATING\n\n calendar.events.each do |event_entry|\n # for performance reasons, create event once and then clone per occurrence\n event = Event.build_from(Adapter.new(event_entry))\n occurences = event_entry.occurrences(:before => rep_until) \n # again, for performance and api limit reasons, get geo coordinates for repeating\n # events only once\n event.get_geo_coordinates #if occurences.size > 1\n \n occurences.each do |ical_event|\n adapter = Adapter.new(ical_event)\n occurrence = event.clone\n occurrence.starts_at = adapter.starts_at\n occurrence.ends_at = adapter.ends_at\n events << occurrence\n end\n end\n \n @log.info \"got #{events.size} events\"\n events\n end",
"def all_ticket_entries\n @ac = ApplicationController.new\n @tickets = Ticket.find(:all, :order => \"created_at\")[0..5000].reverse!\n @species = Specie.all\n @woodtypes = WoodType.all\n end",
"def entries\n MicroQ.redis do |r|\n r.lrange(QUEUES[:entries], 0, -1)\n end.collect(&MicroQ::Util.json_parse)\n end",
"def all_history\n history(history: {})\n end",
"def history\r\n []\r\n end",
"def entries\n @list\n end",
"def get_entries\n @page.all(input_elements[:entries])\n end",
"def fetch_entries(context)\n @site, @page = context.registers[:site], context.registers[:page]\n\n children = (case @source\n when 'site' then @site.pages.root.minimal_attributes(@options[:add_attributes]).first # start from home page\n when 'parent' then @page.parent || @page\n when 'page' then @page\n else\n @site.pages.fullpath(@source).minimal_attributes(@options[:add_attributes]).first\n end).children_with_minimal_attributes(@options[:add_attributes]).to_a\n\n children.delete_if { |p| !include_page?(p) }\n end",
"def all\n @events = Event.order(updated_at: :desc).page(params[:page]).per(10)\n end",
"def all_events\n @unreads = current_user.unreads\n search_params = params.except(:utf8, :commit, :controller, :action, :page)\n if search_params.present?\n @events = Event.search(search_params, @unreads).order(\"created_at DESC\")\n @events = @events.paginate(:page => params[:page], :per_page => 5)\n else\n @events = Event.all.order(created_at: :desc).paginate(:page => params[:page], :per_page => 5)\n end\n end",
"def events\n object.events.last(10)\n end",
"def all_rows\n cache.all_rows\n end",
"def filtered_entries(bp_readings)\n return [] if bp_readings.empty?\n\n bp_readings = bp_readings.filter do |reading|\n reading[:effectiveDateTime].to_date > 1.year.ago\n end\n\n bp_readings.sort_by do |reading|\n reading[:effectiveDateTime].to_datetime\n end.reverse!\n end",
"def active_set_history\n ash = []\n end",
"def events_now\n\n # Open empty array\n events = []\n\n # Loop over all the calendars\n CALENDARS.each do |name, id|\n\n # Get the events\n cal_events = calendar(id).find_events_in_range(Time.now, Time.now + 60)\n\n # Loop over each one and add it to the array\n cal_events.each do |e|\n events << {event: e, cal: name} unless e.nil?\n end\n\n end\n\n # Return the final list\n return events\n\nend",
"def events(query)\n ret = Array.new\n \n feed = Feedjira::Feed.parse jira_query(query)\n \n feed.entries.each do |feed_evt|\n event = event_from_feed(feed_evt)\n event.person = query.person\n \n if (event.time < query.to && event.time > query.from)\n ret << event\n end\n end\n \n ret\n end",
"def entries\n params[:return_entries] = true\n self\n end",
"def get_events\n events = [] \n @log ||= Rails.logger\n Appsterdam::Application.ical_subscriptions.each do |options|\n @log.info \"getting events from #{options[:url]}\"\n components = parse_ical(options[:url])\n events.concat(extract_events(components.first))\n end\n @log.info \"done importing iCal events.\"\n \n events\n end",
"def all\n response = run\n\n while continue?(response)\n @options[:exclusive_start_key] = response.last_evaluated_key\n response = run(response)\n end\n\n @collection.deserialize(response.entities)\n end",
"def entries\n @filter\n end",
"def get_all_records\r\n nodes = []\r\n time_blocks = generate_time_blocks( DEFAULT_OPTIONS[:erp_start_time].dup, Time.now )\r\n \r\n # time_blocks.each do |pair|\r\n # result = search_by_modified_date( pair.first, pair.last )\r\n # nodes.concat result unless result.empty?\r\n # end\r\n \r\n ERP::ThreadPool.new(@options[:threads], time_blocks).start do |pair|\r\n sleep(1 * rand)\r\n result = search_by_modified_date( pair.first, pair.last )\r\n nodes.concat result unless result.empty?\r\n end\r\n \r\n output_log \"#{nodes.size} records received!\"\r\n return nodes\r\n end",
"def future_events\n instances = []\n Event.where(place: self).each do |e|\n instances << e.occurrences.where(date: Date.current..2.weeks.from_now)\n end\n instances.flatten!.sort_by(&:date) unless instances.empty?\n end",
"def refresh_all\n\t\tputs \"Refresh all the entries in the local host repository in one shot.\"\n\t\tchanges=Hash.new\n\t\thosts=@known_hosts.keys\n\t\t@known_hosts=Hash.new\n\t\tchanges=bulk_add(hosts)\n\t\t@known_hosts.merge!(changes)\n\t\t#@known_hosts.keys.map do |key|\n\t\t#\tunless is_ip?(key)\n\t\t#\t\thost=refresh(key)\n\t\t#\t\tchanges.push(host) unless host.nil?\n\t\t#\tend\n\t\t#end\n\t\tputs \"\\n#{changes.size} Entries Refreshed:\" if changes.size>0\n\t\t#changes.map { |x| puts x }\n\t\tputs \"Done refreshing the local hosts.\"\n\t\treturn changes\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def event_list\n events_list\n end",
"def event_results(reload = true)\n if reload\n return Result\n .includes(:team, :person, :scores, :category, race: %i[event category])\n .where(\"people.id\" => id)\n .reject(&:competition_result?)\n end\n results.reject(&:competition_result?)\n end",
"def entries\n settings.time_entries.present? ? settings.time_entries : []\n end",
"def get_festivals() \n #Start from 3 days ago since can be in the middle of a festival\n threeDaysAgo = (Time.now - (3*24*60*60)).strftime('%Y-%m-%d')\n #Find relevant events\n events = Event.where(festival: 1).where('date >= ?', threeDaysAgo).order(:date)\n\n #Make hash of hashes that include all necessary info\n festivalDatesArr = {}\n events.each do |event|\n #Need to account for same name different locations\n name = \"#{event.title} #{event.location}\"\n if festivalDatesArr.has_key?(name)\n festivalDatesArr[name]['dates'].push(event.date) \n else\n festName = \"#{event.title} #{event.location}\"\n festivalDatesArr[festName] = {\n 'dates' => [event.date],\n 'id' => event.id,\n 'title' => event.title,\n 'location' => event.location,\n 'ages' => event.ages,\n 'link' => event.ticketLink,\n 'address' => event.address\n }\n end\n end\n return festivalDatesArr\n end",
"def fetch_latest\n page = page_with_latest_entries\n most_recent_new_entry = page.entries.first\n last_fetched_entry = @entry_cache.latest\n last_fetched_entry_seen = false \n next_entry = nil\n while !last_fetched_entry_seen && page\n page.entries.each do |entry|\n \n @entry_cache.write(entry, next_entry)\n if last_fetched_entry && entry.entry_id == last_fetched_entry.entry_id\n last_fetched_entry_seen = true\n break\n end\n\n next_entry = entry\n end\n page = page.next\n end\n \n @entry_cache.update_current_state(next_entry, most_recent_new_entry)\n @entry_cache.entries(next_entry, most_recent_new_entry)\n end",
"def parse_all\n while parse_one_entry; end\n end",
"def events\n event_lookup()\n end",
"def events\n event_lookup()\n end",
"def load_searches_all\n searches = ServiceCatalographer::Search::all_possible_activity_logs_for_search([ \"data\" ])\n searches = searches.map{|s| ServiceCatalographer::Search::search_term_from_hash(s.data) }\n searches = searches.reject{|s| s.blank? }\n \n @searches_all = searches\n end",
"def events\n metadata['events'].sort_by! { |event| event['timestamp'] }\n end",
"def events\n @events ||= []\n @events\n end",
"def events\n return if @events.empty?\n @events.uniq.sort\n end",
"def fetch_articles\n return unless any_new?\n (how_many? - 1).downto(0) do |index|\n next if added?(index)\n Article.create(title: feed.entries[index].title,\n description: description(index),\n published: feed.entries[index].published,\n link: feed.entries[index].url,\n site_id: id,\n readingtime: reading_time(index))\n end\n end",
"def events_list\n list = []\n if frm.table(:class=>\"calendar\").exist?\n events_table = frm.table(:class=>\"calendar\")\n else\n events_table = frm.table(:class=>\"listHier lines nolines\")\n end\n events_table.links.each do |link|\n list << link.title\n list << link.text\n list << link.href\n list << link.html[/(?<=\"location=\").+doDescription/]\n end\n list.compact!\n list.uniq!\n return list\n end",
"def history\n return nil if tracking_is_empty\n\n history_information_box ||= @tracking_page.css(\".indent table[summary='履歴情報']\")\n history_columns = history_information_box.css(\"tr\")\n history_columns = history_columns[2..history_columns.size] # remove header\n\n history = []\n\n history_columns.each_with_index do |tr, index|\n next if index.odd? # skip zip code row\n date = Chronic.parse(tr.css(\"td\").first.text) rescue nil\n\n action = tr.css(\"td\")[1].text.strip\n action = nil if action.empty?\n\n details = tr.css(\"td\")[2].text.strip\n details = nil if action.empty?\n\n office = tr.css(\"td\")[3].text.strip\n office = nil if action.empty?\n\n location = tr.css(\"td\")[4].text.strip\n location = nil if action.empty?\n\n history << { date: date, action: action, details: details, office: office, location: location }\n end\n\n return history\n end",
"def flattened_events\n _result = []\n _events = events\n\n while event = _events.pop do\n match = _events.find { |e| e == event }\n if match.nil?\n _result << event\n else\n match.increment_frequency\n end\n end\n\n _result\n end",
"def get_entries_from_db(query, target_column)\n\t\tresults = [] \n\t\t# gid_history = Set.new\n\t\t\n\t\t# 1. Get the base dictionary.\n\t\t# Notice:\n\t\t# Assume that the names of base dictionaries are unique.\n\t\t#\n\t\tdic = @db::Dictionary.select(:id).where(:title => @dic_name).first\n\t\tif dic.nil?\n\t\t\treturn results\n\t\tend\n\n\t\t# 2. Get the list of removed entries from the associated user dictionary.\n\t\t# Notice:\n\t\t#\n\t\tuser_dics = @db::UserDictionary.select(:id).where(:dictionary_id => dic[:id]).where(:user_id => @user_id)\n\t\tif user_dics.blank?\n\t\t\tremoved_entry_idlist = []\n\t\telse\n\t\t\t# Assume that the user dictionary to a specific base dictionary is unique (only one)\n\t\t\ttarget_user_dic = user_dics.first\n\n\t\t\t# Convert a key-value hash to an array of values by using .all.values\n\t\t\tremoved_entry_idlist = @db::RemovedEntry.select(:entry_id).where(:user_dictionary_id => target_user_dic[:id]).all.map do | item |\n\t\t\t\titem[:entry_id]\n\t\t\tend\n\t\tend\n\t\t\n\t\t# 3. Retrieve the entries for a given query except those are marked as removed\n removed_entry_idlist = [0] if removed_entry_idlist.blank?\n\t\tds = @db::Entry.where(:dictionary_id => dic[:id]).where(target_column => query).where('id NOT IN (?)', removed_entry_idlist)\n\t\tds.all.each do |row|\n\t\t\tresults << { label: row[:label], uri: row[:uri], title: row[:view_title] }\n\t\t\t# Use if the same gene id has not been found yet\n\t\t\t# if not gid_history.include?( row[:uri] )\n\t\t\t# \tresults << { label: row[:label], uri: row[:uri], title: row[:title] }\n\t\t\t# \tgid_history.add( row[:uri] )\n\t\t\t# end\n\t\tend\n\n\t\t# 4. Add newly added entries by a user\n\t\tif user_dics.present?\n\t\t\tds = @db::NewEntry.where(:user_dictionary_id => target_user_dic[:id]).where(target_column => query)\n\t\t\tds.all.each do |row|\n\t\t\t\tresults << { label: row[:label], uri: row[:uri], title: row[:view_title] }\n\n\t\t\t# \tif not gid_history.include?( row[:uri] )\n\t\t\t# \t\tresults << { label: row[:label], uri: row[:uri], title: row[:title] }\n\t\t\t# \t\tgid_history.add( row[:uri] )\n\t\t\t# \tend\n\t\t\tend\n\t\tend\n\n\t\treturn results\n\tend",
"def index\n @upcoming_events = Event.upcoming_events\n @previous_events = Event.previous_events\n end",
"def history_items\n return @history_items\n end",
"def fetch_all\n self.to_a\n end",
"def fetch_events\n params = {'calendarId' => CONFIG[:cal_id], \n 'orderBy' => 'startTime',\n #'timeMax' => Time.utc(CONFIG[:year].to_i + 1, 4, 1).iso8601, \n #'timeMin' => Time.utc(CONFIG[:year].to_i, 4, 1).iso8601,\n 'singleEvents' => 'True'}\n \n result = @client.execute(:api_method => @cal.events.list, :parameters => params)\n\n @events_list = []\n result.data.items.each do |item|\n @events_list << item\n end\n end",
"def publication_history\n @publication_history ||= channel\n .stories\n .for_current_day_of_week\n .order('published_at DESC')\n .limit(NUMBER_OF_STORIES_TO_ANALYZE)\n .pluck(:published_at)\n end",
"def subentries\n\t\t# If we have our own subentries, use them.\n\t\town_subentries = Subentry.joins(:etymotheses).where(:etymotheses => {:etymology_id => id}).all\n\t\treturn own_subentries if own_subentries.present?\n\t\t\n\t\t# If we are next etymon of anything else, use that etymon's subentries.\n\t\tprev_etymon = Etymology.where(:next_etymon_id => id).first\n\t\treturn prev_etymon.subentries if prev_etymon\n\t\t\n\t\t# Default response\n\t\t[]\n\tend",
"def read_logs_all()\n #logs = Log.find(:all, :order => 'created_at asc')\n logs = Log.all.order('created_at asc')\n end",
"def fetch_entries(context)\n @site, @page, @portal_user = context.registers[:site], context.registers[:page], context.registers[:current_portal_user]\n set_defaults\n\n page = (case @source\n when 'site' then @all_pages.root.minimal_attributes(@options[:add_attributes]).first # start from home page\n when 'parent' then top_page\n when 'page' then @page\n else\n @all_pages.fullpath(@source).minimal_attributes(@options[:add_attributes]).first\n end)\n\n children = children(page)\n\n children.delete_if { |p| !include_page?(p) }\n end",
"def entries\n require_initialized_entry_class do \n Array.load(self[:@entries_url])\n end\n end",
"def get_upcoming_episodes(seriesid)\n # See if we already have both a name for the series, if there exists a name episodes should be updated\n seriesInformation = SeriesInformation.find_by seriesid: seriesid\n upcomingEpisodes = EpisodeInformation.where(seriesid: seriesid)\n if seriesInformation.nil?\n seriesInformation,upcomingEpisodes = initialize_cache_and_return_data(seriesid)\n end\n # If, for some reason, neither database lookup or cache updating didn't return an array, create one.\n if upcomingEpisodes.nil?\n upcomingEpisodes = Array.new\n end\n upcoming_episodes_for_return = Array.new\n # Go through list of episodes found\n for j in 0..(upcomingEpisodes.length-1)\n # Check if episode is still in the future\n if(upcomingEpisodes[j].firstaired > Date.today.prev_day)\n upcoming_episodes_for_return.push(upcomingEpisodes[j])\n else\n # If not, delete it (should be safe to do here as the data is only removed from database, not from array)\n # NOTE: This is the only place old episodes are pruned out when updates are not occurring. This should probably also be in a cleanup function. \n upcomingEpisodes[j].delete\n end\n end\n return upcoming_episodes_for_return\n end",
"def rss_entries(url)\n\t\tresponse = fetch(url)\n\t\tresponse[\"feed\"][\"entry\"]\n\tend"
] |
[
"0.6893237",
"0.68743587",
"0.6513726",
"0.64541024",
"0.6300125",
"0.6283504",
"0.6253153",
"0.62425214",
"0.62035984",
"0.61733747",
"0.616701",
"0.6162796",
"0.6152221",
"0.6124355",
"0.6108532",
"0.60980844",
"0.6086168",
"0.60857993",
"0.6068412",
"0.6057965",
"0.6057965",
"0.6057965",
"0.6057965",
"0.60574",
"0.60365874",
"0.60333353",
"0.5996743",
"0.59809035",
"0.59474546",
"0.59223425",
"0.5899904",
"0.58808047",
"0.58753234",
"0.5871348",
"0.5860059",
"0.5860054",
"0.5847123",
"0.5841772",
"0.5836186",
"0.5831671",
"0.5825498",
"0.58134025",
"0.5788646",
"0.5781481",
"0.5779439",
"0.57637686",
"0.5751296",
"0.5738581",
"0.5731829",
"0.5726771",
"0.5725811",
"0.5719744",
"0.5708253",
"0.5698213",
"0.56977785",
"0.5685279",
"0.5682393",
"0.5676606",
"0.56659645",
"0.56615406",
"0.56597203",
"0.5642107",
"0.5630005",
"0.5619368",
"0.5618201",
"0.56063837",
"0.56022674",
"0.5600697",
"0.5596091",
"0.5592385",
"0.5585041",
"0.5575214",
"0.55715793",
"0.5566357",
"0.55585456",
"0.5554399",
"0.55516165",
"0.55492264",
"0.55384916",
"0.55384916",
"0.5528139",
"0.55266726",
"0.55261266",
"0.5525938",
"0.5524507",
"0.55197",
"0.55194527",
"0.5516421",
"0.55001044",
"0.54943854",
"0.54843146",
"0.54841244",
"0.54794323",
"0.5477332",
"0.5472627",
"0.5470701",
"0.5467851",
"0.5466806",
"0.5459878",
"0.5455581"
] |
0.7192802
|
0
|
GET /events GET /events.json
|
def index
@events = Event.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end",
"def index\n #returns all events from eventbrite API, need to change to pull from her endpoint\n @eventList = Event.retrieve_all_events params\n render json: @eventList, status: 200\n end",
"def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end",
"def index\n @events = Event.all\n render json: @events, status: 200\n end",
"def index\n @events = Event.all\n render json: @events\n end",
"def index\n @events = current_user.events\n\n render json: @events\n end",
"def index\n @events = Event.find(:all)\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n @events = Event.all\n\n render json: @events\n end",
"def index\n @event = Event.all\n render json: @event\n end",
"def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json do\n render :json => {events: @events}\n end\n end\n end",
"def index\n response = { events: Event.all }\n respond_to do |format|\n format.json { render json: response.to_json }\n format.html { render :index }\n end\n end",
"def get_events\n if @user.uuid.present?\n @events = @user.events.active_events.page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n elsif @user.uuid == \"guest\"\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: @user.tenant_id)\n render json: @events\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end",
"def index\n\t\t@events = Event.all.order('created_at desc')\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render :json => @events }\n\t\tend\n\tend",
"def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json \n end\n end",
"def get_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\tdo_the_get_call( url: api_url, user: @user )\nend",
"def events(project_id, options = {})\n get \"projects/#{project_id}/events\", options\n end",
"def index\n @events = current_user.events\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def show\n @event = Event.find(params[:id])\n render json: @event\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n \n @events = current_user.events\n \n \n respond_to do |format|\n format.html {}\n format.json { render json: Event.events_to_json(@events) }\n end\n end",
"def events\n data[\"events\"]\n end",
"def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend",
"def index\n @events = @calendar.events.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end",
"def index\n @events = @category.events\n render json: @events \n end",
"def index\n\t\t@events = current_user.events\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @events }\n\t\tend\n\tend",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def index\n event = Event.find(params[:event_id])\n render json: event.route, status: :ok\n end",
"def index\n render json: Event.all, status: :ok\n end",
"def show\n render json: @event, status: :ok\n end",
"def index\n @upcoming_events = Event.upcoming\n @past_events = Event.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n respond_with(@events)\n end",
"def get_event(session, options={})\n json_request \"get\", {:session => session}, options\n end",
"def index\n @events = getUpcomingEvents()\n \n @page_title = \"Events\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def get(event_id)\n @client.request \"events/#{event_id}\"\n end",
"def index\n\t\t@events = Event.page(params[:page]).per(10)\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json {\n\t\t\t\trender :json => @events.to_json\n\t\t\t}\n\t\tend\n\n\tend",
"def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @user.tenant_id)\n if @event.present?\n render :json => @event\n else\n render :json => {messageCode: \"event.notfound\", message: \"Event Not Found\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end",
"def events\n collection(\"events\")\n end",
"def event(event, options = {})\n get \"events/#{event}\", options\n end",
"def past_events\n @events = Event.past\n render json: @events, include: :talks\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def get_event_list ( year )\n get_api_resource \"#{@@api_base_url}events/#{year}\"\n end",
"def index\n begin\n events = Event.all\n render :json => {events: ActiveModel::ArraySerializer.new(events, each_serializer: EventsSerializer), :code => 200}, status: :ok\n rescue Exception => e\n logger.error {\"Error while populating list of events. ErrorMessage: #{e.message}, Params: #{params.inspect}\"}\n render json: {error: e.message, code: 500}\n end\n end",
"def show\n \trender json: @event\n end",
"def show\n @events = fetch_events\n end",
"def show\n render json: EventSerializer.new(@event).as_json, status: 200\n end",
"def list\n @events = Event.coming_events\n respond_to do |format|\n format.html do\n render layout: 'events'\n end\n format.json do \n events = @events.map {|event| {event: event, users: event.users, applied: event.users.include?(current_user) }}\n render json: events \n end\n end\n end",
"def index\n if params[:query].present?\n @events = GroupEvent.send(params[:query])\n else\n @events = GroupEvent.published\n end\n\n render json: @events\n end",
"def fullcalendar_events_json\n events.map do |event|\n {\n id: event.id.to_s,\n title: event.name,\n start: event.starts_at.strftime('%Y-%m-%d %H:%M:%S'),\n end: event.ends_at.strftime('%Y-%m-%d %H:%M:%S'),\n allDay: event.all_day,\n url: event_path(event)\n }\n end\n end",
"def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event_event = Event::Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_event }\n end\n end",
"def index\n if params[:user]\n @events = Event.where(user: params[:user]).first\n else\n @events = Event.all.order('created_at asc')\n end\n\n render json: @events, :only => [:id, :date, :user, :event_type, :message, :otheruser]\n end",
"def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def details\n get(\"v1/event/#{@id}\")\n end",
"def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event } \n end\n end",
"def index\n @events = Event.all\n @event = Event.new\n\n respond_to do |format|\n format.html\n format.json { render 'events/index', events: @events }\n end\n end",
"def show\n render json: format_event(@event)\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end"
] |
[
"0.83372355",
"0.8240056",
"0.79437226",
"0.7928057",
"0.7768322",
"0.7741097",
"0.76704425",
"0.7665877",
"0.7659134",
"0.76427555",
"0.76214844",
"0.7616007",
"0.7616007",
"0.76134557",
"0.75691116",
"0.7523018",
"0.7489189",
"0.7481164",
"0.7470412",
"0.74423337",
"0.7440539",
"0.74402696",
"0.74386674",
"0.7411357",
"0.74097383",
"0.74097383",
"0.74097383",
"0.74097383",
"0.74097383",
"0.74097383",
"0.74097383",
"0.74097383",
"0.74097383",
"0.74097383",
"0.7400458",
"0.73985314",
"0.73756176",
"0.73685235",
"0.7366903",
"0.7364686",
"0.73642004",
"0.7362057",
"0.7362057",
"0.7362057",
"0.7362057",
"0.7362057",
"0.7359807",
"0.7352254",
"0.73343575",
"0.7325566",
"0.73207647",
"0.7295974",
"0.72953916",
"0.7288734",
"0.728279",
"0.72738683",
"0.7273804",
"0.72476894",
"0.7245207",
"0.7229074",
"0.7229074",
"0.72238356",
"0.7212674",
"0.7212629",
"0.7183519",
"0.71821636",
"0.71710896",
"0.7133522",
"0.71284497",
"0.7124501",
"0.7123345",
"0.71146816",
"0.71108645",
"0.71108645",
"0.71045107",
"0.71028566",
"0.7102187",
"0.71013737",
"0.7100566",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056",
"0.71003056"
] |
0.0
|
-1
|
GET /events/1 GET /events/1.json
|
def show
@event = Event.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @event = Event.find(params[:id])\n render json: @event\n end",
"def get(event_id)\n @client.request \"events/#{event_id}\"\n end",
"def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @user.tenant_id)\n if @event.present?\n render :json => @event\n else\n render :json => {messageCode: \"event.notfound\", message: \"Event Not Found\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end",
"def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end",
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def index\n #returns all events from eventbrite API, need to change to pull from her endpoint\n @eventList = Event.retrieve_all_events params\n render json: @eventList, status: 200\n end",
"def index\n @events = Event.all\n render json: @events, status: 200\n end",
"def index\n @event = Event.all\n render json: @event\n end",
"def index\n @events = Event.find(:all)\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: @events }\n end\n end",
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def details\n get(\"v1/event/#{@id}\")\n end",
"def index\n @events = Event.all\n render json: @events\n end",
"def show\n\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @myevent = Myevent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @myevent }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @event_event = Event::Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_event }\n end\n end",
"def index\n event = Event.find(params[:event_id])\n render json: event.route, status: :ok\n end",
"def index\n @events = Event.all\n\n render json: @events\n end",
"def show\n render json: @event, status: :ok\n end",
"def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json do\n render :json => {events: @events}\n end\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.json { render json: @events }\n end\n end",
"def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event } \n end\n end",
"def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @event }\n end\n end",
"def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @event }\n end\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json \n end\n end",
"def show\n render json: EventSerializer.new(@event).as_json, status: 200\n end",
"def event(event, options = {})\n get \"events/#{event}\", options\n end",
"def index\n response = { events: Event.all }\n respond_to do |format|\n format.json { render json: response.to_json }\n format.html { render :index }\n end\n end",
"def index\n render json: Event.all, status: :ok\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def index\n @events = current_user.events\n\n render json: @events\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def event(id, options = {})\n get \"events/#{id}\", options\n end",
"def index\n @events = Event.all\n @event = Event.new\n\n respond_to do |format|\n format.html\n format.json { render 'events/index', events: @events }\n end\n end",
"def show\n @event = Event.find(params[:id])\n @client = Client.find(@event.client_id)\n @event_type = EventType.find(@event.event_type_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end",
"def get_event ( event_key )\n get_api_resource \"#{@@api_base_url}event/#{event_key}\"\n end",
"def get_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\tdo_the_get_call( url: api_url, user: @user )\nend",
"def index\n @event = Event.find(params[:event_id])\n\n end",
"def index\n @upcoming_events = Event.upcoming\n @past_events = Event.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def show\n \trender json: @event\n end",
"def index\n @events = current_user.events\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n @events = getUpcomingEvents()\n \n @page_title = \"Events\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def index\n respond_with(@events)\n end",
"def show\n render json: format_event(@event)\n end",
"def show\n @current_event = CurrentEvent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @current_event }\n end\n end",
"def get_events\n if @user.uuid.present?\n @events = @user.events.active_events.page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n elsif @user.uuid == \"guest\"\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: @user.tenant_id)\n render json: @events\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end",
"def show\n begin\n @event = Event.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to show invalid event #{params[:id]}\"\n redirect_to events_path, notice: 'Invalid event ID'\n else\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end\n end",
"def index\n @events = @category.events\n render json: @events \n end",
"def index\n\t\t@events = Event.all.order('created_at desc')\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render :json => @events }\n\t\tend\n\tend",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @event, methods: [:talks] }\n end\n end",
"def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end",
"def index\n if params[:user]\n @events = Event.where(user: params[:user]).first\n else\n @events = Event.all.order('created_at asc')\n end\n\n render json: @events, :only => [:id, :date, :user, :event_type, :message, :otheruser]\n end",
"def get_event(session, options={})\n json_request \"get\", {:session => session}, options\n end",
"def index\n \n @events = current_user.events\n \n \n respond_to do |format|\n format.html {}\n format.json { render json: Event.events_to_json(@events) }\n end\n end",
"def show\n @calendar = Calendar.find(params[:id])\n @events = Event.find(@calendar.event_ids)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @calendar }\n end\n end"
] |
[
"0.75029767",
"0.74019474",
"0.7361382",
"0.7348975",
"0.73475033",
"0.7338018",
"0.7317425",
"0.72875094",
"0.72813755",
"0.7246173",
"0.72317284",
"0.7219172",
"0.7219172",
"0.7218839",
"0.7218839",
"0.721464",
"0.7204848",
"0.71989256",
"0.7196662",
"0.71925515",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7192214",
"0.7190171",
"0.7189989",
"0.71858066",
"0.71843475",
"0.71817815",
"0.7178166",
"0.716525",
"0.71637964",
"0.7158998",
"0.71580267",
"0.7120116",
"0.7120116",
"0.7120116",
"0.7120116",
"0.7120116",
"0.7104676",
"0.7098543",
"0.70866513",
"0.7075021",
"0.7071629",
"0.70692325",
"0.70692325",
"0.7067004",
"0.70606047",
"0.70606047",
"0.70606047",
"0.70606047",
"0.70606047",
"0.70606047",
"0.70606047",
"0.70606047",
"0.70606047",
"0.70606047",
"0.7050251",
"0.7043129",
"0.70385677",
"0.70330113",
"0.7027942",
"0.7025206",
"0.70196456",
"0.6993209",
"0.69843143",
"0.69733816",
"0.69682246",
"0.69497913",
"0.6949218",
"0.6943893",
"0.6929541",
"0.69259447",
"0.6922537",
"0.69194067",
"0.6912311",
"0.6893206",
"0.689077",
"0.687633",
"0.6853893",
"0.6851784"
] |
0.0
|
-1
|
POST /events POST /events.json
|
def create
@event = Event.new(event_params)
respond_to do | format |
if @event.save
if(params.require(:event).key?("tags"))
tags = Tag.find(params.require(:event)['tags'])
else
tags = Tag.find_by(name: "Other") # Set default tag if none was selected
end
@event.tags << tags
UserEventRelationship.create(event_id: @event.id, user_id: current_user.id, role_type_id: 0)
format.html { redirect_to @event }
format.json { render json: @event, status: :created, location: @event }
else
format.html {render 'new'}
format.json {render json: @event.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_event event, data={}\n data[:event] = event\n post '/event', data\n end",
"def create\n event = Event.new(event_params)\n event.save!\n render json: event\n end",
"def create\n Rails.logger.debug(\"Received event #{params[:event]}\")\n head :ok\n end",
"def create\n @event = Event.new(params[:event])\n\n if @event.save\n render json: @event, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def create\n megam_rest.post_event(to_hash)\n end",
"def create\n @event = Event.new(event_params)\n\n if @event.save\n \tdata = { data: @event, status: :created, message: \"Event was successfully created.\" }\n render :json => data\n else\n \tdata = { data: @event.errors, status: :unprocessable_entity }\n render :json => data\n end\n end",
"def create\n @event = Event.new(event_params)\n if @event.save\n head :created\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def create\n puts params[:event]\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, :notice => 'Event was successfully created.' }\n format.json { render :json => @event, :status => :created, :location => @event }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.json { render :show, status: :created, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.json { render :show, status: :created, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find_by_authentication_token(params[:auth_token])\n @event = Event.new.from_json(params[:event])\n @event.user_id = @user.id\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n @event.organizer = current_user\n\n if @event.save\n render json: @event, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def save\n event = params\n # This assumes that all keys exists. Yay no error handling...\n toSave = Event.new(update_type: event[:event],\n start_time: event[:payload][:event][:start_time_pretty],\n end_time: event[:payload][:event][:end_time_pretty],\n location: event[:payload][:event][:location],\n invitee_name: event[:payload][:invitee][:name],\n duration: event[:payload][:event_type][:duration],\n event_kind: event[:payload][:event_type][:kind])\n toSave.save\n render json: {}, status: 200\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, :notice => 'Event was successfully created.' }\n format.json { render :json => @event, :status => :created, :location => @event }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: t(:event_created) }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params['user_id'] = current_user.id if current_user\n @event = Event.new(event_params)\n\n if @event.save\n render json: { location: format_event(@event) }, status: :created\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to \"/#{@event.url}\" }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def push_events\n saved = []\n jsonHash = request.POST[:_json];\n jsonHash.each do |jsonEvent|\n event = Event.new\n event.race_id = jsonEvent[\"raceId\"]\n event.walker_id = jsonEvent[\"walkerId\"]\n event.eventId = jsonEvent[\"eventId\"]\n event.eventType = jsonEvent[\"type\"]\n event.eventData = jsonEvent[\"data\"]\n event.batteryLevel = jsonEvent[\"batL\"]\n event.batteryState = jsonEvent[\"batS\"]\n event.timestamp = Time.zone.parse(jsonEvent[\"time\"])\n if event.save # if new\n saved << jsonEvent[\"eventId\"]\n if event.race_id != 0 # if not unknown race_id\n after_create(event)\n end\n else # if exists\n saved << jsonEvent[\"eventId\"]\n puts \"Not Saved!\" # debug print\n puts jsonEvent # debug print \n end\n end\n render :json => {:savedEventIds => saved}\n end",
"def create\n result = Event::CreateEvent.perform(event_context)\n\n respond_to do |format|\n if result.success?\n @event = result.event\n format.json { render action: 'show', status: :created }\n else\n format.json { render json: { :errors => result.errors.full_messages }, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n if @event.save\n render :show, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def create\n @event = Events::Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: \"Event #{@event} was successfully created.\" }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: events_path(@event) }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, event: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:event] = convert_datetimes( params[:event] )\n @event = @current_account.events.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # render json: params[:event]\n temp_event = Event.create(\n name: params[:event][:name],\n location: params[:event][:location],\n date: params[:event][:date],\n time: params[:event][:time],\n budget: params[:event][:budget],\n user: current_user\n )\n redirect_to \"/items?event=#{temp_event.id}\"\n end",
"def create\n \n @event = Event.new(event_params)\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event_event = Event::Event.new(params[:event_event])\n\n respond_to do |format|\n if @event_event.save\n format.html { redirect_to @event_event, notice: 'Event was successfully created.' }\n format.json { render json: @event_event, status: :created, location: @event_event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to dashboard_home_path }\n format.json { render 'event', status: :created, event: @event }\n else\n format.html { render dashboard_home_path }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n logger.debug @event.errors.inspect\n format.html { redirect_to @event, notice: 'データが新規作成されました。' }\n format.json { render :show, status: :created, location: @event }\n else\n logger.debug @event.errors.to_hash(true)\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to new_event_path, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, flash: {success: 'Event was successfully created.'} }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, success: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'El evento fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n flash[:success] = \"Event was successfully created.\"\n format.html { redirect_to @event }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @event = Event.new(event_params)\r\n convert_timezone @event\r\n event_type_status @event\r\n if @event.save_without_exception\r\n update_theme @event\r\n add_event_categories @event\r\n add_event_location @event\r\n create_group_guest_list @event\r\n add_photos @event\r\n # Create Groups and contacts through CSV\r\n contacts_imports\r\n render json: SuccessResponse.new(\r\n code: 200, message: 'Event Created.', location: '/events/List?id=' + @event.id.to_s, eventID: @event.id\r\n ), adapter: :json, status: :ok\r\n else\r\n render json: ErrorResponse.new, adapter: :json, status: :unprocessable_entity\r\n end\r\n end",
"def create\n @event = current_user.events.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: t(:event_success) }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_events\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Aula cadastrada com sucesso.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to action: :index, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to new_user_event_path(current_user), notice: 'event was successfully created.' }\n format.json\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n @event.url = BASE_URL + @event.name.gsub(' ', '_')\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_event(url, event, payload_type, payload)\n body = {\n :event => event,\n :payload_type => payload_type }\n body[:payload] = payload if payload\n\n http_post(url) do |req|\n req.headers['Content-Type'] = 'application/json'\n req.body = body.to_json\n req.params['verification'] = 1 if event == 'verification'\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = @calendar.events.new(event_params)\n respond_to do |format|\n if @event.save\n format.json { render json: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n flash[:success] = \"Wydarzenie zostało utworzone.\"\n format.html {redirect_to @event}\n format.json {render :show, status: :created, location: @event}\n else\n format.html {render :new}\n format.json {render json: @event.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to event_registration_path(id: @event.id), notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n @event.creator = @current_user\n\n if @event.save\n @event.users.each do |user|\n p \"event user = #{user.name}\"\n user.send_event_push(PushTypes::NEW_EVENT, current_user.to_push, @event.title)\n end\n else\n render json: @event.errors, status: :unprocessable_entity\n return\n end\n end",
"def create\n @event = Event.new(event_params)\n if @event.save\n render json: @event, status: 201\n @user_event = UserEvent.create(admin: true, event_id: @event.id, user_id: current_user.id)\n else\n render json: { message: \"Please make sure to fill all required fields.\" }, status: 401\n end\n end",
"def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n track_activity @event\n format.html { redirect_to :back, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n after_event_created_mail @event\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @myevent = Myevent.new(params[:myevent])\n\n respond_to do |format|\n if @myevent.save\n format.html { redirect_to @myevent, notice: 'Myevent was successfully created.' }\n format.json { render json: @myevent, status: :created, location: @myevent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @myevent.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7714071",
"0.7611226",
"0.76028967",
"0.7541319",
"0.7444731",
"0.73206913",
"0.73138195",
"0.728203",
"0.7251226",
"0.7235907",
"0.7235907",
"0.7215051",
"0.71682763",
"0.7150409",
"0.7126664",
"0.7118896",
"0.7117831",
"0.71162695",
"0.70964044",
"0.70907074",
"0.7083036",
"0.7081109",
"0.7080767",
"0.7071589",
"0.7057984",
"0.70422375",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7018503",
"0.7016941",
"0.70167124",
"0.70091015",
"0.70081246",
"0.6989661",
"0.6987218",
"0.6970633",
"0.6970633",
"0.6966775",
"0.6948742",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6948119",
"0.6942416",
"0.6936477",
"0.69359535",
"0.69359535",
"0.69318086",
"0.69268054",
"0.6907236",
"0.6905569",
"0.69051725",
"0.6904514",
"0.6902843",
"0.69011873",
"0.6899826",
"0.68961006",
"0.68811166",
"0.68746495",
"0.68642014",
"0.68642014",
"0.6843213",
"0.68419445",
"0.6836244",
"0.68352246",
"0.6820027",
"0.68000513",
"0.6791519"
] |
0.0
|
-1
|
private PATCH/PUT /events/1 PATCH/PUT /events/1.json
|
def update
respond_to do |format|
if @event.update(event_params)
format.html { redirect_to @event, notice: 'Event was successfully updated.' }
format.json { render :show, status: :ok, location: @event }
else
format.html { render :edit }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def patch_event\n user_id = params[\"user_id\"]\n group_id = params[\"group_id\"]\n event_id = params[\"event_id\"]\n\n #TODO Handle 404 if event not found\n event = Event.find(event_id)\n\n json_body = JSON.parse(request.body.read)\n\n @@event_service.patch_event(json_body, user_id, group_id, event_id)\n\n render status: :ok, text: \"\"\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { head :no_content }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n return forbidden unless user_is_owner\n return bad_request unless @event.update_attributes(event_params)\n render json: @event, status: :ok\n end",
"def update\n if @event.update(event_params(params))\n render json: @event, status: 200\n else\n render :json => @event.errors, :status => 422\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render json: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @event.update(event_params)\n render json: @event, status: 201\n else\n render json: { message: \"Error. Error. Please try again.\"}, status: 400\n end\n end",
"def update\n\tif @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @event.update(event_params)\n render json: { location: format_event(@event) }\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render :show, status: :ok, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render :show, status: :ok, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n @event.update(status: \"Pending\")\n else\n @reopen = true\n format.json { render json: @event.errors, status: :unprocessable_entity }\n format.html { render :show }\n end\n end\n end",
"def update\n respond_to do |format|\n if @base_event.update(base_event_params)\n format.json { head :no_content }\n else\n format.json { render json: @base_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n event_id = params[:id]\n if event_id.present? && params[:event].present? && @user.uuid.present? && @user.uuid != \"guest\"\n event_params = params[:event]\n @event = Com::Nbos::Events::Event.where(id: params[:id], user_id: @user.id ).first\n if @event.present?\n @event.update(event_params.permit!)\n if @event.save\n render :json => @event\n else\n data = add_error_messages(@event)\n render :json => data\n end\n else\n render :json => {\"messageCode\": \"module.user.unauthorized\", \"message\": \"Unauthorized to update others Event\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end",
"def put_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\tputs do_the_put_call( url: api_url, user: @user, json: args[:json] )\nend",
"def update\n # @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def pupdate\n @event = Event.find(params[:id])\n respond_to do |format|\n if @event.update_attributes(JSON.parse(params[:event]))\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event = Event.find(params[:id])\n\n if @event.update(params[:event])\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @event.update(event_params)\n \tdata = { data: @event, status: :ok, message: \"Event was successfully updated.\" }\n render :json => data\n else\n \tdata = { data: @event.errors, status: :unprocessable_entity }\n render :json => data\n end\n end",
"def update\n @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def update\n @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def update\n \n \n @event = Event.find(params[:id])\n\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: t(:event_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n \n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html {redirect_to @event, notice: 'Event was successfully updated.'}\n format.json {head :no_content}\n else\n format.html {render action: 'edit'}\n format.json {render json: @event.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n @event.save!\n end\n end",
"def update\n\n respond_to do |format|\n if @event.update(event_params)\n\n format.html { redirect_to @event }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @event, :message => 'Not authorized as an administrator.'\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to '/', notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event = Event.using(:shard_one).find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n\n\n\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to events_path, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: events_path(@event) }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @event.update(event_params)\n render :show, status: :ok, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @event.update(event_params)\n render :show, status: :ok, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to edit_admin_event_path(@event), notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #require \"pry\"; binding.pry\n\n update_users\n\n respond_to do |format|\n if @event.update(event_params)\n sync_update @event\n format.html { redirect_to @event, notice: t(\"successfully_updated\", :model => t(\"models.event\")) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html do\n gflash :notice\n redirect_to @event\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { redirect_to @event }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @event.update(event_params)\r\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @event.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to events_event_path(@event), notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7537089",
"0.73692966",
"0.72826266",
"0.72365457",
"0.7201157",
"0.71830827",
"0.7149663",
"0.7108273",
"0.7076145",
"0.7076145",
"0.7012079",
"0.70069283",
"0.69886845",
"0.6897466",
"0.68738306",
"0.6866166",
"0.6844737",
"0.6843305",
"0.68402004",
"0.68402004",
"0.6834515",
"0.6815093",
"0.6804249",
"0.6804249",
"0.6804249",
"0.6804249",
"0.6804249",
"0.6804249",
"0.6804249",
"0.6804249",
"0.6804249",
"0.6799543",
"0.6797781",
"0.67887014",
"0.6773746",
"0.675526",
"0.6735145",
"0.67330444",
"0.6728715",
"0.6728715",
"0.67172474",
"0.67167974",
"0.6716505",
"0.67040366",
"0.6698212",
"0.6693169",
"0.6690364"
] |
0.6687046
|
95
|
DELETE /events/1 DELETE /events/1.json
|
def destroy
@event.destroy
respond_to do |format|
format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_event\n if params[:id]\n @e = Evento.find(params[:id]).destroy\n end\n render :json => msj = { :status => true, :message => 'ok'}\n end",
"def destroy\n @event = Event.find(params[:id])\n \n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n # @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @events = Event.where(event_id: params[:id])\n @events.each.destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @event_event = Event::Event.find(params[:id])\n @event_event.destroy\n\n respond_to do |format|\n format.html { redirect_to event_events_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @myevent = Myevent.find(params[:id])\n @myevent.destroy\n\n respond_to do |format|\n format.html { redirect_to myevents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n\n sync_destroy @event\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html {redirect_to events_url}\n format.json {head :no_content}\n end\n end",
"def destroy\n @calevent = Calevent.find(params[:id])\n @calevent.destroy\n\n respond_to do |format|\n format.html { redirect_to calevents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n #@event.update_attribute(:deleted, true)\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n render :nothing => true, :status => 200, :content_type => 'text/plain'\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url, notice: t(:event_deleted) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_events_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n head :no_content\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Event was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'データが削除されました。' }\n format.json { head :no_content }\n end\n end",
"def delete_event\r\n event = Event.find_by(id: params[:eventid].to_i)\r\n if event.present?\r\n event.update(status: 3)\r\n lt_update_event_status event, 'archived'\r\n render json: SuccessResponse.new(\r\n code: 200,\r\n message: 'Event Deleted.'\r\n ), adapter: :json, status: :ok\r\n else\r\n render json: ErrorResponse.new(\r\n code: 404,\r\n message: 'Event not found!'\r\n ), adapter: :json, status: :not_found\r\n end\r\n\r\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @client = Client.find(@event.client_id)\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_to_client_path(@client) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_request = EventRequest.find(params[:id])\n @event_request.destroy\n\n respond_to do |format|\n format.html { redirect_to event_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Мероприятие успешно удалено.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = current_user.events.find_by_url(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_event.destroy\n respond_to do |format|\n format.html { redirect_to post_events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = @current_account.events.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @evento = Evento.find(params[:id])\n @evento.destroy\n\n respond_to do |format|\n format.html { redirect_to eventos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @eventtype.events.each do |e|\n e.destroy\n end\n @eventtype.destroy\n respond_to do |format|\n format.html { redirect_to eventtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy \n @event.destroy \n respond_to do |format|\n format.html { redirect_to events_url, success: 'Event was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.mobile { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @create_event = CreateEvent.find(params[:id])\n @create_event.destroy\n\n respond_to do |format|\n format.html { redirect_to create_events_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7693181",
"0.7687918",
"0.7687918",
"0.7687918",
"0.76818216",
"0.75862354",
"0.7569196",
"0.7561378",
"0.7541531",
"0.7541216",
"0.7541216",
"0.7541216",
"0.7541216",
"0.7541216",
"0.7541216",
"0.7541216",
"0.7541216",
"0.7541216",
"0.7541216",
"0.7541216",
"0.754035",
"0.7539055",
"0.7538002",
"0.75270826",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.7519824",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.75153315",
"0.74957514",
"0.7465986",
"0.745978",
"0.7453816",
"0.7447803",
"0.7440907",
"0.74406576",
"0.7435698",
"0.74325156",
"0.74026173",
"0.7388795",
"0.73783016",
"0.7372169",
"0.7365898",
"0.73388004",
"0.7335741",
"0.7335741",
"0.7323916",
"0.73013246",
"0.72973156",
"0.72913134",
"0.7290662",
"0.7290012",
"0.72889847",
"0.7285712",
"0.7283969",
"0.7282883",
"0.72727853",
"0.727015"
] |
0.0
|
-1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.